help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"targetted" pattern rules


From: Helge Avlesen
Subject: "targetted" pattern rules
Date: Fri, 17 Feb 2006 17:44:27 +0100

Dear make gurus

I am trying to build a large application made from 5 types of source
files, where the files of each type in some cases needs different sets
of flags to build, using only one Makefile.
the object files in the Makefile are currently grouped like this:
(except that OBJS totally consists of ca 3500 files)

OBJS1=\
dir1/file1.o \
dir2/file2.o \
...
OBJS2=\
dir1/file3.o \
dir2/file4.o \
...
OBJS=$(OBJS1) $(OBJS2)

main: $(OBJS)
     $(LD) ... -o prog $(OBJS) ...
include dependencies

a complete list of dependencies is included, and works well with one
set of compiler flags.
now, what I want is to create pattern rules, that will compile the
OBJS1 group with one set of
flags and OBJS2 with another, in a previous project I had only one
type of files (.f90) and I could achieve this by using the pattern
rules
...
$(OBJS1) : %.o : %.f90 ; $(F95) -c $(FREEFLAGS1)   -o $@ $<
$(OBJS2) : %.o : %.f90 ; $(F95) -c $(FREEFLAGS2)   -o $@ $<
...
the makefile worked as expected, compiled all OBJS1 files with
FREEFLAGS1 and OBJS2 using FREEFLAGS2. make did, however, not like me
to extend this scheme...
when I in the bigger project tried to include similar rules for the other types
...
$(OBJS1) : %.o : %.F90 ; $(F95) -c $(PFREEFLAGS1)  -o $@ $<
$(OBJS1) : %.o : %.F   ; $(F95) -c $(PFIXEDFLAGS1) -o $@ $<
$(OBJS1) : %.o : %.f90 ; $(F95) -c $(FREEFLAGS1)   -o $@ $<
$(OBJS1) : %.o : %.f   ; $(F95) -c $(FIXEDFLAGS1)  -o $@ $<
$(OBJS1) : %.o : %.c   ; $(CC)  -c $(CFLAGS1)      -o $@ $<
$(OBJS2) : %.o : %.F90 ; $(F95) -c $(PFREEFLAGS2)  -o $@ $<
$(OBJS2) : %.o : %.F   ; $(F95) -c $(PFIXEDFLAGS2) -o $@ $<
$(OBJS2) : %.o : %.f90 ; $(F95) -c $(FREEFLAGS2)   -o $@ $<
$(OBJS2) : %.o : %.f   ; $(F95) -c $(FIXEDFLAGS2)  -o $@ $<
$(OBJS2) : %.o : %.c   ; $(CC)  -c $(CFLAGS2)      -o $@ $<
...

I got loads of warnings of the type
Makefile:43: warning: overriding commands for target `../src/internal4.o'
Makefile:40: warning: ignoring old commands for target `../src/internal4.o'
...
clearly there is a thing or two I do not understand about pattern rules,
so I would be very grateful if anyone could give a hint on how I can
achieve my goal
without explicitly specifying rules for each file...

Helge




reply via email to

[Prev in Thread] Current Thread [Next in Thread]