自动生成Makefile (转)

Posted on 2008-06-27 12:33 T.S Liu 阅读(929) 评论(0)  编辑 收藏 引用 所属分类: makefile
在test目录上新建src和include目录,源文件中src目录下,头文件在include目录。在src目录新建Makefile.am文件,编写Makefile.am,如下:
AUTOMAKE_OPTIONS = foreign
INCLUDES= -I../include
bin_PROGRAMS = main
radio_SOURCES = main.c \
keyboard.c \
lcd.c \
setup.c \
storage.c
 
保存退出。
返回test目录,再新建Makefile.am文件,编写Makefile.am,如下:
SUBDIRS = src
保存退出。
 
执行 
autoscan
生成configure.scan文件 ,如:
autoscan.log  configure.scan  include  Makefile.am  src
编辑configure.scan文件,如:
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(radio,1.0.0,[wenzel@163.com])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/make.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
#AC_PROG_RANLIB
# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h termios.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_FORK
AC_PROG_GCC_TRADITIONAL
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([bzero memset strcasecmp strchr strrchr])
#AC_CONFIG_FILES([Makefile
#                 src/Makefile])
AC_OUTPUT(Makefile src/Makefile)
 
保存退出,改名为:mv configure.scan configure.in
执行:
touch NEWS README AUTHORS ChangeLog
再执行:
autoreconf -fvi
 
最后,可以执行:
./configure
配置为ARM平台:
 ./configure --host=arm --target=arm CC=arm-linux-gcc
就可以编译了,如:
make 
make install
make clean
make distclean

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理