Use make variable in builtin shell function in a Makefile

Shiplu Mokaddim

I have this make file

all : CONFIG=config.ini
debug : CONFIG=config-debug.ini

CONFIG_FILES := $(shell python parse_config.py -i $(CONFIG))

all: $(CONFIG) $(CONFIG_FILES)
    echo $(CONFIG) $(CONFIG_FILES)

When I run make all it shows some python error saying -i option param is missing. So it seems $(CONFIG) is not going through shell function.

How can make all invoke python parse_config.py -i 'config.ini'?

same way make debug invoke python parse_config.py -i 'config-debug.ini'?

Update:

After running make all SHELL+=-x I get following output.

+ python parse_config.py -p static -i
usage: parse_config.py [-h] -i INPUT_JSB3 [-p PREFIX]
parse_config.py: error: argument -i: expected one argument

But after that I get

+ python parse_config.py -p static -i static/config.ini

And make seems to continue to work.

Shiplu Mokaddim

This can be done using MAKECMDGOALS variable.

ifeq ($(findstring debug,$(MAKECMDGOALS)),debug)
CONFIG=config-debug.ini
else
CONFIG=config.ini
endif

CONFIG_FILES := $(shell python parse_config.py -i $(CONFIG))

all: $(CONFIG) $(CONFIG_FILES)
    echo $(CONFIG) $(CONFIG_FILES)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to use shell builtin function from a Makefile?

From Dev

Pass for loop variable to shell function in makefile

From Dev

What is the variable $(MAKE) in a makefile?

From Dev

Set shell environment variable without using a shell builtin command

From Dev

Makefile : delimit a shell variable ($$var)

From Dev

How to use variable with ':' in a Makefile?

From Dev

GNU Make - Set MAKEFILE variable from shell command output within a rule/target

From Dev

How to make `man` work for shell builtin commands and keywords?

From Dev

How to make `man` work for shell builtin commands and keywords?

From Dev

bash builtin commands in makefile

From Dev

Setting variable in Makefile through shell script logic or native make logic but assigning default value when not found in environment variable

From Dev

how to make my user defined function be a builtin function?

From Dev

Is it possible to use alias expansion with shell's builtin commands in Git?

From Dev

How to use an exported variable in a makefile?

From Dev

can't use variable in Makefile

From Dev

How to use an exported variable in a makefile?

From Java

How to get a shell environment variable in a makefile?

From Dev

Makefile patsubst using value of shell variable

From Dev

Execute shell function in variable

From Dev

Use a shell variable in awk

From Dev

use of the 'SHELL' environment variable

From Dev

How to invoke a function in a shell script from a Makefile

From Dev

How to use echo in shell command from Makefile?

From Dev

How can I make this javascript function not use a global variable?

From Dev

Overriding a makefile variable depending on the type of make

From Dev

A variable is defined in makefile but Make ignores it. Why?

From Dev

AIX make/makefile : variable assignment is not working

From Dev

makefile: fail on single make target if variable empty

From Dev

shell builtin with redirection

Related Related

  1. 1

    How to use shell builtin function from a Makefile?

  2. 2

    Pass for loop variable to shell function in makefile

  3. 3

    What is the variable $(MAKE) in a makefile?

  4. 4

    Set shell environment variable without using a shell builtin command

  5. 5

    Makefile : delimit a shell variable ($$var)

  6. 6

    How to use variable with ':' in a Makefile?

  7. 7

    GNU Make - Set MAKEFILE variable from shell command output within a rule/target

  8. 8

    How to make `man` work for shell builtin commands and keywords?

  9. 9

    How to make `man` work for shell builtin commands and keywords?

  10. 10

    bash builtin commands in makefile

  11. 11

    Setting variable in Makefile through shell script logic or native make logic but assigning default value when not found in environment variable

  12. 12

    how to make my user defined function be a builtin function?

  13. 13

    Is it possible to use alias expansion with shell's builtin commands in Git?

  14. 14

    How to use an exported variable in a makefile?

  15. 15

    can't use variable in Makefile

  16. 16

    How to use an exported variable in a makefile?

  17. 17

    How to get a shell environment variable in a makefile?

  18. 18

    Makefile patsubst using value of shell variable

  19. 19

    Execute shell function in variable

  20. 20

    Use a shell variable in awk

  21. 21

    use of the 'SHELL' environment variable

  22. 22

    How to invoke a function in a shell script from a Makefile

  23. 23

    How to use echo in shell command from Makefile?

  24. 24

    How can I make this javascript function not use a global variable?

  25. 25

    Overriding a makefile variable depending on the type of make

  26. 26

    A variable is defined in makefile but Make ignores it. Why?

  27. 27

    AIX make/makefile : variable assignment is not working

  28. 28

    makefile: fail on single make target if variable empty

  29. 29

    shell builtin with redirection

HotTag

Archive