$ lf -R
Makefile.am configure.ac libmym/
./libmym:
Makefile.am mym.cpp mym.h
$ cat Makefile.am
AUTOMAKE_OPTIONS = foreign
SUBDIRS = libmym
$ cat configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT(libmym, 1.0, mymtom@mymtom.cn)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([libmym/mym.cpp])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CXX
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
libmym/Makefile])
AC_OUTPUT
$ cat libmym/Makefile.am
AUTOMAKE_OPTIONS = foreign
lib_LTLIBRARIES = libmym.la
libmym_la_SOURCES = mym.cpp
$ cat libmym/mym.cpp
#include
using namespace std;
#include "mym.h"
void
mym_hello(void)
{
cout << "mym_hello(): Hello, World!" << endl;
}
$ cat libmym/mym.h
#ifndef MYM_H
#define MYM_H
#ifdef __cplusplus
extern "C" {
#endif
void mym_hello(void);
#ifdef __cplusplus
}
#endif
#endif
$ aclocal
$ libtoolize -c -f
$ autoheader
$ autoconf
$ automake --add-missing
configure.ac:5: installing `./missing'
configure.ac:5: installing `./install-sh'
libmym/Makefile.am: installing `./depcomp'
$ ./configure --prefix=/usr/home/mymtom/local
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
......
......
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... freebsd8.0 ld.so
checking how to hardcode library paths into programs... immediate
appending configuration tag "F77" to libtool
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libmym/Makefile
config.status: creating config.h
config.status: executing depfiles commands
$ gmake
gmake all-recursive
gmake[1]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0'
Making all in libmym
gmake[2]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
/usr/local/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT mym.lo -MD -MP -MF .deps/mym.Tpo -c -o mym.lo mym.cpp
mkdir .libs
g++ -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT mym.lo -MD -MP -MF .deps/mym.Tpo -c mym.cpp -fPIC -DPIC -o .libs/mym.o
g++ -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT mym.lo -MD -MP -MF .deps/mym.Tpo -c mym.cpp -o mym.o >/dev/null 2>&1
mv -f .deps/mym.Tpo .deps/mym.Plo
/usr/local/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -o libmym.la -rpath /usr/home/mymtom/local/lib mym.lo
g++ -shared -nostdlib /usr/lib/crti.o /usr/lib/crtbeginS.o .libs/mym.o -L/usr/lib -lstdc++ -lm -lc -lgcc_s /usr/lib/crtendS.o /usr/lib/crtn.o -Wl,-soname -Wl,libmym.so.0 -o .libs/libmym.so.0
(cd .libs && rm -f libmym.so && ln -s libmym.so.0 libmym.so)
(cd .libs && rm -f libmym.so && ln -s libmym.so.0 libmym.so)
ar cru .libs/libmym.a mym.o
ranlib .libs/libmym.a
creating libmym.la
(cd .libs && rm -f libmym.la && ln -s ../libmym.la libmym.la)
gmake[2]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
gmake[2]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0'
gmake[2]: Nothing to be done for `all-am'.
gmake[2]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0'
gmake[1]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0'
$ gmake install
Making install in libmym
gmake[1]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
gmake[2]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
test -z "/usr/home/mymtom/local/lib" || .././install-sh -c -d "/usr/home/mymtom/local/lib"
/usr/local/bin/bash ../libtool --mode=install /usr/bin/install -c 'libmym.la' '/usr/home/mymtom/local/lib/libmym.la'
/usr/bin/install -c .libs/libmym.so.0 /usr/home/mymtom/local/lib/libmym.so.0
(cd /usr/home/mymtom/local/lib && { ln -s -f libmym.so.0 libmym.so || { rm -f libmym.so && ln -s libmym.so.0 libmym.so; }; })
(cd /usr/home/mymtom/local/lib && { ln -s -f libmym.so.0 libmym.so || { rm -f libmym.so && ln -s libmym.so.0 libmym.so; }; })
/usr/bin/install -c .libs/libmym.lai /usr/home/mymtom/local/lib/libmym.la
/usr/bin/install -c .libs/libmym.a /usr/home/mymtom/local/lib/libmym.a
chmod 644 /usr/home/mymtom/local/lib/libmym.a
ranlib /usr/home/mymtom/local/lib/libmym.a
----------------------------------------------------------------------
Libraries have been installed in:
/usr/home/mymtom/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
gmake[2]: Nothing to be done for `install-data-am'.
gmake[2]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
gmake[1]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
gmake[1]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0'
gmake[2]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0'
gmake[2]: Nothing to be done for `install-exec-am'.
gmake[2]: Nothing to be done for `install-data-am'.
gmake[2]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0'
gmake[1]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0'
$ gmake dist-bzip2
{ test ! -d libmym-1.0 || { find libmym-1.0 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr libmym-1.0; }; }
test -d libmym-1.0 || mkdir libmym-1.0
list='libmym'; for subdir in $list; do \
if test "$subdir" = .; then :; else \
test -d "libmym-1.0/$subdir" \
|| ./install-sh -c -d "libmym-1.0/$subdir" \
|| exit 1; \
distdir=`CDPATH="${ZSH_VERSION+.}:" && cd libmym-1.0 && pwd`; \
top_distdir=`CDPATH="${ZSH_VERSION+.}:" && cd libmym-1.0 && pwd`; \
(cd $subdir && \
gmake \
top_distdir="$top_distdir" \
distdir="$distdir/$subdir" \
am__remove_distdir=: \
am__skip_length_check=: \
distdir) \
|| exit 1; \
fi; \
done
gmake[1]: Entering directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
gmake[1]: Leaving directory `/usr/home/mymtom/src/play/automake/hello-1.0/libmym'
find libmym-1.0 -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec /usr/local/bin/bash /usr/home/mymtom/src/play/automake/hello-1.0/install-sh -c -m a+r {} {} \; \
|| chmod -R a+r libmym-1.0
tardir=libmym-1.0 && /usr/local/bin/bash /usr/home/mymtom/src/play/automake/hello-1.0/missing --run tar chof - "$tardir" | bzip2 -9 -c >libmym-1.0.tar.bz2
{ test ! -d libmym-1.0 || { find libmym-1.0 -type d ! -perm -200 -exec chmod u+w {} ';' && rm -fr libmym-1.0; }; }
$