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:
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.
On Sat, 2016-09-24 at 10:31 +1000, Karl May wrote:
> 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.
VPATH is intended only for locating remote _source_ files. It cannot be
used to find object files.
If you want to create two different sets of object files you need to
write two different pattern rules with different directories. Since
your makefile is not complete (you didn't show what operations you
wanted for the OMP version, nor how you are going to decide which
version to build) it's hard to give an example.