我的目标是将所有目标文件构建在 .objs 目录而不是 Makefile 的根目录中,并将二进制文件(和库)复制到项目的bin/目录中。但我一直找不到任何资源来解释如何做到这一点。我该怎么做呢?
这是我的 configure.ac 和src/Makefile.am - 对于两个引用的共享库,我有类似的 Makefile.am 文件。它们编译,并在将它们复制到bin/目录后正常工作。我只是想自动化这个过程。
配置.ac
AC_PREREQ([2.63])
AC_INIT([gtkworkbook], [0.12], [j_bellone@users.sourceforge.net])
AC_CONFIG_SRCDIR([gtkworkbook/cell.c])
AM_INIT_AUTOMAKE([gtkworkbook], [0.12])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_LIBTOOL
AC_PROG_CC_C_O
AC_CHECK_LIB([pthread], [pthread_mutex_init], [], [
echo "pthread library is missing. pthread is required for this program"
exit -1])
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([gethostbyname memset socket])
AC_OUTPUT([Makefile
csv/Makefile
gtkworkbook/Makefile
src/Makefile])
src/Makefile.am
AUTOMAKE_OPTIONS= foreign
C_FLAGS= -I/usr/local/include -I/usr/include -I/usr/local/include/gtkextra-2.0 -I$(top_srcdir)/include `pkg-config gtk+-2.0 glib-2.0 --cflags`
L_FLAGS= -L/usr/local/lib -L/usr/lib -L$(top_srcdir)/lib `pkg-config gtk+-2.0 glib-2.0 --libs` -lgtkextra-x11-2.0
bin_PROGRAMS= gtkworkbook
gtkworkbook_SOURCES= application.c config.c main.c parse.c plugin.c
gtkworkbook_CFLAGS= -Wall -lgthread-2.0 -std=c99 $(C_FLAGS)
gtkworkbook_LFLAGS= -ldl $(L_FLAGS)
gtkworkbook_LDFLAGS= $(L_FLAGS)
gtkworkbook_LDADD= ../gtkworkbook/libgtkworkbook.la ../csv/libcsv.la
lib_LTLIBRARIES= realtime.la
realtime_la_SOURCES= realtime/CsvParser.cpp realtime/Network.cpp realtime/Packet.cpp realtime/plugin_main.cpp \
realtime/thread_main.cpp realtime/concurrent/Mutex.cpp realtime/concurrent/Semaphore.cpp \
realtime/concurrent/Thread.cpp realtime/concurrent/ThreadGroup.cpp realtime/concurrent/ThreadPool.cpp \
realtime/proactor/Dispatcher.cpp realtime/proactor/Event.cpp realtime/proactor/Proactor.cpp \
realtime/proactor/InputDispatcher.cpp realtime/proactor/Worker.cpp realtime/network/Tcp.cpp
realtime_la_CPPFLAGS= -Wall -Wno-write-strings $(C_FLAGS)
realtime_la_LFLAGS= -lgtkworkbook -lcsv $(L_FLAGS)
realtime_la_LDFLAGS= -module -export-dynamic
realtime_la_LIBADD= ../gtkworkbook/libgtkworkbook.la ../csv/libcsv.la
所以,我的问题是如何为每个 Makefile 的编译结果指定输出目录(我希望它们被复制到bin/,并且目标文件在每个项目的.obj中而不是在 Makefile 的根目录中.
感谢您迄今为止的帮助。这个网站是一个很好的资源,我从已经提供的链接中学到了很多东西。