No.1: autoconf automake

来源:互联网 发布:安卓app 知乎 编辑:程序博客网 时间:2024/06/05 01:08

1. configure.ac

#                                               -*- Autoconf -*-# Process this file with autoconf to produce a configure script.AC_PREREQ([2.68])AC_INIT([zz-test], [1.0], [amao.chj@gmail.com])AC_CONFIG_SRCDIR([src/common_test.c])AC_CONFIG_HEADERS([config.h])AC_CONFIG_AUX_DIR([config])AM_INIT_AUTOMAKE(foreign 1.1 -Wall -Werror)# Checks for programs.AC_PROG_CC# Checks for libraries.#if found, then LIBS="-lpthread $LIBS" and #define HAVE_LIBPTHREAD 1 in config.h#(Automake uses $LIBS for linking everything.)AC_CHECK_LIB([pthread], [pthread_rwlock_init]) # Checks for header files.dnl check for ANSI C headersAC_HEADER_STDCdnl check for other standard c headersAC_CHECK_HEADERS([inttypes.h sys/types.h stdint.h stdlib.h string.h strings.h unistd.h stdio.h stddef.h fcntl.h], [], AC_MSG_ERROR(some system header not found, please check.))# Checks for typedefs, structures, and compiler characteristics.AC_TYPE_SIZE_T# Checks for library functions.AC_FUNC_MALLOC#########################################if we will create libAC_PROG_RANLIBAM_PROG_CC_C_OAM_PROG_AR#AC_PROG_LIBTOOLAC_CONFIG_MACRO_DIR([m4]) AC_CHECK_PROGS([TAR], [tar gtar], [:])if test "$TAR" = :; thenAC_MSG_ERROR([tar is needed in this package.])fi#COMMON_WITH_READLINE#COMMON_VAR_SYS_ERRLIST#COMMON_VAR_SYS_SIGLISTTAR=$(whereis tar)AC_SUBST([TAR])###########################################AM_MAINTAINER_MODE #../configure --enable-maintainer-modeAC_SYS_LARGEFILE # ../configure --enable-largefile########################################AC_CONFIG_FILES([Makefilesrc/Makefilesrc/common/Makefilesrc/container/Makefiletestsuite/Makefiletestsuite/common_test/Makefile])AC_OUTPUT

2. Makefile.am

SUBDIRS = src testsuiteEXTRA_DIST = bootstrap autogen.sh

3. src/Makefile.am

SUBDIRS = common containerbin_PROGRAMS = common_testcommon_test_SOURCES = common/common.h common/xmalloc.h common/xstring.h \ common/xmalloc.c common/xstring.c common_test.c4. 

4. src/common/Makefile.am

MAINTAINERCLEANFILES = Makefile.inbin_PROGRAMS = commoncommon_SOURCES = common.h xmalloc.h xmalloc.c xstring.h xstring.c common_test.clib_LIBRARIES = libcommon.alibcommon_a_SOURCES = common.h xmalloc.h xmalloc.c xstring.h xstring.cinclude_HEADERS = common.h xmalloc.h xstring.h###############################################libraries will be installed in $(libdir).##if the lib will not install, then use: noinst_LIBRARIES =##Public headers will be installed in $(includedir)##Private headers are not installed, like ordinary source files.#############################################

5. src/container/Makefile.am

bin_PROGRAMS = icontainericontainer_SOURCES = container.h container.c container_test.cicontainer_CPPFLAGS = -I$(top_srcdir)/src/common

6. testsuite/Makefile.am

SUBDIRS = common_test

7. testsuite/common_test/Makefile.am

MAINTAINERCLEANFILES = Makefile.inbin_PROGRAMS = test1test1_SOURCES = xstring_test1.ctest1_LDADD= $(top_builddir)/src/common/libcommon.atest1_CPPFLAGS = -I$(top_srcdir)/src/common##LDADD = $(top_builddir)/src/common/libcommon.a##AM_CPPFLAGS = -I$(top_srcdir)/src/common##'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')##LDADD = ../../src/common/libcommon.a##INCLUDES = -I../../../src/common