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 headers
AC_HEADER_STDC
dnl check for other standard c headers
AC_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 lib
AC_PROG_RANLIB
AM_PROG_CC_C_O
AM_PROG_AR
#AC_PROG_LIBTOOL
AC_CONFIG_MACRO_DIR([m4])
AC_CHECK_PROGS([TAR], [tar gtar], [:])
if test "$TAR" = :; then
AC_MSG_ERROR([tar is needed in this package.])
fi
#COMMON_WITH_READLINE
#COMMON_VAR_SYS_ERRLIST
#COMMON_VAR_SYS_SIGLIST
TAR=$(whereis tar)
AC_SUBST([TAR])
###########################################
AM_MAINTAINER_MODE #../configure --enable-maintainer-mode
AC_SYS_LARGEFILE # ../configure --enable-largefile
########################################
AC_CONFIG_FILES([Makefile
src/Makefile
src/common/Makefile
src/container/Makefile
testsuite/Makefile
testsuite/common_test/Makefile
])
AC_OUTPUT
2. Makefile.am
SUBDIRS = src testsuite
EXTRA_DIST = bootstrap autogen.sh
3. src/Makefile.am
SUBDIRS = common container
bin_PROGRAMS = common_test
common_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.in
bin_PROGRAMS = common
common_SOURCES = common.h xmalloc.h xmalloc.c xstring.h xstring.c common_test.c
lib_LIBRARIES = libcommon.a
libcommon_a_SOURCES = common.h xmalloc.h xmalloc.c xstring.h xstring.c
include_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 = icontainer
icontainer_SOURCES = container.h container.c container_test.c
icontainer_CPPFLAGS = -I$(top_srcdir)/src/common
6. testsuite/Makefile.am
SUBDIRS = common_test
7. testsuite/common_test/Makefile.am
MAINTAINERCLEANFILES = Makefile.in
bin_PROGRAMS = test1
test1_SOURCES = xstring_test1.c
test1_LDADD = $(top_builddir)/src/common/libcommon.a
test1_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