自已做的第一个autoconf程序(不断完善中)
生活随笔
收集整理的這篇文章主要介紹了
自已做的第一个autoconf程序(不断完善中)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
1、先寫個簡單的main函數,并按如下目錄結構存放:
??? timesync--
??? ??? |--conf
??? ??? |--include
??? ??? |--lib
??? ??? |--src
2、在最上層目錄下,執行autoscan,生成configure.scan,并改名為configure.in,并進行編輯:
# -*- Autoconf -*- # Process this file with autoconf to produce a configure script.AC_PREREQ(2.59) AC_INIT(timesync, 1.0.0, wuhonghai@ccit.com.cn) AM_INIT_AUTOMAKE(timessync,1.0.0)AC_CONFIG_SRCDIR([src/timesync.c]) AC_CONFIG_HEADER(config.h)# Checks for programs. AC_PROG_CXX AC_PROG_CC# Checks for libraries.# Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_CHECK_HEADERS([arpa/inet.h fcntl.h memory.h netdb.h netinet/in.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])# Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM# Checks for library functions. AC_FUNC_CLOSEDIR_VOID AC_FUNC_FORK AC_FUNC_LSTAT AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK AC_TYPE_SIGNAL AC_FUNC_STAT AC_FUNC_STRFTIME AC_FUNC_VPRINTF AC_CHECK_FUNCS([bzero dup2 gethostname inet_ntoa memmove memset socket strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strstr]) AC_OUTPUT([Makefilesrc/Makefile])3、執行autoheader,生成config.h.in
4、執行aclocal、autoconf
5、在timesync目錄下編輯Makefile.am文件,如下:
AUTOMAKE_OPTIONS = foreignSUBDIRS=src CURRENTPATH=$(shell /bin/pwd) INCLUDES=-I$(CURRENTPATH)/include export INCLUDES6、在src目錄下編輯Makefile.am文件,如下:
AUTOMAKE_OPTIONS = foreign bin_PROGRAMS=timesync timesync_SOURCE=timesync.c libhttpd.c7、回到timesync目錄,執行automake -a,或者automake --add-missing,即可生成configure腳本。
8、可以執行./configure && make 進行編譯驗證。
轉載于:https://my.oschina.net/SmileWolf/blog/41880
總結
以上是生活随笔為你收集整理的自已做的第一个autoconf程序(不断完善中)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MFC和Win32之三___CGdiOb
- 下一篇: linux视频教程之vsftp_B