No.1: autoconf automake

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


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值