我尝试使用libtool目标创建一个基于autotools的项目并进行测试。
除了VPATH(或make check
)中的make distcheck
外,一切正常。
以下是测试的Makefile.am
:
AM_CPPFLAGS = -I$(top_srcdir)/include
LDADD = $(top_srcdir)/lib/libboilerplate.la
check_PROGRAMS = test test_fail
test_SOURCES = test.c
test_fail_SOURCES = test_fail.c
TESTS = $(check_PROGRAMS)
XFAIL_TESTS = test_fail
以下是make check
的输出:
Making check in include
make[1]: Nothing to be done for `check'.
Making check in lib
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT boilerplate.lo -MD -MP -MF .deps/boilerplate.Tpo -c -o boilerplate.lo boilerplate.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT boilerplate.lo -MD -MP -MF .deps/boilerplate.Tpo -c boilerplate.c -fno-common -DPIC -o .libs/boilerplate.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT boilerplate.lo -MD -MP -MF .deps/boilerplate.Tpo -c boilerplate.c -o boilerplate.o >/dev/null 2>&1
mv -f .deps/boilerplate.Tpo .deps/boilerplate.Plo
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o libboilerplate.la -rpath /usr/local/lib boilerplate.lo
libtool: link: gcc -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libboilerplate.0.dylib .libs/boilerplate.o -O2 -install_name /usr/local/lib/libboilerplate.0.dylib -compatibility_version 1 -current_version 1.0 -Wl,-single_module
libtool: link: (cd ".libs" && rm -f "libboilerplate.dylib" && ln -s "libboilerplate.0.dylib" "libboilerplate.dylib")
libtool: link: ar cru .libs/libboilerplate.a boilerplate.o
libtool: link: ranlib .libs/libboilerplate.a
libtool: link: ( cd ".libs" && rm -f "libboilerplate.la" && ln -s "../libboilerplate.la" "libboilerplate.la" )
Making check in src
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o boilerplate main.o
libtool: link: gcc -g -O2 -o boilerplate main.o
Making check in tests
/Applications/Xcode.app/Contents/Developer/usr/bin/make test test_fail
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT test.o -MD -MP -MF .deps/test.Tpo -c -o test.o test.c
mv -f .deps/test.Tpo .deps/test.Po
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o test test.o ../lib/libboilerplate.la
libtool: link: gcc -g -O2 -o .libs/test test.o ../lib/.libs/libboilerplate.dylib
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT test_fail.o -MD -MP -MF .deps/test_fail.Tpo -c -o test_fail.o test_fail.c
mv -f .deps/test_fail.Tpo .deps/test_fail.Po
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o test_fail test_fail.o ../lib/libboilerplate.la
libtool: link: gcc -g -O2 -o .libs/test_fail test_fail.o ../lib/.libs/libboilerplate.dylib
/Applications/Xcode.app/Contents/Developer/usr/bin/make check-TESTS
PASS: test
XFAIL: test_fail
make[4]: Nothing to be done for `all'.
============================================================================
Testsuite summary for boilerplate 1.0
============================================================================
# TOTAL: 2
# PASS: 1
# SKIP: 0
# XFAIL: 1
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
VPATH中make check
的输出:
Making check in include
make[1]: Nothing to be done for `check'.
Making check in lib
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../lib -I.. -g -O2 -MT boilerplate.lo -MD -MP -MF .deps/boilerplate.Tpo -c -o boilerplate.lo ../../lib/boilerplate.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../lib -I.. -g -O2 -MT boilerplate.lo -MD -MP -MF .deps/boilerplate.Tpo -c ../../lib/boilerplate.c -fno-common -DPIC -o .libs/boilerplate.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../../lib -I.. -g -O2 -MT boilerplate.lo -MD -MP -MF .deps/boilerplate.Tpo -c ../../lib/boilerplate.c -o boilerplate.o >/dev/null 2>&1
mv -f .deps/boilerplate.Tpo .deps/boilerplate.Plo
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o libboilerplate.la -rpath /usr/local/lib boilerplate.lo
libtool: link: gcc -dynamiclib -Wl,-undefined -Wl,dynamic_lookup -o .libs/libboilerplate.0.dylib .libs/boilerplate.o -O2 -install_name /usr/local/lib/libboilerplate.0.dylib -compatibility_version 1 -current_version 1.0 -Wl,-single_module
libtool: link: (cd ".libs" && rm -f "libboilerplate.dylib" && ln -s "libboilerplate.0.dylib" "libboilerplate.dylib")
libtool: link: ar cru .libs/libboilerplate.a boilerplate.o
libtool: link: ranlib .libs/libboilerplate.a
libtool: link: ( cd ".libs" && rm -f "libboilerplate.la" && ln -s "../libboilerplate.la" "libboilerplate.la" )
Making check in src
gcc -DHAVE_CONFIG_H -I. -I../../src -I.. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o ../../src/main.c
mv -f .deps/main.Tpo .deps/main.Po
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o boilerplate main.o
libtool: link: gcc -g -O2 -o boilerplate main.o
Making check in tests
/Applications/Xcode.app/Contents/Developer/usr/bin/make test test_fail
gcc -DHAVE_CONFIG_H -I. -I../../tests -I.. -I../../include -g -O2 -MT test.o -MD -MP -MF .deps/test.Tpo -c -o test.o ../../tests/test.c
mv -f .deps/test.Tpo .deps/test.Po
make[2]: *** No rule to make target `../../lib/libboilerplate.la', needed by `test'. Stop.
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1
有谁知道为什么会这样?
答案 0 :(得分:2)
您写道:
LDADD = $(top_srcdir)/lib/libboilerplate.la
但是,这会将输出文件放入源树中 - 这是错误的。请改用$(top_builddir)
。