linux自动生成makefile,自动生成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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值