configure的制作
来源:互联网 发布:a股b股h股n股s股 知乎 编辑:程序博客网 时间:2024/05/16 12:11
前提:安装autoconf automake m4
用autotools制作Makefile 和configure文件。
制作一个最简单的helloworld程序:
现有目录test
mkdir src 建立src目录存放 源代码
在src下。
编辑hello.c文件
在src目录下建立Makefile.am文件 (src/Makefile.am)
保存退出
退到test目录
编辑Makefile.am文件 (Makefile.am)
SUBDIRS = src
退出保存
然后
执行
autoscan
生成configure.scan文件
按此编辑此文件
退出保存
将此文件更名 mv configure.scan configure.in
然后执行
touch NEWS README AUTHORS ChangeLog
然后执行
autoreconf -fvi
至此生成configure文件
执行configure文件
|- src 目录
|- hello.c 文件
|- include 目录
|- hello.h文件
|- lib 目录
|- test.c文件 此文件用来生成 libhello.a
在当前目录 编写Makefile.am
在include目录下 编写hello.h
在lib目录下编写test.c
在lib目录下编写Makefile.am
这里noinst_LIBRARIES 的意思是生成的静态库 ,不会被make install 安装
然后指定libhello.a的源文件test.c
在src目录下编写hello.c
在src目录下编写Makefile.am
首先指定头文件的位置 ../include
然后指定要生成执行文件 hello
然后指定源代码文件 hello.c
最后添加静态库的位置 ../lib/libhello.a
按照我首篇帖子的方式.
执行autoscan 生成configure.scan
修改该文件
按照首篇帖子修改.
然后不同之处
需要添加一行:AC_PROG_RANLIB
mv configure.scan configure.in
touch NEWS README AUTHORS ChangeLog
执行autoreconf -fvi
生成configure.执行configure生成Makefile..
用autotools制作Makefile 和configure文件。
制作一个最简单的helloworld程序:
现有目录test
mkdir src 建立src目录存放 源代码
在src下。
编辑hello.c文件
#include <stdio.h>
int main()
{
printf("hello world/n");
return 0;
}
int main()
{
printf("hello world/n");
return 0;
}
在src目录下建立Makefile.am文件 (src/Makefile.am)
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS = hello
hello_SOURCES = hello.c
hello_LDADD = -lpthread (只是测试,实际不需要连接该库)
bin_PROGRAMS = hello
hello_SOURCES = hello.c
hello_LDADD = -lpthread (只是测试,实际不需要连接该库)
保存退出
退到test目录
编辑Makefile.am文件 (Makefile.am)
SUBDIRS = src
退出保存
然后
执行
autoscan
生成configure.scan文件
按此编辑此文件
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hello,1.0, [miaoquan@nou.com.cn])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lpthread':
AC_CHECK_LIB([pthread], [main])
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
#AC_CONFIG_FILES([Makefile
# src/Makefile])
AC_OUTPUT(Makefile src/Makefile)
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hello,1.0, [miaoquan@nou.com.cn])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lpthread':
AC_CHECK_LIB([pthread], [main])
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
#AC_CONFIG_FILES([Makefile
# src/Makefile])
AC_OUTPUT(Makefile src/Makefile)
退出保存
将此文件更名 mv configure.scan configure.in
然后执行
touch NEWS README AUTHORS ChangeLog
然后执行
autoreconf -fvi
至此生成configure文件
执行configure文件
|- src 目录
|- hello.c 文件
|- include 目录
|- hello.h文件
|- lib 目录
|- test.c文件 此文件用来生成 libhello.a
在当前目录 编写Makefile.am
SUBDIRS = lib src
在include目录下 编写hello.h
extern void print(char *);
在lib目录下编写test.c
#include <stdio.h>
void print(char *msg)
{
printf("%s/n",msg);
}
void print(char *msg)
{
printf("%s/n",msg);
}
在lib目录下编写Makefile.am
noinst_LIBRARIES=libhello.a
libhello_a_SOURCES=test.c
libhello_a_SOURCES=test.c
这里noinst_LIBRARIES 的意思是生成的静态库 ,不会被make install 安装
然后指定libhello.a的源文件test.c
在src目录下编写hello.c
#include "hello.h"
int main()
{
print("haha"); //这里是静态库里的print函数
return 0;
}
int main()
{
print("haha"); //这里是静态库里的print函数
return 0;
}
在src目录下编写Makefile.am
INCLUDES= -I../include
bin_PROGRAMS=hello
hello_SOURCES=hello.c
hello_LDADD=../lib/libhello.a
bin_PROGRAMS=hello
hello_SOURCES=hello.c
hello_LDADD=../lib/libhello.a
首先指定头文件的位置 ../include
然后指定要生成执行文件 hello
然后指定源代码文件 hello.c
最后添加静态库的位置 ../lib/libhello.a
按照我首篇帖子的方式.
执行autoscan 生成configure.scan
修改该文件
按照首篇帖子修改.
然后不同之处
需要添加一行:AC_PROG_RANLIB
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hello,1.1,[miaoquan@nou.com.cn])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
AC_PROG_RANLIB
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
#AC_CONFIG_FILES([Makefile
# lib/Makefile
# src/Makefile])
AC_OUTPUT([Makefile
lib/Makefile
src/Makefile])
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hello,1.1,[miaoquan@nou.com.cn])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
AC_PROG_RANLIB
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
#AC_CONFIG_FILES([Makefile
# lib/Makefile
# src/Makefile])
AC_OUTPUT([Makefile
lib/Makefile
src/Makefile])
mv configure.scan configure.in
touch NEWS README AUTHORS ChangeLog
执行autoreconf -fvi
生成configure.执行configure生成Makefile..
总结一下就是先完成所有的源代码,然后编写Makefile.am 然后autoscan生成configure.scan把它修改成configure.in 然后 touch NEWS README AUTHORS ChangeLog最后 autoreconf -fvi就ok
转自:http://blog.csdn.net/hahapro/article/details/1614132
0 0
- configure的制作
- configure的制作
- configure的制作
- 用autotools制作Makefile 和configure文件。
- 使用autotools制作Makefile和configure文件
- 用autotools制作Makefile 和configure文件。
- 用autotools制作Makefile 和configure文件
- 用autotools制作Makefile 和configure文件
- linux 如何制作:./configure; make; make install
- configure参数的理解
- 梳理kernel的configure
- ./configure的问题
- RMAN的配置configure
- ubuntu configure的问题解决
- configure文件的生成
- configure.scan的修改
- configure.scan的修改
- ./configure 的配置。
- Ubuntu12.04从桌面进入终端Terminal的方式
- hihoCoder1051 - 补提交卡
- HDU 3078 倍增LCA+排序
- hdu 2586 lca离线tarjan
- Linux文件类型解析
- configure的制作
- 1.1 解压序列到多个变量
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第8章节--配送SP2013Apps 总结
- leetcode 虐我篇之(二十)Search Insert Position
- cocos2d_x_01_环境搭建
- Dinic+当前弧优化
- 1.2.从任意长度的迭代中解压元素
- 1.3.保留最后N个元素
- spring注入成员对象