schuelermine
schuelermine

Reputation: 2288

Make: No main target

Is it possible to make make not have a main target, meaning that invocations to make without a specified target would fail, even if a first target exists?

Upvotes: 0

Views: 48

Answers (1)

MadScientist
MadScientist

Reputation: 101111

Not specifically that, but if you are using GNU make there are ways to ensure users provide a goal on the command line.

First, you could check MAKECMDGOALS:

ifeq ($(MAKECMDGOALS),)
$(error Missing command line goal!)
endif

Or alternatively you could use .DEFAULT_GOAL to force the default goal to be a rule that fails:

.DEFAULT_GOAL = fail
fail:; @echo Missing command line goal; exit 1

Upvotes: 2

Related Questions