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 INCLUDES
6、在src目录下编辑Makefile.am文件,如下:
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS=timesync
timesync_SOURCE=timesync.c libhttpd.c
7、回到timesync目录,执行automake -a,或者automake --add-missing,即可生成configure脚本。
8、可以执行./configure && make 进行编译验证。