Automake错误构建库 - Phantom文件

时间:2013-12-14 19:22:29

标签: autotools automake libtool

我将autotools功能添加到个人库中,但是我遇到了一些问题。我确切地认为autotools对我来说是全新的。

.
|-- Makefile.am
|-- configure.ac
`-- socket++
    |-- Makefile.am
    |-- base_socket.cpp
    |-- base_socket.hpp
    |-- client.cpp
    |-- client.hpp
    |-- config.h
    |-- config.h.in
    |-- refcount++.hpp
    |-- server.cpp
    |-- server.hpp
    |-- server.imp.hpp
    `-- types
        |-- Makefile.am
        |-- simple_socket.cpp
        |-- simple_socket.hpp
        |-- simple_socket_stop.cpp
        |-- simple_socket_stop.hpp
        |-- text_buffered.hpp
        `-- text_buffered.imp.hpp

以下是configure.ac

AC_INIT([socket++], [1.2], [xcodexif@xif.fr], [socket++], [http://dev.xif.fr/socketxx])
AM_INIT_AUTOMAKE([foreign -Wall])
AC_CONFIG_HEADERS([socket++/config.h])
AC_CONFIG_SRCDIR([socket++/base_socket.cpp])
AC_CONFIG_FILES([Makefile socket++/Makefile socket++/types/Makefile])
AC_CONFIG_MACRO_DIR([m4])

# Distribute additional compiler and linker flags
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])

# Checks for compilers
AC_PROG_CXX
AC_PROG_CC
AX_CXX_COMPILE_STDCXX_11

# Libtool
LT_INIT
LT_LANG([C++])

# Checks for header files
AC_CHECK_HEADERS([arpa/inet.h inttypes.h netdb.h netinet/in.h stddef.h sys/ioctl.h sys/socket.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T

# Checks for library functions
AC_FUNC_ERROR_AT_LINE
AC_CHECK_FUNCS([gethostbyname inet_ntoa select socket strerror])

AC_OUTPUT

以下是socket++/Makefile.am

AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
AM_CXXFLAGS = -I$(top_srcdir)/socket++ @AM_CXXFLAGS@
ACLOCAL_AMFLAGS = -I m4

SUBDIRS = types

lib_LTLIBRARIES = libsocket++.la
library_includedir=$(includedir)/socket++
library_include_HEADERS = refcount++.hpp base_socket.hpp client.hpp server.imp.hpp server.hpp
libsocket++_la_SOURCES = base_socket.cpp client.cpp server.cpp
socket++_libincludedir = $(libdir)/socket++/include
nodist_socket++_libinclude_HEADERS = config.h
libsocket++_la_LIBADD = types/libsocket++types.a

最后socket++/types/Makefile.am

noinst_lib_LTLIBRARIES = libsocket++types.la
library_includedir=$(includedir)/socket++/types
library_include_HEADERS = simple_socket_stop.hpp simple_socket.hpp text_buffered.imp.hpp text_buffered.hpp
libsocket++types_la_SOURCES = simple_socket_stop.cpp simple_socket.cpp

./configure一切都很好 但是当我make时,我有这个错误:

make[3]: Entering directory '/root/socket++/socket++/types'
make[3]: *** No rule to make target 'libsocket++types.c', needed by 'libsocket++types.lo'.  Stop.

这很奇怪,因为libsocket++types.c

中从未定义libsocket++types_la_SOURCES

我搜索了一会儿,但没有发现像这样的幻影文件。 在此先感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

使用<prefix>_原色只有几个问题:

lib_LTLIBRARIES = libsocket++.la会产生derived variable name libsocket__

libsocket___includedir = $(includedir)/socket++
libsocket___include_HEADERS = ...
libsocket___la_SOURCES = ...

您也可以将头文件放在_SOURCES列表中。即,如果标题被更改,make将看到必须重新编译库或其他依赖项。

您称之为“幻像”目标,通常称为convenience library,其中:libsocket++types.la转换为libsocket__types_前缀。父Makefile.am应添加AM_CPPFLAGS的包含路径。由于subdirs将首先下降,您可以添加便利库:

libsocket___la_LIBADD = types/libsocket++types.la

此外,noinst_LTLIBRARIES 不是 noinst_lib_LTLIBRARIES