我正在尝试使用自制的AutoTools文件(configure
脚本(构建TerraGear。TerraGear分为几个子项目。对于每一个,我都创建了一组不同的configure.ac
和Makefile.am
文件,但它们几乎都是相同的。
考虑以下两个文件:
configure.ac
AC_PREREQ([2.69])
AC_INIT([TerraGear libterragear], [2.1.0], [])
AC_CONFIG_SRCDIR([airport.cxx])
AC_CONFIG_FILES([Makefile])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CXX
PKG_CHECK_MODULES([ZLIB], [zlib])
PKG_CHECK_MODULES([GDAL], [gdal])
AC_ARG_WITH([simgear-dir], [AS_HELP_STRING(
[--with-simgear-dir=prefix],
[installation prefix of SimGear])],
[
SIMGEAR_CPPFLAGS="-I${withval}/include"
SIMGEAR_LIBRARY="-L${withval}/lib"
]
)
AC_MSG_NOTICE([simgear cppflags : ${SIMGEAR_CPPFLAGS}])
AC_OUTPUT
Makefile.am
bin_PROGRAMS = genapts850
genapts850_SOURCES = airport.cxx
apt_math.cxx
closedpoly.cxx
debug.cxx
elevations.cxx
helipad.cxx
lights.cxx
linearfeature.cxx
linked_objects.cxx
main.cxx
object.cxx
output.cxx
parser.cxx
runway.cxx
rwy_simple.cxx
rwy_gen.cxx
scheduler.cxx
taxiway.cxx
genapts850_LDADD = -L$(top_srcdir)/../../Lib/terragear
$(SIMGEAR_LIBRARY)
-lSimGearCore
-lSimGearScene
-lterragear
$(ZLIB_LIBRARY)
$(GDAL_LIBRARY)
genapts850_CXXFLAGS = -I$(top_srcdir)/../../Lib
-I$(top_srcdir)/../../Lib/terragear
$(SIMGEAR_CPPFLAGS)
$(ZLIB_CFLAGS)
$(GDAL_CFLAGS)/gdal
我运行autoreconf:
autoreconf -vfi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
autoreconf: configure.ac: not using Autoheader
autoreconf: running: automake --add-missing --copy --force-missing
autoreconf: Leaving directory `.'
然后运行配置脚本:
./configure --with-simgear-dir=/path/to/simgear/installation/prefix
[...]
configure: simgear cppflags : -I/path/to/simgear/installation/prefix/include
[...]
然后我运行make:
make
g++ -DPACKAGE_NAME="TerraGear libterragear" -DPACKAGE_TARNAME="terragear-libterragear" -DPACKAGE_VERSION="2.1.0" -DPACKAGE_STRING="TerraGear libterragear 2.1.0" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="terragear-libterragear" -DVERSION="2.1.0" -I. -I./../../Lib -I./../../Lib/terragear -Ig++ -DPACKAGE_NAME="TerraGear libterragear" -DPACKAGE_TARNAME="terragear-libterragear" -DPACKAGE_VERSION="2.1.0" -DPACKAGE_STRING="TerraGear libterragear 2.1.0" -DPACKAGE_BUGREPORT="" -DPACKAGE_URL="" -DPACKAGE="terragear-libterragear" -DVERSION="2.1.0" -I. -I./../../Lib -I./../../Lib/terragear -I/path/to/simgear/installation/prefix/include/gdal -g -O2 -MT genapts850-airport.o -MD -MP -MF .deps/genapts850-airport.Tpo -c -o genapts850-airport.o `test -f 'airport.cxx' || echo './'`airport.cxx
airport.cxx:6:10: fatal error: simgear/compiler.h: Datei oder Verzeichnis nicht gefunden
6 | #include <simgear/compiler.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:471: genapts850-airport.o] Fehler 1
(simgear/compiler.h
位于/path/to/simgear/installation/prefix/include
内部(我做错了什么?我的头撞在屏幕上三个小时都没能弄清楚问题。请帮忙…
并非configure
中定义的所有shell变量都转发到输出文件。一般来说,您需要使用AC_SUBST()
来告诉Autoconf shell变量应该是输出变量:
AC_SUBST([SIMGEAR_CPPFLAGS])
AC_SUBST([SIMGEAR_LIBRARY])