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.

jww
  • 97,681
  • 90
  • 411
  • 885
pic11
  • 14,267
  • 21
  • 83
  • 119

2 Answers2

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.

Jack Kelly
  • 18,264
  • 2
  • 56
  • 81
  • 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. – jww Nov 06 '17 at 22:42
  • `PACKAGE_NAME` is special - it's set by `AC_INIT` as tiwo mentions below. – Jack Kelly Feb 01 '18 at 06:03
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.

tiwo
  • 3,238
  • 1
  • 20
  • 33
  • Also read [Jack's answer](http://stackoverflow.com/a/11648552) (and give him that checkmark). – tiwo Jul 25 '12 at 15:15