* autoconf를 설치
* automake를 설치
* libtool* 를 설치
autoconf http://www.gnu.org/software/autoconf/manual/index.html
automake http://www.gnu.org/software/automake/manual/index.html
libtool http://www.gnu.org/software/libtool/
tutorial http://mij.oltrelinux.com/devel/autoconf-automake/
AC_INIT([프로젝트명],[버전],[이메일],[패키지명])
PACKAGE=패키지명
AC_PREREQ(2.50) /// 요구되는 autoconf 버전이 최소
AC_COPYRIGHT([Copyright 2009-2012 jchern])
AC_CONFIG_AUX_DIR([build]) ///autotools가 필요한 파일이 저장될 디렉토리
AC_CANONICAL_TARGET /// 표준 설치방식을 채용하겠다는 명시적 선언
AM_INIT_AUTOMAKE[(foreign]) /// auto make 사용시에만
AC_CONFIG_HEADER=([include/auto_config.h]) /// 프로젝트 공통적으로 사용하는 것들을 템플릿으로 만들어 놓음
#AC_PREFIX_DEFAULT(/daum/program/time_hash)
AC_PREFIX_DEFAULT(`pwd`/install) /// 설치 기본 디렉토리
AH_TOP([#ifndef AUTO_CONFIG_H
#define AUTO_CONFIG_H 1
])
AH_BOTTOM([
#endif /*AUTO CONFIG H */
])
AH_VERBATIM([([1_NEAR_TOP__],[
/*example */
#undef TIME_HASH_HOME
])
AC_DEFINE(TIME_HASH_HOME,`pwd`)/// auto_config.h에 time_hash의 home 디렉토리를 define 문으로 만들기 위해
AC_MSG_RESULT("prefix is $prefix.")
#configure에서 파리마터를 받는 경우
#define 변수를 0또는 1로 변경할때
AC_ARG_WITH( 변수명,
[ --with-변수명 help 메세지를 기술 [default=no]], [
if test "$withval" != yes
then
AC_DEFINE(#define변수,0)
else
AC_DEFINE(#define변수,1)
fi
])
#파라미터를 변수에 할당할때
AC_ARG_WITH(변수명,
[ --with-변수명 help 메세지를 기술 [default=4]], [
AC_DEFINE_UNQUOTED(변수명_대문자,$withval)
])
# 경로를 지정하고 해당 경로에서 찾고자 하는 바이너리로 경로를 설정
AC_ARG_WITH(변수명,
AS_HELP_STRING([[--with-변수명=FILE]],[help메세지]),
[ 변수명="$withval" ],
[AC_PATH_PROGS(변수명,
[찾고자 하는 실행파일들 리스트],
[no], /// default값
[$PATH:/usr/sbin/:/usr/local/apache2/bin] /// 찾고자 하는 디렉토리 위치
)]
)
#HANL_LIB="-lhanl"
dnl ..............................................................................................................
dnl Checks for programs /// dns <- 최종 산출물에 포함되지 않는 주석 ( cf. #도 주석이지만 최종 결과물에 남는다 )
AC_PROG_CC /// 해당 프로그램이 있는 확인하는 명령어
AC_PROG_INSTALL
#AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_CHECK_HEADER( \//// 시스템에서 사용하는 헤더파일을 체크
string.h stdlib.h stdio.h sys/types.h sys/stat.hfcntl.h getopt.h \
)
AC_CHECK_FUNC )\ ///필요한 함수가 있는지 확인
getopt \
getopt_long
)
TH_RELEASE_DATE=`LANG=C date "%a %d %d %T %z %Y"`
AC_SUBST(PACKAGE) /// replace 함수 PACKAGE를 time_hash롤 바꾼다
AC_SUBST(TH_RELEASE_DATE)
AC_SUBST(LIBTOOL)
#AC_SUBST(HANL_LIB)
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_CPPFLAGS)
AC_SUBST(AM_LDFLAGS)
AC_SUBST(AM_LIBTOOLFLAGS)
AC_CONFIG_FILES([ /// AC_SUBST를 실행하기 위한 목표파일
Makefile /// Makefile.in을 AC_SUBST를 실행한후에 Makefile을 생성한다. 여기에는 타켓파일명을 기술한다.
src/Makefile
include/Makefile
])
AC_OUTPUT /// auto configure가 끝났음을 알리는 키워드
* automake(trunk)
SUBDIRS=include src /// Makefile( configure.ac에 AC_CONFIG_FILES에 기술됐던 디렉토리 전부
* automake(trunk/src)
bin_PROGRAMS = makehash searchhash showhash testhash /// build해야될 프로그램(실행파일) 리스트, bin_PROGRAMS에서 bin은 디렉토리 이름이다.
#check_PROGRAMS=testhash/// 여기에 프로그램이 있으면 install디렉토리에 복사되지 않는다.
lib_LTLIBRARIES
#target_유형 =
libhanlhash_la_SOURCE = \
finger_time_hash.c testhash.c \
makehash.c searchhash.c showhash.c
libhanlhash_la_LDFLAGS = -module -avoid-vesion -no-undefined /// default
#libhanlhash_la_LIBADD = 이 프로그램이 실행하기 위해서 필요한 라이브러리를 기술한다.
#libhanlhash_la_LIBADD = $(HANL_LIB)
makehash_SOURCES = makehash.c finger_time_hash.c
#makehash_LDADD = makehash를 컴파일 하기 위해서 필요한 라이브러리
makehash_CFLAS = -Wall
searchhash_SOURCE = searchhash.c finger_time_hash.c
showhash_SOURCES = showhash.c finger_time_hash.c
testhash_SOURCE = testhash.c finger_time_hash.c
* automake(trunk/include)
include_HEADERS = finger_time_hash.h /// install할 대상 header 파일
'C언어' 카테고리의 다른 글
[autotools] libtool link 옵션 (0) | 2013.04.01 |
---|---|
"configure: error: C++ preprocessor "/lib/cpp" fails sanity check" (0) | 2013.01.29 |
external MERGE SORT (0) | 2012.05.24 |
cpu 사용량 (0) | 2012.05.04 |
환경변수 PATH_INFO 활용 (0) | 2012.04.10 |