configure.in 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. # -*- mode:Shell-script -*-
  2. AC_PREREQ(2.57)
  3. AC_INIT
  4. AC_CONFIG_SRCDIR([configure.in])
  5. AC_CONFIG_AUX_DIR(config)
  6. AC_CONFIG_MACRO_DIR([config])
  7. AM_CONFIG_HEADER(src/config.h)
  8. LOG4C_MAJOR_VERSION=1
  9. LOG4C_MINOR_VERSION=2
  10. LOG4C_MICRO_VERSION=4
  11. VERSION=$LOG4C_MAJOR_VERSION.$LOG4C_MINOR_VERSION.$LOG4C_MICRO_VERSION${SNAPSHOT:+.$SNAPSHOT}
  12. # +1 : ? : +1 == new interface that does not break old one
  13. # +1 : ? : 0 == new interface that breaks old one
  14. # ? : ? : 0 == no new interfaces, but breaks apps
  15. # ? :+1 : ? == just some internal changes, nothing breaks but might work
  16. # better
  17. # CURRENT : REVISION : AGE
  18. LT_VERSION=6:1:3
  19. AC_SUBST(LOG4C_MAJOR_VERSION)
  20. AC_SUBST(LOG4C_MINOR_VERSION)
  21. AC_SUBST(LOG4C_MICRO_VERSION)
  22. AC_SUBST(LT_VERSION)
  23. AM_INIT_AUTOMAKE("log4c", $VERSION)
  24. AC_CANONICAL_HOST
  25. # Need this to get pthread etc.
  26. AC_DEFINE(_GNU_SOURCE,1,"POSIXandGNU extensions")
  27. #####################
  28. # Checks for programs
  29. #.
  30. AC_PROG_YACC
  31. AC_PROG_CC
  32. AC_PROG_CPP
  33. AC_PROG_CXX
  34. AM_PROG_LEX
  35. AC_PROG_AWK
  36. AC_PROG_INSTALL
  37. AC_PROG_LN_S
  38. AC_PROG_MAKE_SET
  39. AC_PROG_LIBTOOL
  40. # platform idioms
  41. case "$host" in
  42. *-hp-hpux*)
  43. CFLAGS="-g"
  44. ;;
  45. *-mingw*)
  46. dnl required to create shared libraries
  47. LDFLAGS_NOUNDEFINED="-no-undefined"
  48. l4c_have_win=yes
  49. ;;
  50. *)
  51. ;;
  52. esac
  53. AC_SUBST([LDFLAGS_NOUNDEFINED])
  54. AM_CONDITIONAL([WIN32], test "x$l4c_have_win" = "xyes")
  55. if test "x$GCC" = "xyes"; then
  56. case " $CFLAGS " in
  57. *[\ \ ]-Wall[\ \ ]*) ;;
  58. *) CFLAGS="$CFLAGS -Wall" ;;
  59. esac
  60. fi
  61. ##########################
  62. # Enable debug if required
  63. #
  64. AC_ARG_ENABLE(debug,
  65. AC_HELP_STRING([--enable-debug], [LOG4C: turn on debugging (default=no)]))
  66. if test x$enable_debug = xyes; then
  67. CFLAGS="$CFLAGS -D__SD_DEBUG__ -D__LOG4C_DEBUG__"
  68. fi
  69. ########################
  70. # Enable reread if flagged
  71. #
  72. AC_ARG_ENABLE(reread,
  73. AC_HELP_STRING([--enable-reread],
  74. [LOG4C: turn on re-read of log4crc file(default=no)]i),
  75. if test x$enable_reread = xyes; then
  76. AC_MSG_NOTICE([Enabled automatic reread of log4crc file])
  77. AC_DEFINE([__ENABLE_REREAD__], [],
  78. [Enable automatic reread of log4crc file])
  79. fi
  80. )
  81. ####################################################################
  82. # Test for pthread and enable rollingfile code which depends on that
  83. # if we find it
  84. #
  85. AC_CHECK_HEADER(pthread.h,[
  86. AC_CHECK_LIB(pthread,pthread_mutex_init,[
  87. LIBS="$LIBS -lpthread"
  88. AC_DEFINE([WITH_ROLLINGFILE], [], [Define if we found pthread.h libpthread])
  89. AC_MSG_NOTICE([Compile with rollingfile code])
  90. with_rollingfile=true],[AC_MSG_NOTICE([No pthread--not compiling rollingfile code])]
  91. )
  92. ])
  93. AM_CONDITIONAL(WITH_ROLLINGFILE, test "x$with_rollingfile" = "xtrue")
  94. #####################################
  95. # Enable test compilation if required
  96. #
  97. AC_ARG_ENABLE(test,
  98. AC_HELP_STRING([--enable-test], [LOG4C: compile test programs (default=no)]))
  99. AM_CONDITIONAL(TEST, test x$enable_test = xyes)
  100. #####################################
  101. # Checks for libraries.
  102. #
  103. #####################################
  104. # Checks for header files.
  105. #
  106. AC_HEADER_STDC
  107. AC_CHECK_HEADERS([alloc.h fcntl.h inttypes.h langinfo.h limits.h malloc.h stddef.h stdint.h \
  108. stdlib.h string.h sys/time.h syslog.h unistd.h stdarg.h varargs.h getopt.h \
  109. pthread.h])
  110. dnl These tests don't work properly, on MinGW the functions are not detected
  111. dnl even they are available. But replacement functions are good enough. :-)
  112. AC_CHECK_FUNCS([sleep gmtime_r localtime_r])
  113. AC_CHECK_DECLS([sleep], [], [], [[#include <unistd.h>]])
  114. AC_CHECK_DECLS([gmtime_r, localtime_r], [], [], [[#include <time.h>]])
  115. # Checks for typedefs, structures, and compiler characteristics.
  116. AC_C_CONST
  117. AC_C_INLINE
  118. AC_TYPE_SIZE_T
  119. AC_HEADER_TIME
  120. AC_STRUCT_TM
  121. # Checks for library functions.
  122. AC_FUNC_ALLOCA
  123. dnl nonportable or buggy (we want cross-compilation)
  124. dnl AC_FUNC_MALLOC
  125. AC_FUNC_MMAP
  126. dnl nonportable or buggy (we want cross-compilation)
  127. dnl AC_FUNC_REALLOC
  128. AC_FUNC_UTIME_NULL
  129. AC_FUNC_VPRINTF
  130. AC_CHECK_FUNCS([gettimeofday memset munmap nl_langinfo strdup strerror strncasecmp strrchr strstr utime sbrk])
  131. LOG4C_FUNC_GETHOSTNAME
  132. LOG4C_VA_COPY
  133. # enable mmap appender only when mmap() function found
  134. AM_CONDITIONAL(WITH_MMAP, test "x$ac_cv_func_mmap_fixed_mapped" = "xyes")
  135. ###############
  136. # Documentation
  137. #
  138. AC_ARG_ENABLE(doc,
  139. AC_HELP_STRING([--enable-doc],
  140. [LOG4C: create documentation with doxygen--html/man/pdf (default=no)]))
  141. # Checks for doxygen
  142. AC_PATH_PROG(DOXYGEN, doxygen, )
  143. if test x$DOXYGEN = x; then
  144. enable_doc=no
  145. fi
  146. AM_CONDITIONAL(DOC, test x$enable_doc = xyes)
  147. #
  148. # Checks for the graphviz tool 'dot' used to generate graphs
  149. # of the class dependencies. Probably not useful
  150. # for c programs. If we don't find dot in the path
  151. # then set HAVE_DOT to NO in Doxyfile.in
  152. #
  153. HAVE_DOT=YES
  154. AC_PATH_PROG(DOT, dot, )
  155. if test x$DOT = x; then
  156. HAVE_DOT=NO
  157. fi
  158. AC_SUBST(HAVE_DOT)
  159. # Similar for latex
  160. HAVE_LATEX=YES
  161. AC_PATH_PROG(LATEX, latex, )
  162. if test x$LATEX = x; then
  163. HAVE_LATEX=NO
  164. fi
  165. # This variable is used to turn LATEX on and off in the Doxyfile
  166. AC_SUBST(HAVE_LATEX)
  167. # This variable is used in doc/Makefile.am to set the target to make
  168. # the doc with latex or not
  169. AM_CONDITIONAL(HAVE_LATEX, test x$HAVE_LATEX = xYES)
  170. #
  171. # Documentation
  172. ###############
  173. AC_ARG_ENABLE(constructors, AC_HELP_STRING([--enable-constructors],
  174. [LOG4C: build with initialization constructors [default=no]]))
  175. if test "x$enable_constructors" = "xyes"; then
  176. AC_DEFINE([WITH_CONSTRUCTORS], 1,
  177. [build log4c with initialization constructors])
  178. AC_MSG_NOTICE([using constructors to initialize log4c])
  179. fi
  180. #
  181. ###################
  182. ###################
  183. # Test for libexpat
  184. #
  185. AC_ARG_WITH(expat,
  186. AC_HELP_STRING([--without-expat],
  187. [LOG4C: build without expat (default=no).
  188. Set this option to yes if you do not want Log4C to use expat
  189. for parsing the configuration file. If without-expat is
  190. set to yes then none of the other options related to expat
  191. have any effect and Log4C uses some bundled yacc/lex code
  192. for parsing it's configuration file.
  193. ]),
  194. with_expat=no,
  195. with_expat=yes)
  196. if test x$with_expat = xyes ; then
  197. use_expat=yes
  198. AM_PATH_EXPAT(1.95.1)
  199. fi
  200. dnl AC_MSG_NOTICE([value of with_expat = $with_expat no_expat = $no_expat use_expat= $use_expat])
  201. AM_CONDITIONAL(USE_EXPAT, test "x$use_expat" = "xyes" )
  202. #
  203. ###################
  204. AC_CONFIG_FILES([
  205. Makefile
  206. log4c-config
  207. log4c.pc
  208. log4crc.sample
  209. log4c.spec
  210. config/Makefile
  211. doc/Makefile
  212. doc/Doxyfile
  213. doc/main.doc
  214. src/Makefile
  215. src/log4c/Makefile
  216. src/log4c/version.h
  217. src/sd/Makefile
  218. tests/Makefile
  219. tests/log4c/Makefile
  220. examples/Makefile
  221. examples/log4crc
  222. examples/helloworld/Makefile
  223. examples/helloworld1/Makefile
  224. ])
  225. AC_CONFIG_COMMANDS([default],[[
  226. chmod +x log4c-config
  227. ]],[[]])
  228. AC_OUTPUT