help-make
[Top][All Lists]
Advanced

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

vpath problem when making static libraries


From: Karl May
Subject: vpath problem when making static libraries
Date: Sat, 24 Sep 2016 10:31:35 +1000
User-agent: KMail/5.3.1 (Linux/4.7.4-1-ARCH; KDE/5.26.0; x86_64; ; )

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



reply via email to

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