Skip to content

Makefile ignores additional sources and has no clean target #5

Description

@dmccoystephenson

The Makefile contains a single artifact target naming one source file explicitly:

all: testing

testing: src/testing.cpp
	@echo "---"
	@echo "Compiling testing.cpp"

	g++ src/testing.cpp -o testing

	@echo "Finished compiling testing.cpp"

Two gaps are visible for a starter template whose purpose is to be extended:

  • A second source file is silently ignored. Adding src/foo.cpp produces no build error and no link error — the file is simply never compiled, because both the prerequisite list and the g++ invocation name src/testing.cpp literally. The failure is silent, which is the hardest kind to notice when starting a project from this template.
  • No clean target exists. Removal of the build artifact is instead open-coded in cr.sh as rm ./testing, so the knowledge of what the build produces is duplicated in two places that can disagree.

Additionally, no warning flags are passed: g++ is invoked without -Wall -Wextra, so a project started from this template compiles with warnings suppressed by default.

Proposed resolution (each part is separable, and the wildcard change is the largest):

  1. Add a clean target that removes ./testing, and have cr.sh call it instead of open-coding the removal.
  2. Consider building from a wildcard over src/*.cpp so that added sources are picked up.
  3. Consider adding -Wall -Wextra to the compile line.

Note that Makefile is the build contract inherited by every project generated from this template, so changes here deserve deliberate review rather than being folded into unrelated work.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions