讀完autotools mythbuster之後,我試着用子目標對象寫一個非遞歸makefile的小示例,以使我的二進制文件位於我的源文件。automake的subdir-objects選項不起作用
這裏是我的小測試的組織:
/
autogen.sh
configure.ac
Makefile.am
src/
main.c
的autogen.sh:
#!/bin/sh
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
./configure "[email protected]"
的configure.ac:
AC_PREREQ([2.69])
AC_INIT([test], [0.0.1], [[email protected]])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
AM_INIT_AUTOMAKE([1.14 foreign subdir-objects])
AM_MAINTAINER_MODE([enable])
AC_OUTPUT(Makefile)
的Makefile.am:
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.h.in configure depcomp install-sh missing compile
bin_PROGRAMS=toto
toto_SOURCES=src/main.c
我編譯一切搭配:
./autogen.sh
make
我認爲二進制TOTO將與選項的src目錄已經創建子目錄對象但似乎這個選項沒有效果,並且toto二進制文件總是在根目錄中生成。
我也嘗試過在Makefile.am中傳遞這個選項,AUTOMAKE_OPTIONS = subdir-objects但是沒有成功。
化妝會自動尋找一個Makefile文件名爲或Makefile的或Makefile.mak或makefile.mak。它不會查找文件名稱Makefile.am。所以使用make -f Makefile.am – user3629249 2014-10-30 02:41:10
'make -f Makefile.am'將不工作。 'Makefile'由Automake和'configure'從'Makefile.am'中生成。 – ptomato 2014-10-30 05:49:02