I have a case where I have an executable that depends on a shared library. Thus as a dependency for the exe then there is a dependency to build the library.
Now the compilation of these are almost identical except for one define "-Dsomeflag". The rules to build both targets are placed in one common place. So if I add the "-Dsomeflag" then I will accidently make it apply for both.
Is it possible to do it conditionally for only a part of the code?
Thanks.
Henrik
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
if I understand you right, you have some .o files which need to be compiled differently depending on whether this is for the lib or the exe?
This is tricky, because either way there is only one .o file and makepp can only compile it in one way at a time, even if you put in some ifdefs based on the target. So whenever you change the target, makepp would have to compile to and fro (which could be eased with the build cache).
I would think it cleaner to compile into two different object directories and link each from there, then they could be built at the same time, and the whole build would always be consistent:
exeobjs/%.o: %.c
... -DEXEDEF ...
libobjs/%.o: %.c
... -DLIBDEF ...
regards
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Instead what I did was to make use of another feature like:
$(OBJECTS) : CPLATFORM += -DXF_TESTCASE
This seems to work fine for one makefile. However I am starting to believe there are bugs in makepp. Because for another makefile it only worked on the first item when I specified it as:
B, C and D did never get this applied and thus compilation starts to fail. Is there any way you could find out if it's a bug or something that I could do to verify this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a case where I have an executable that depends on a shared library. Thus as a dependency for the exe then there is a dependency to build the library.
Now the compilation of these are almost identical except for one define "-Dsomeflag". The rules to build both targets are placed in one common place. So if I add the "-Dsomeflag" then I will accidently make it apply for both.
Is it possible to do it conditionally for only a part of the code?
Thanks.
Henrik
Hi Henrik,
if I understand you right, you have some .o files which need to be compiled differently depending on whether this is for the lib or the exe?
This is tricky, because either way there is only one .o file and makepp can only compile it in one way at a time, even if you put in some ifdefs based on the target. So whenever you change the target, makepp would have to compile to and fro (which could be eased with the build cache).
I would think it cleaner to compile into two different object directories and link each from there, then they could be built at the same time, and the whole build would always be consistent:
exeobjs/%.o: %.c
... -DEXEDEF ...
libobjs/%.o: %.c
... -DLIBDEF ...
regards
Daniel
Instead what I did was to make use of another feature like:
$(OBJECTS) : CPLATFORM += -DXF_TESTCASE
This seems to work fine for one makefile. However I am starting to believe there are bugs in makepp. Because for another makefile it only worked on the first item when I specified it as:
$(OBJECTS_A) : CPLATFORM += -DXF_TESTCASE
$(OBJECTS_B) : CPLATFORM += -DXF_TESTCASE
$(OBJECTS_C) : CPLATFORM += -DXF_TESTCASE
$(OBJECTS_D) : CPLATFORM += -DXF_TESTCASE
B, C and D did never get this applied and thus compilation starts to fail. Is there any way you could find out if it's a bug or something that I could do to verify this?
Hi Henrik,
I tried
$(phony all): a aa b bb c cc d dd
OBJECTS_A = a aa
OBJECTS_B = b bb
OBJECTS_C = c cc
OBJECTS_D = d dd
CPLATFORM = C
$(OBJECTS_A) : CPLATFORM += -DXF_TESTCASEa
$(OBJECTS_B) : CPLATFORM += -DXF_TESTCASEb
$(OBJECTS_C) : CPLATFORM += -DXF_TESTCASEc
$(OBJECTS_D) : CPLATFORM += -DXF_TESTCASEd
$(foreach): :foreach a aa b bb c cc d dd
&echo ':$(CPLATFORM):' -o $(output)
and it gave me an expected
&echo ':C -DXF_TESTCASEa:' -o a
&echo ':C -DXF_TESTCASEa:' -o aa
&echo ':C -DXF_TESTCASEb:' -o b
&echo ':C -DXF_TESTCASEb:' -o bb
&echo ':C -DXF_TESTCASEc:' -o c
&echo ':C -DXF_TESTCASEc:' -o cc
&echo ':C -DXF_TESTCASEd:' -o d
&echo ':C -DXF_TESTCASEd:' -o dd
Please submit a reproducible error report!
regards
Daniel