8步运用automake开源发布自己的软件
2013-06-03 10:17
316 查看
都说自己写Makefile麻烦,而且在不同体系结构下为了移植性写出的Makefile完全没法读懂,所以好像目前大牛都开始用automake产生Makefile了,这里总结一下自己初步学习的经验。
首先,我只有一个文件,testtcmalloc.c
总共8步完成。
另外在output加上Makefile
[root@localhost test1]# ls
aclocal.m4 autom4te.cache autoscan.log configure configure.in testtcmalloc.c
step 6: 自己编写Makefile.am
首先,我只有一个文件,testtcmalloc.c
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <time.h> #include <sys/time.h> #include <pthread.h> #define MAX_COUNT 1000*1000 void fun(int i) { char* ptr = (char*)malloc(i); free(ptr); } void* fun_thread(void*) { int i = 0; int j = 1; while(i++<MAX_COUNT) { j ++; fun(j); if ( j>1024 ) j = 1; } } #define MSECOND 1000000 int main() { struct timeval tpstart,tpend; float timeuse; gettimeofday(&tpstart,NULL); pthread_t _deliver_t; pthread_create(&_deliver_t, NULL, fun_thread, NULL); int i = 0; int j = 1; while(i++<MAX_COUNT) { j ++; fun(i); if ( j > 1024 ) j = 1; //usleep(1); } gettimeofday(&tpend,NULL); timeuse=MSECOND*(tpend.tv_sec-tpstart.tv_sec)+tpend.tv_usec-tpstart.tv_usec; timeuse/=MSECOND; printf("Used Time:%f\n", timeuse); return 0; }
总共8步完成。
step1: autoscan
[root@localhost test1]# pwd /home/zhulele/fedora18/gadgit/src/test1 [root@localhost test1]# ll total 4 -rw-r--r-- 1 root root 1244 Jun 3 10:04 testtcmalloc.c [root@localhost test1]# autoscan [root@localhost test1]# ls autoscan.log configure.scan testtcmalloc.c [root@localhost test1]#
step 2:mv
[root@localhost test1]# mv configure.scan configure.in [root@localhost test1]# ls autoscan.log configure.in testtcmalloc.c
step 3:vim configure.in
添加两行,一个是AM_INIT_AUTOMAKE(PACKAGE,VERSION)另外在output加上Makefile
1 # -*- Autoconf -*- 2 # Process this file with autoconf to produce a configure script. 3 4 AC_PREREQ([2.69]) 5 AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS]) 6 AC_CONFIG_SRCDIR([testtcmalloc.c]) 7 AC_CONFIG_HEADERS([config.h]) 8 # I add something here!!! 9 AM_INIT_AUTOMAKE(testtcmalloc,1.0) 10 11 # Checks for programs. 12 AC_PROG_CC 13 14 # Checks for libraries. 15 16 # Checks for header files. 17 AC_CHECK_HEADERS([stdlib.h sys/time.h unistd.h]) 18 19 # Checks for typedefs, structures, and compiler characteristics. 20 21 # Checks for library functions. 22 AC_FUNC_MALLOC 23 AC_CHECK_FUNCS([gettimeofday]) 24 # I add "(Makefile)" 25 AC_OUTPUT(Makefile)
step 4: aclocal
[root@localhost test1]# vim configure.in [root@localhost test1]# aclocal [root@localhost test1]# ls aclocal.m4 autom4te.cache autoscan.log configure.in testtcmalloc.c
step 5: autoconf
[root@localhost test1]# autoconf[root@localhost test1]# ls
aclocal.m4 autom4te.cache autoscan.log configure configure.in testtcmalloc.c
step 6: 自己编写Makefile.am
1 bin_PROGRAMS = testtcmalloc 2 testtcmalloc_SOURCES = testtcmalloc.c 3 testtcmalloc_CFLAGS = -lpthread -ltcmalloc
step7: autoheader
step 8: automake --add-missing
相关文章推荐
- DIY:用开源软件搭建自己的物联网
- 如何发布自己的开源库到JCenter实现AS中可以以依赖的方式引入
- 发布一个免费开源软件-- PAD流程图绘制软件PADFlowChart
- 在Maven Central发布了自己的第一个开源项目
- 如何将自己写的开源库发布到 JitPack.io
- 利用开源软件提高自己的GIS编程能力
- 房地产行业软件ApartmentSales开源版发布
- 本文教你如何使用autoconf、automake等来制作一个以源代码形式(.tar.gz)发布的软件、并可在执行configure时使用自定义参数。
- 自由开源壁纸软件 Wallch 4.15 发布
- DarkTable 1.2 发布,开源 RAW 处理软件
- 开源软件绿色报时器2.0版发布
- 开源矢量绘图软件Inkscape 0.46 发布
- 发布自己的开源框架到CocoaPods
- 软件在吞噬世界,但是开源软件在吞噬自己
- 开源新闻速递:天文软件 Stellarium 0.15.0 发布
- Linux下automake软件编译与发布快速入门 (1)
- 如何发布自己的开源框架到CocoaPods【转】
- [软件资讯]百度发布富文本开源编辑器UEditor