I'm currently grappling with understanding the autotools. I'm almost there, but I'm a bit stumped by the behavior of automake when it comes to the AM_CFLAGS
and AM_LDLIBS
macros.
Below is my very short Makefile.am
1 bin_PROGRAMS = sqlmigrate
2 sqlmigrate_SOURCES = sqlmigrate.c db.c
3
4 AM_CFLAGS=-g -Wall -D_LARGEFILE64_SOURCE=1 -I/usr/local/apr/include/apr-1
5 AM_LDLIBS=-lsqlite3 -lapr-1
My understanding is that AM_CFLAGS
and AM_LDLIBS
are used when no corresponding argument is passed to ./configure
, but that they yield to such arguments when given.
After creating Makefile.in and running configure, however, make all
is clearly not using the specified CFLAGS
and LDLIBS
even though I specified them.
Even stranger (to me anyway), is that my configure script can cause those libraries to be included if I happen to use the AC_CHECK_LIB
macro.
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.68])
5 AC_INIT([sqlmigrate], [1.0], [])
6 AM_INIT_AUTOMAKE(1.8)
7 AC_CONFIG_SRCDIR([sqlmigrate.c])
8
9 # Checks for programs.
10 AC_PROG_CC
11 AC_PROG_INSTALL
12
13 # Checks for libraries.
14 # AC_CHECK_LIB([sqlite3], [sqlite3_open])
15 # AC_CHECK_LIB([apr-1], [apr_pool_initialize])
16
17 # Checks for header files.
18 AC_CHECK_HEADERS([stdlib.h string.h unistd.h])
19
20 # Checks for typedefs, structures, and compiler characteristics.
21
22 # Checks for library functions.
23
24 AC_CONFIG_HEADER(config.h)
25 AC_CONFIG_FILES([Makefile])
26 AC_OUTPUT
So with the AC_CHECK_LIB
lines commented out, gcc
is invoked without linking the libraries.
I feel like I'm hanging on by a thread with autotools here. Feel free to explode my reality and show me the error of my ways.
Thanks for your time!
-I/usr/local/apr/include/apr-1
do not belong inAM_CFLAGS
orAM_CPPFLAGS
. That path is specific to the machine on which the user builds the package, and therefore have no place in any of the autotool metafiles. – William Pursell