Skip to content

Instantly share code, notes, and snippets.

@sushidub
Last active March 26, 2020 04:16
Show Gist options
  • Save sushidub/110e3436023fc90b5be1b2a07da8984d to your computer and use it in GitHub Desktop.
Save sushidub/110e3436023fc90b5be1b2a07da8984d to your computer and use it in GitHub Desktop.
Notes and quotes on building from source files

When using a gcc based toolchain, be mindful that you should have the autotools installed (autoconf, automake) and will need to run either ./autogen.sh or ./bootstrap.sh to produce the configure file.

The difference between autogen.sh and bootstrap.sh is that the former invokes configure with a default set of options, and will therefore generate a Makefile, whereas the latter does not invoke configure at all. If using autogen.sh, note that you can also append options, that will be passed as is to configure.

source: https://github.com/libusb/libusb/blob/master/README.git


Remember always that Autoconf is a code generator. It builds a shell script from the input file you present to it, using a custom configuration of the m4 macro processor, a built-in macro library, and any additional macros provided to it. Many of these macros emit shell code that causes shell variables to be defined when the resulting configure script runs. These variables belong to configure; they are just text to Autoconf itself. (Generally. There are, in fact, one or two gotchas in this area.)

Different variables are set and/or modified by shell code produced by different macros. For example, AC_INIT emits code that defines $PACKAGE_VERSION. I think it's also responsible for $VERSION, but I don't find that documented.

On the other hand, some variables take their initial values from the environment in which configure is run. $LIBS is one of these. In the (usual) event that it is not set in the environment, it follows from ordinary shell behavior that the initial value is effectively empty. This particular variable is updated by code generated by the AC_CHECK_LIB and AC_SEARCH_LIBS macros, and possibly others.

Coming back to the nature of Autoconf, perhaps your confusion arises from a failure to appreciate the distinction between a macro and a function. Autoconf expands macros recursively to produce a shell script. The semantics of the resulting script are whatever follows from the resulting code. Autoconf macros do not provide any scoping for for shell variables that appear in the resulting script.

source: https://stackoverflow.com/questions/46752029/from-where-are-variables-in-configure-ac-substituted


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment