Originally Posted by
matsp
Code:
....
$debug ?= n // Default to no debug - don't set debug if it already has a value.
ifeq($debug, y) // If debug was set
CCFLAGS += -g
else
CCFLAGS += -O2
endif
...
Code:
optimize:
make -f makefile.step2 CCFLAGS=-O2
debug:
make -f makefile.step2 CCFLAGS=-g
I'm using make 3.81 on ubuntu 7.04
I used the method #1 and the shell prompt:
Code:
ifeq (debug, y)
/bin/sh: Syntax error: word unexpected (expecting ")")
make: *** [all] Error 2
I've checked the manual of make, and I've tried $(debug) or debug, y or "y"
but the syntax seems to be legal:
The syntax of the conditional-directive is the same whether the conditional is simple or complex; after an else or not. There are four different directives that test different conditions. Here is a table of them:
ifeq (arg1, arg2)
ifeq 'arg1' 'arg2'
ifeq "arg1" "arg2"
ifeq "arg1" 'arg2'
ifeq 'arg1' "arg2"
If I use method #2 the shell will prompt:
Code:
make -f makefile.step2 CCFLAGS=-O2
make[1]: Entering directory `/home/jutirain/Research/Semi-automatic_Composition/Code/trunk'
make[1]: makefile.step2: No such file or directory
make[1]: *** No rule to make target `makefile.step2'. Stop.
make[1]: Leaving directory `/home/jutirain/Research/Semi-automatic_Composition/Code/trunk'
make: *** [optimize] Error 2
So, how to generate makefile "on the fly"?
Why is it so hard to write makefile...