1.建立如下目錄:
libmessage
├── examples/
│ ├── Makefile.am
│ ├── test.c
├── include/
│ └── zk_message.h
├── _install/
├── m4/
├── Makefile.am
└── src
├── Makefile.am
└── zk_message.c
src 爲庫資源,include 爲頭文件 examples爲測試程序
2.0 建立Makefile.am
ACLOCAL_AMFLAGS=-I m4
SUBDIRS=src examples
2.1在src建立Makefile.am
AUTOMAKE_OPTIONS=foreign
lib_LTLIBRARIES = libmessage.la
libmessage_la_SOURCES=zk_message.c
libmessage_la_CPPFLAGS=-I ../include
include_HEADERS=../include/zk_message.h
libmessage_la_LIBADD= -lpthread
2.2在examples建立Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS= test
test_SOURCES=test.c
test_CPPFLAGS=-I ../include/
test_LDADD=-L../src/.libs/ -lmessage
3.使用autoscan生成configure.scan文件,將其重命名爲configure.ac
vi打開configure.ac
將:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([src/zk_message.c])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lmessage':
AC_CHECK_LIB([message], [main])
# FIXME: Replace `main' with a function in `-lpthread':
AC_CHECK_LIB([pthread], [main])
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset])
AC_CONFIG_FILES([Makefile
examples/Makefile
src/Makefile])
AC_OUTPUT
改爲:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(libmessage, 1.0, [email protected])
AC_CONFIG_SRCDIR([src/zk_message.c])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
AM_INIT_AUTOMAKE
AM_PROG_AR
LT_INIT
AC_CONFIG_MACRO_DIR([m4])
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lmessage':
AC_CHECK_LIB([message], [main])
# FIXME: Replace `main' with a function in `-lpthread':
AC_CHECK_LIB([pthread], [main])
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset])
AC_CONFIG_FILES([Makefile
examples/Makefile
src/Makefile])
AC_OUTPUT
5.touch NEWS README AUTHORS ChangeLog
6、 使用libtoolize -f -c、aclocal、autoreconf --install
7.創建安裝目錄 _install
mkdir _install
9生成Makefile
./configure --host=aarch64-himix100-linux --prefix=$(pwd)/_install
10.make;make install