본문 바로가기
【🧰 SW Info & Tips】/🦿 Automake & Autoconf

[automake] libtool

반응형
▣ 원문 출처: http://funkylocker.tistory.com/entry/automake-libtool

 
GNU libtool은 라이브러리 제공 스크립트로 유저에게 새로운 라이브러리 빌딩을 손쉽게 제공합니다. 본 글에서는 간단한 예제만을 기반으로 설명 드리니 자세한 내용은 GNU Libtool (http://www.gnu.org/software/libtool/)의 Document를 통해 확인할 수 있습니다.

소스 트리에서 유저가 생성해 주어야 파일은 configure.ac 와 각 디렉토리의 Makefile.am 입니다.

[소스 트리]

 .
|-- Makefile.am
|-- Makefile.in
|-- aclocal.m4
|-- autom4te.cache
|   |-- output.0
|   |-- output.1
|   |-- requests
|   |-- traces.0
|   `-- traces.1
|-- autoscan.log
|-- config.guess
|-- config.h.in
|-- config.sub
|-- configure
|-- configure.ac
|-- depcomp
|-- include
|-- install-sh
|-- ltmain.sh
|-- missing
`-- src
    |-- Makefile.am
    |-- Makefile.in
    |-- minus
    |   |-- Makefile.am
    |   |-- Makefile.in
    |   |-- minus.c
    `-- plus
        |-- Makefile.am
        |-- Makefile.in
        `-- plus.c

5 directories, 28 files



그럼 각 파일 내용을 살펴 보겠습니다. (설명은 주석으로 대신)

[Makefile.am]
SUBDIRS = src
dist_doc_DATA = README


[src/Makefile.am]

SUBDIRS = plus minus

# llibtool 라이브러리
lib_LTLIBRARIES = libsum.la

# 하나의 소스가 한 디렉토리에 있다면 아래에 나열
libsum_la_SOURCES =

# 두개 이상의 라이브러리를 합칠 경우
libsum_la_LIBADD =  plus/libplus.la \
                               minus/libminus.la


[src/plus/Makefile.am]

AM_CFLAGS = -I../ -I../../include
AM_LDFLAGS =

# 설치되지 않는 라이브러리 (not install)
noinst_LTLIBRARIES = libplus.la

libplus_la_SOURCES = $(SOURCES_libplus)

# 라이브러리 소스
SOURCES_libplus =    plus.c




[src/minus/Makefile.am]

AM_CFLAGS = -I../ -I../../include
AM_LDFLAGS =

# 설치되지 않는 라이브러리 (not install)
noinst_LTLIBRARIES = libminus.la

# 설치되지 않는 라이브러리 (not install)
libminus_la_SOURCES = $(SOURCES_libminus)

SOURCES_libminus =    minus.c 



autoscan을 통해 configure.scan을 생성하고 다음과 libtool 매크로를 추가 합니다.

[configure.ac]

 #                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT([sum], [0.0.1], [BUG-REPORT-ADDRESS])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC
AC_PROG_LIBTOOL

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile
                 src/Makefile
                 src/minus/Makefile
                 src/plus/Makefile])
AC_OUTPUT



마지막으로 configure 파일과 Makefile.in, Makefile을 생성합니다.

$ autoreconf --install
$ ./configure


반응형

'【🧰 SW Info & Tips】 > 🦿 Automake & Autoconf' 카테고리의 다른 글

GNU 빌드시스템 (2)  (0) 2020.10.24
GNU 빌드시스템 (1)  (0) 2020.10.24
[autotools] Manual  (0) 2011.10.07
[autotools] automake, autoconf 사용법  (0) 2011.10.07
[autoconf] Macro 정리 (Canonicalizing)  (0) 2011.10.07