0

I would like to do the following. I don't know whether it's possible to do it. If possible I would like to know how to do it.

make VAR1=arg1,arg2,arg3

based on the arg I would like to pass a switch to gcc.

For example,

if arg1 and arg2 are passed I would like to define a switch and if arg2 and arg3 are passed I would like to define another switch in the make file. How do I do that?

Kitcha
  • 1,641
  • 6
  • 19
  • 20

2 Answers2

0

Did you check GMSL?

http://gmsl.sourceforge.net/

conditional-directive
text-if-true
endif

https://stackoverflow.com/a/180818/643500

...

if you want to pass it seperated by commas, then you can split the string and pass it to the if statements.

Community
  • 1
  • 1
Sully
  • 14,672
  • 5
  • 54
  • 79
0

Use make VAR1="arg1 arg2 arg3" with this in the makefile:

ifeq (arg1 arg2,$(findstring arg1,$(VAR1)) $(findstring arg2,$(VAR1)))
# define a switch
endif

ifeq (arg2 arg3,$(findstring arg2,$(VAR1)) $(findstring arg3,$(VAR1)))
# define another switch
endif

If there are a lot of these switches, you can define a macro to simplify the makefile.

Beta
  • 96,650
  • 16
  • 149
  • 150