【发布时间】:2019-10-12 23:53:10
【问题描述】:
我的工作目录如下树所示:
./
|--HelloWorld/
|--|--main.cpp
|--|--Dog/
|--|--|--Dog.h
|--|--|--Dog.cpp
|--Pet/
|--|--Pet.h
|--|--Pet.cpp
|--build/
main.cpp 包括dog.h 和pet.h。 Dog 是 Pet 的继承类,所以Dog.h 也包含Pet.h。我知道这是一种组织代码的有线方式,但我只是好奇 如何为每个子目录创建 makefile.am 文件,以便 autotool 可以在构建目录中构建项目。
请注意,我想要一些额外的功能:
- 是否可以在
build目录而不是build/HelloWorld/目录中构建hello.exe?为此,我是否必须将bin_PROGRAMS放在./Makefile.am - 我不想将 Pet 构建为库,我想知道是否有一种方法可以告诉 automake 在不同位置查找源代码。
- 我知道使用非递归生成文件会更容易。但我只想学习如何为多个目录创建递归 makefile。
我试过的是:
configure.ac
AC_PREREQ([2.69])
AC_INIT([Hello], [1.0], [qub@oregonstate.edu])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_SRCDIR([HelloWorld/main.cpp])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
#AC_PROG_CPP
AC_CONFIG_FILES([Makefile
HelloWorld/Makefile
Pet/Makefile
HelloWorld/Dog/Makefile])
AC_OUTPUT
Makefile.am
SUBDIRS = HelloWorld Pet
HelloWorld/Makefile.am
AM_CPPFLAGS=-I$(srcdir)/../Pet -I$(srcdir)/Dog
SUBDIRS = Dog
bin_PROGRAMS=hello
hello_SOURCES = main.cpp
宠物/Makefile.am
hello_SOURCES = Pet.h Pet.cpp
HelloWorld/Dog/Makefile.am
AM_CPPFLAGS=-I$(srcdir)/../../Pet
hello_SOURCES = Dog.h Dog.cpp
我刚开始学习 automake 的东西,我知道这些代码根本不起作用。
谁能帮我解决它们?谢谢。
【问题讨论】:
标签: linux autotools autoconf automake