Reputation: 17487
My FreeBSD
is 11.0
, and find the make
can't process the ifdef
directives. For example:
ifdef VERBOSE
Q :=
else
Q := @
endif
The make
will complain:
make: "/root/Project/powermon/Makefile" line 13: Need an operator
make: "/root/Project/powermon/Makefile" line 15: Need an operator
make: "/root/Project/powermon/Makefile" line 17: Need an operator
My current solution is using gmake
instead. So does any make
port on FreeBSD
support processing ifdef
?
Upvotes: 7
Views: 2249
Reputation: 2118
A more portable way to write something like that is:
Q$(VERBOSE) := @
Upvotes: 0
Reputation:
BSD make uses different syntax and has different features than GNU make. The snippet you show should look like the following for BSD make:
.ifdef VERBOSE
Q :=
.else
Q := @
.endif
You have basically three options:
make
.make
that every known make
tool implements (e.g. don't use any pattern rules etc). This can be tedious and there are other tools helping to manage this by generating the Makefile like cmake
or the GNU autotools.GNUmakefile
, so it is never interpreted by any other make
than GNU make) and rely on the fact that GNU make is available nearly everywhere. For FreeBSD, this would mean installing the appropriate port.If you go with the third option, you can add a "wrapper" Makefile
like e.g. this:
GNUMAKE?= gmake
all:
${GNUMAKE} $@
.DEFAULT:
${GNUMAKE} $@
.PHONY: all
Typing make
on BSD will cause the BSD make to read this file and accordingly call gmake
. On a GNU system (where make
is GNU make), this file will be ignored when there is a GNUmakefile
-- GNU make prefers this over just Makefile
.
Upvotes: 9