Flavio Alberto
Flavio Alberto

Reputation: 31

How to pass shell variable to autogen.sh script

I calling a autogen.sh script from other Makefile, and this Makefile is called from a shell script, If I set a variable VAR on this more external script I can use-it normally inside this Makefile, really VAR exists and is defined, but when this Makefile runs autogen.sh I cannot use the variable VAR in configure.in file, the only way to get this (or any other variable) is using export command in more external shell.

compile: pushd $(DIRNAME); \ if test ! -e Makefile; then \ echo $PKG_CONFIG_PATH; \ ./autogen.sh $(CONFIGURE_OPTIONS); \ fi; \ make; \ popd

This is the best way to do this ?

Thanks in advance

Upvotes: 3

Views: 1616

Answers (2)

Tuxdude
Tuxdude

Reputation: 49473

You could either follow the suggestion from Idelic of passing the variable to autogen.sh explicitly as part of the command:

PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" ./autogen.sh $(CONFIGURE_OPTIONS)

or, if you have multiple scripts and commands you call from the Makefile and you want to export a bunch of environment variables to any command invoked from this Makefile, you could just add these lines to your Makefile:

export PKG_CONFIG_PATH="YOUR_PKG_CONFIG_PATH"
export FOO="BLAH"
export BAR="BLAH-BLAH"

Upvotes: 4

Idelic
Idelic

Reputation: 15582

You can pass the variable explicitly in the autogen.sh invocation:

PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)" ./autogen.sh $(CONFIGURE_OPTIONS)

Upvotes: 2

Related Questions