7

Hopefully this is a very simple question. I have a makefile pattern rule that looks like this:

%.so : %.f %.pyf f2py -c -L${LAPACK_DIR} ${GRASPLIBS} -m $* $^ ${SOURCES} --opt='-02' --f77flags='-fcray-pointer' >> silent.txt 

I want the makefile to build a number of .so files, so I tried to get it to build two files (radgrd_py.so and lodiso_py.so) by doing this:

radgrd_py.so lodiso_py.so: %.so : %.f %.pyf f2py -c -L${LAPACK_DIR} ${GRASPLIBS} -m $* $^ ${SOURCES} --opt='-02' --f77flags='-fcray-pointer' >> silent.txt 

and then tried this:

radgrd_py.so: lodiso_py.so: %.so : %.f %.pyf f2py -c -L${LAPACK_DIR} ${GRASPLIBS} -m $* $^ ${SOURCES} --opt='-02' --f77flags='-fcray-pointer' >> silent.txt 

But in each case, it only builds the first target that I specify. If I run 'make radgrd_py.so' it works fine, I'm just not sure how to specify a list of files that need to be built so I can just run 'make'.

2 Answers 2

14

The usual trick is to add a 'dummy' target as the first that depends on all targets you want to build when running a plain make:

all: radgrd_py.so lodiso_py.so 

It is a convention to call this target 'all' or 'default'. For extra correctness, let make know that this is not a real file by adding this line to your Makefile:

.PHONY: all 
Sign up to request clarification or add additional context in comments.

Comments

5

Best way is to add:

.PHONY: all .DEFAULT: all all: radgrd_py.so lodiso_py.so

Explanations:

make uses the first target appearing when no .DEFAULT is specified.

.PHONY informs make that the targets (a coma-separated list, in fact) don't create any file or folder.

all: as proposed by schot

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.