Hi there, I wanna make two different static libraries from the same FORTRAN source files, one with OMP support, one without. Thus %.o file generated during compilation will differ and must be keept for updating both the libraries when one files has changed (to avoid making MAKE recompiling everything). Since the naming of the %.o files is the same they will be kept in two different directories.
With the following setting I have managed to get full recompilation and rebuilding after "make clean", and, if one source file has changed, recompilation of that file and library update: #makefile SRC := FORTRAN = ifort OPTS = -O3 -mkl=sequential -warn nounused -warn declarations DRVOPTS = $(OPTS) LOADER = ifort ARCH = ar ARCHFLAGS= cr RANLIB = ranlib kernel=$(shell uname -r) LibName=Lib_Tools_$(FORTRAN)_$(kernel)_1.0.a .SUFFIXES: .SUFFIXES: .f90 include src/Moduls_MKL.mk vpath %.o NoOMP/ vpath %.f90 src/ OBJS = $(subst .f90,.o,$(SRC)) %.o: %.f90 $(FORTRAN) $(OPTS) -c $< -o $(addprefix NoOMP/,$@) $(LibName): $(OBJS) $(ARCH) $(ARCHFLAGS) $@ $(addprefix NoOMP/,$?) $(RANLIB) $@ clean: -rm *.smod -rm *.mod -rm NoOMP/*.o -rm $(LibName) However, if I remove the library from the folder, MAKE tries to rebuilt the target. Since none of the %.o files need to be rebuilt, their filename is expanded by "NoOMP/". Thus "$(addprefix NoOMP/,$?)" will result in an additional expansion and AR will complain that it could not find files named "NoOMP/NoOMP/*.o". The same holds when removing the library and in addition changing one source file. The only remedy I could figure out is to execute "make clean; make". Then filename prefixes introduced by vpath will be dropped and expansion via "$ (addprefix)" will yield the correct results. Or I change to "$(ARCH) $ (ARCHFLAGS) $@ $?", which will cause subsequent trouble for re-compiled files. Thus, the final goal is, in addition to the already correct behaviour, to get MAKE rebuilding the library from scratch using old %.o files only in "NoOMP/", or using old %.o files and new %.o files in "NoOMP/". Is there any way to achive that without an additional makefile. Thanks a lot Karl _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make