Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

problems generating prerequisites automatically

parker__velocity
New Contributor I
395 Views

i have a mixed fortran/c++ code. generated a Makefile that correctly compiles the code. however, i ran into a problem generating prerequisites automatically for the c++ parts. the relevant part of the Makefile is

$(DEPDIR)/%.d: %.cpp 
        @echo "Constructing dependencies for $<..."
        @set -e; rm -f $@; \
         $(CXX) -MT '$$(BLDDIR)/$(subst .cpp,.o,$<)' -MM $< > $@.T; \
         sed "s,\($*\)\.o[ :]*,\1.o $@ : ,g" < $@.T > $@; \
         rm -f $@.T

when CXX=g++ (version 8), i get the correct *.d files, for example

$(BLDDIR)/src/FP/export.o .build/dep/src/FP/export.d : src/FP/export.cpp src/FP/lib-array.h \
 src/FP/lib-algorithms.h src/FP/state.h src/FP/formulary.h \
 src/FP/export.h

when CXX=icpc (version 19, update 3 on CentOS 7.6) there's an extra '$'

$$(BLDDIR)/src/FP/export.o .build/dep/src/FP/export.d : src/FP/export.cpp src/FP/lib-array.h \
 src/FP/lib-algorithms.h src/FP/state.h src/FP/formulary.h \
 src/FP/export.h

which, of course, fails to force a recompile of export.cpp if any of its headers change. any suggestions? i've tried -MQ option, but doesn't really matter. is there a way i can force icpc to generate the same thing as g++?

0 Kudos
1 Reply
parker__velocity
New Contributor I
395 Views

so, a workaround would be to replace the sed w/ the following:

sed -e 's,\$$\$$,\$$,' -e "s,\($*\)\.o[ :]*,\1.o $@ : ,g" < $@.T > $@; \

but i would prefer to understand why there's an extra $.

0 Kudos
Reply