Makefile.in and variable substitution
Asked Answered
C

2

12

In Makefile.in I see variable definition where an external variable name is enclosed between two @ symbols

# @configure_input@

package = @PACKAGE_NAME@

Where those external variables come from? Also, I couldn't find in GNU manual what does exactly enclosing a variable between two @ symbols mean? Is it something specific to Makefile.in?

Thank you.

Crapulous answered 25/7, 2012 at 5:59 Comment(0)
S
11

It's an autoconf thing.

When ./configure finishes running, it generates and executes a file called config.status, which is a shell script that has the final value of the variable substitutions (anything declared with AC_SUBST).

Anything that is declared in AC_CONFIG_FILES is processed by config.status, usually by turning foo.in into foo.

When automake processes Makefile.am into Makefile.in, any AC_SUBST variable is automatically made available (using a declaration like FOO = @FOO@), unless it's suppressed by a call to AM_SUBST_NOTMAKE.

Surplus answered 25/7, 2012 at 11:20 Comment(2)
What about PACKAGE_NAME in the question? In my Makefile.am I used @datadir@/@package_name@, and it was substituted to ${datarootdir}/@package_name@, which is obviously not correct.Photogenic
PACKAGE_NAME is special - it's set by AC_INIT as tiwo mentions below.Surplus
C
5

(I am not an expert, but) Yes they are specific to Makefile.in, and configure replaces them when assembling the Makefile, see the Autoconf Manual, section 4.8. For example, @PACKAGE_NAME@ is defined by AC_INIT.

Contextual answered 25/7, 2012 at 10:12 Comment(1)
Also read Jack's answer (and give him that checkmark).Contextual

© 2022 - 2024 — McMap. All rights reserved.