[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Different compilation based on filename
From: |
CHEN Cheng |
Subject: |
Re: Different compilation based on filename |
Date: |
Thu, 10 Sep 2009 21:17:55 +0800 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
On Thu, Sep 10, 2009 at 02:50:47PM +0200, Christian Rogsch wrote:
[...]
> I have the following problem with a makefile: I want to compile files with
> different compiler flags, based on the name of the file.
>
> Example1:
> filename is (I call it type1 file): func.f90
> make should do: $(FCOMPL) -c $(FFLAGS) $(FOPENMPFLAGS) $<
>
> Example2:
> filename is (I call it type2 file): smvv.f90
> make should do: $(FCOMPL) -c $(FFLAGS) $<
>
> Based on the makefile I have it should be (pseudocode):
>
> .f90.o:
> if filename = func.f90
> or filename = part.f90
> or filename = divg.f90
> $(FCOMPL) -c $(FFLAGS) $(FOPENMPFLAGS) $<
> else
> $(FCOMPL) -c $(FFLAGS) $<
>
> thus I want to create a list with different filenames (or if-then-else)
> where make should check if this file is a type1 file and then it should
> compile like example1, if it is not a typ1 file, it should compile like
> example2, like shown above.
>
Target-specific variables may help on this problem, please see the code
below:
# if the target is bb.o, then append more flags to $(CFLAGS)
bb.o: CFLAGS += -g
CFLAGS=-c
all: aa.o bb.o cc.o
@echo ok
%.c:
@:
%.o: %.c
@echo gcc -o $@ $*.c $(CFLAGS)
HTH,
Cheng