I want to write some conditionals in a Makefile, following the guide at http://sunsite.ualberta.ca/Documentation/Gnu/make-3.79/html_chapter/make_7.html#SEC72. However, I get the error Makefile:219: *** missing separator. Stop.
, where line 219 is the line with the ifeq
statement. The three lines with the -$(FC)
do start with a tab.
I'm using GNU Make 3.81. Any help is greatly appreciated!
[...]
mod: $(MODBIN)
$(MODBIN): $(MODSRC)
ifeq($(FC),gfortran)
-$(FC) $(MODFLAGS) -J$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq($(FC),ifort)
-$(FC) $(MODFLAGS) -module $(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(FC),xlf2003_r)
-$(FC) $(MODFLAGS) -qmoddir=$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
endif
io: $(IOBIN)
[...]
EDIT: Following the advice by @sagar-sakre, I changed to this:
[...]
mod: $(MODBIN)
$(MODBIN): $(MODSRC)
ifeq($(B3dC),gfortran)
-$(FC) $(MODFLAGS) -J$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq($(B3dC),ifort)
-$(FC) $(MODFLAGS) -module $(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(B3dC),xlf2003_r)
-$(FC) $(MODFLAGS) -qmoddir=$(INCPATH) $(INCLUDE) -c -o $@ $(subst $(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
endif endif endif
io: $(IOBIN)
[...]
However, now I get this error:
ifeq(xlf,gfortran)
/bin/sh: -c: line 0: syntax error near unexpected token `xlf,gfortran'
/bin/sh: -c: line 0: `ifeq(xlf,gfortran)'
make: *** [build/basic.o] Error 2
So still something's wrong here ...
There should be a [space] after ifeq
mod: $(MODBIN)
$(MODBIN): $(MODSRC)
ifeq ($(FC),gfortran)
-$(FC) $(MODFLAGS) -J$(INCPATH) $(INCLUDE) -c -o $@ $(subst
$(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(FC),ifort)
-$(FC) $(MODFLAGS) -module $(INCPATH) $(INCLUDE) -c -o $@ $(subst
$(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
else ifeq ($(FC),xlf2003_r)
-$(FC) $(MODFLAGS) -qmoddir=$(INCPATH) $(INCLUDE) -c -o $@ $(subst
$(BUILDPATH),$(MODPATH),$*).f90 $(NETCDFLDFLAGS)
endif
General Makefile would be
target:dependencies
ifeq ( parm1, parm2)
[TAB] operation
else
[TAB] operation
endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With