configure.in 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. dnl this file has to be processed by autoconf
  2. dnl run ./buildconf.sh to get a working ./configure script
  3. dnl {{{ AX_PREFIX_CONFIG_H
  4. AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl
  5. AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl
  6. AC_CONFIG_COMMANDS([ifelse($1,,$PACKAGE-config.h,$1)],[dnl
  7. AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl
  8. AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl
  9. AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl
  10. AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl
  11. AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl
  12. AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl
  13. m4_pushdef([_script],[conftest.prefix])dnl
  14. m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl
  15. _OUT=`echo ifelse($1, , $PACKAGE-config.h, $1)`
  16. _DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"`
  17. _PKG=`echo ifelse($2, , $PACKAGE, $2)`
  18. _LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"`
  19. _UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"`
  20. _INP=`echo "ifelse($3,,,$3)" | sed -e 's/ *//'`
  21. if test ".$_INP" = "."; then
  22. for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue
  23. case "$ac_file" in
  24. *.h) _INP=$ac_file ;;
  25. *)
  26. esac
  27. test ".$_INP" != "." && break
  28. done
  29. fi
  30. if test ".$_INP" = "."; then
  31. case "$_OUT" in
  32. */*) _INP=`basename "$_OUT"`
  33. ;;
  34. *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"`
  35. ;;
  36. *) _INP=config.h
  37. ;;
  38. esac
  39. fi
  40. if test -z "$_PKG" ; then
  41. AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H])
  42. else
  43. if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then
  44. _INP="$srcdir/$_INP"
  45. fi fi
  46. AC_MSG_NOTICE(creating: $_OUT: prefix $_UPP for $_INP defines)
  47. if test -f $_INP ; then
  48. echo "s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/" > _script
  49. echo "s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/" >> _script
  50. echo "s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1 \\" >> _script
  51. echo "@%:@def[]ine $_UPP""_\\1 \\2 \\" >> _script
  52. echo "@%:@endif/" >>_script
  53. echo "s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1 \\" >> _script
  54. echo "@%:@define $_LOW""_\\1 \\2 \\" >> _script
  55. echo "@%:@endif/" >> _script
  56. # now executing _script on _DEF input to create _OUT output file
  57. echo "@%:@ifndef $_DEF" >$tmp/pconfig.h
  58. echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h
  59. echo ' ' >>$tmp/pconfig.h
  60. echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h
  61. sed -f _script $_INP >>$tmp/pconfig.h
  62. echo ' ' >>$tmp/pconfig.h
  63. echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h
  64. echo "@%:@endif" >>$tmp/pconfig.h
  65. if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then
  66. rm -f $tmp/pconfig.h
  67. AC_MSG_NOTICE([unchanged $_OUT])
  68. else
  69. ac_dir=`AS_DIRNAME(["$_OUT"])`
  70. AS_MKDIR_P(["$ac_dir"])
  71. rm -f "$_OUT"
  72. mv $tmp/pconfig.h "$_OUT"
  73. fi
  74. cp _script _configs.sed
  75. else
  76. AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT])
  77. fi
  78. rm -f conftest.*
  79. fi
  80. m4_popdef([_symbol])dnl
  81. m4_popdef([_script])dnl
  82. AS_VAR_POPDEF([_INP])dnl
  83. AS_VAR_POPDEF([_UPP])dnl
  84. AS_VAR_POPDEF([_LOW])dnl
  85. AS_VAR_POPDEF([_PKG])dnl
  86. AS_VAR_POPDEF([_DEF])dnl
  87. AS_VAR_POPDEF([_OUT])dnl
  88. ],[PACKAGE="$PACKAGE"])])
  89. dnl }}}
  90. AC_PREREQ(2.60)
  91. AC_INIT([libhpdf],[2.3.0-dev])
  92. AC_CONFIG_SRCDIR([README])
  93. AC_CONFIG_SRCDIR(include/hpdf.h)
  94. AC_CONFIG_HEADER(include/config.h)
  95. AX_PREFIX_CONFIG_H(include/hpdf_config.h)
  96. AM_INIT_AUTOMAKE([no-define])
  97. AM_MAINTAINER_MODE
  98. dnl Check for programs
  99. AC_PROG_CC
  100. AC_PROG_LD
  101. AM_PROG_LIBTOOL
  102. AC_PROG_INSTALL
  103. AC_PROG_EGREP
  104. dnl Check for size_t
  105. AC_TYPE_SIZE_T
  106. dnl Check for header files
  107. AC_CHECK_HEADERS(string.h strings.h unistd.h stdint.h)
  108. AC_CHECK_LIB([m], [floor], [LIBS="$LIBS -lm"], [AC_MSG_ERROR([can't continue without libm])])
  109. DEFAULT_INSTALL_PREFIX="/usr/local"
  110. STANDARD_PREFIXES="/usr /usr/local /opt /local"
  111. HPDF_MAJOR_VERSION=2
  112. HPDF_MINOR_VERSION=3
  113. HPDF_BUGFIX_VERSION=0
  114. HPDF_EXTRA_VERSION="-dev"
  115. HPDF_VERSION_TEXT="${HPDF_MAJOR_VERSION}.${HPDF_MINOR_VERSION}.${HPDF_BUGFIX_VERSION}${HPDF_EXTRA_VERSION}"
  116. HPDF_VERSION_ID=`expr [$]HPDF_MAJOR_VERSION \* 10000 + [$]HPDF_MINOR_VERSION \* 100 + [$]HPDF_BUGFIX_VERSION`
  117. dnl generate hpdf_version.h {{{
  118. echo "/* automatically generated by configure */" > hpdf_version.h.new
  119. echo "/* edit configure.in to change version number */" >> hpdf_version.h.new
  120. echo "#define HPDF_MAJOR_VERSION $HPDF_MAJOR_VERSION" >> hpdf_version.h.new
  121. echo "#define HPDF_MINOR_VERSION $HPDF_MINOR_VERSION" >> hpdf_version.h.new
  122. echo "#define HPDF_BUGFIX_VERSION $HPDF_BUGFIX_VERSION" >> hpdf_version.h.new
  123. echo "#define HPDF_EXTRA_VERSION \"$HPDF_EXTRA_VERSION\"" >> hpdf_version.h.new
  124. echo "#define HPDF_VERSION_TEXT \"$HPDF_VERSION_TEXT\"" >> hpdf_version.h.new
  125. echo "#define HPDF_VERSION_ID $HPDF_VERSION_ID" >> hpdf_version.h.new
  126. cmp hpdf_version.h.new $srcdir/include/hpdf_version.h >/dev/null 2>&1
  127. if test $? -ne 0 ; then
  128. rm -f $srcdir/include/hpdf_version.h && mv hpdf_version.h.new $srcdir/include/hpdf_version.h && \
  129. echo 'Updated include/hpdf_version.h'
  130. else
  131. rm -f hpdf_version.h.new
  132. fi
  133. dnl }}}
  134. dnl {{{ --enable-debug
  135. AC_ARG_ENABLE(debug,
  136. [AS_HELP_STRING([--enable-debug],[enable debugging symbols and compile flags])
  137. ],
  138. [
  139. if test x"$enableval" = xyes ; then
  140. debug="yes"
  141. else
  142. debug="no"
  143. fi
  144. ]
  145. )
  146. if test x"$debug" = xyes ; then
  147. AC_DEFINE([DEBUG], [], [debug build])
  148. if test x"$GCC" = xyes; then
  149. dnl Remove any optimization flags from CFLAGS
  150. changequote({,})
  151. CFLAGS=`echo "$CFLAGS" | /usr/bin/sed -e 's/-O[0-9s]*//g'`
  152. CFLAGS=`echo "$CFLAGS" | /usr/bin/sed -e 's/-g[0-2]\? //g'`
  153. changequote([,])
  154. CFLAGS="$CFLAGS -g3 -Wall -O0"
  155. fi
  156. dnl Do not strip symbols from developer object files.
  157. INSTALL_STRIP_FLAG=""
  158. else
  159. dnl Make sure to strip symbols from non-developer object files.
  160. INSTALL_STRIP_FLAG="-s"
  161. fi
  162. dnl }}}
  163. dnl {{{ --enable-debug-trace
  164. AC_ARG_ENABLE(debug-trace,
  165. [AS_HELP_STRING([--enable-debug-trace],[enable debug trace (only available along with --enable-debug)])
  166. ],
  167. [
  168. if test x"$enableval" = xyes && test x"$debug" = xyes; then
  169. debug_trace="yes"
  170. else
  171. debug_trace="no"
  172. fi
  173. ]
  174. )
  175. if test x"$debug_trace" = xyes ; then
  176. AC_DEFINE([DEBUG_TRACE], [], [debug trace enabled])
  177. fi
  178. dnl }}}
  179. dnl {{{ --with-libdir
  180. AC_ARG_WITH(libdir,
  181. [AS_HELP_STRING([--with-libdir],[look for libraries in .../NAME rather than .../lib])
  182. ],
  183. [LIBDIR=$with_libdir],
  184. [LIBDIR=lib]
  185. )
  186. dnl }}}
  187. dnl {{{ --with-zlib
  188. AC_ARG_WITH(zlib,
  189. [AS_HELP_STRING([--with-zlib],[specify Zlib install prefix])
  190. ],
  191. [ ],
  192. [with_zlib=yes]
  193. )
  194. if test "x$with_zlib" = "xno"; then
  195. AC_DEFINE([HAVE_NOZLIB], [], [zlib is not available])
  196. else
  197. AC_MSG_CHECKING([Zlib install prefix])
  198. if test "x$with_zlib" = "xyes"; then
  199. for i in `echo "$STANDARD_PREFIXES"`; do
  200. if test -f "$i/include/zlib.h"; then
  201. ZLIB_DIR="$i"
  202. break;
  203. fi
  204. done
  205. else
  206. if test -f "$with_zlib/include/zlib.h"; then
  207. ZLIB_DIR="$with_zlib"
  208. break;
  209. else
  210. AC_MSG_ERROR([Can't find Zlib headers under $with_zlib directory]);
  211. fi
  212. fi
  213. if test "x$ZLIB_DIR" = "x"; then
  214. AC_MSG_ERROR([Unable to locate Zlib headers, please use --with-zlib=<DIR>]);
  215. fi
  216. AC_MSG_RESULT([$ZLIB_DIR])
  217. LDFLAGS="$LDFLAGS -L$ZLIB_DIR/$LIBDIR"
  218. CFLAGS="$CFLAGS -I$ZLIB_DIR/include"
  219. LIBS="$LIBS -lz"
  220. AC_CHECK_LIB([z], [deflate], [], [
  221. AC_MSG_ERROR([deflate() is missing, check config.log for more details])
  222. ])
  223. HAVE_ZLIB=yes
  224. fi
  225. dnl }}}
  226. dnl {{{ --with-png
  227. AC_ARG_WITH(png,
  228. [AS_HELP_STRING([--with-png],[specify libpng install prefix])
  229. ],
  230. [ ],
  231. [with_png=yes]
  232. )
  233. if test "x$with_png" = "xno"; then
  234. AC_DEFINE([HAVE_NOPNGLIB], [], [libpng is not available])
  235. else
  236. if test "x$HAVE_ZLIB" != "xyes"; then
  237. AC_MSG_ERROR([PNG support requires Zlib, but it's not enabled. Either enable Zlib or disable PNG support.]);
  238. fi
  239. AC_MSG_CHECKING([libpng install prefix])
  240. if test "x$with_png" = "xyes"; then
  241. for i in `echo "$STANDARD_PREFIXES"`; do
  242. if test -f "$i/include/png.h"; then
  243. LIBPNG_DIR="$i"
  244. break;
  245. fi
  246. done
  247. else
  248. if test -f "$with_png/include/png.h"; then
  249. LIBPNG_DIR="$with_png"
  250. break;
  251. else
  252. AC_MSG_ERROR([Can't find libpng headers under $with_png directory]);
  253. fi
  254. fi
  255. if test "x$LIBPNG_DIR" = "x"; then
  256. AC_MSG_ERROR([Unable to locate libpng headers, please use --with-png=<DIR>]);
  257. fi
  258. AC_MSG_RESULT([$LIBPNG_DIR])
  259. LDFLAGS="$LDFLAGS -L$LIBPNG_DIR/$LIBDIR"
  260. CFLAGS="$CFLAGS -I$LIBPNG_DIR/include"
  261. LIBS="$LIBS -lpng"
  262. AC_CHECK_LIB([png], [png_init_io], [], [
  263. AC_MSG_ERROR([png_init_io() is missing, check config.log for more details])
  264. ])
  265. fi
  266. dnl }}}
  267. case "$host_alias" in
  268. *cygwin*[)]
  269. CFLAGS="$CFLAGS -mno-cygwin -DHPDF_DLL_MAKE_CDECL"
  270. ;;
  271. esac
  272. if test "$GCC" = yes ; then
  273. AC_MSG_CHECKING([whether GCC supports -fexceptions])
  274. echo 'void somefunc() { };' > conftest.c
  275. cmd='$CC -fexceptions -c conftest.c'
  276. if eval $cmd 2>&1 | $EGREP -e $1 >/dev/null ; then
  277. AC_MSG_RESULT([no])
  278. else
  279. AC_MSG_RESULT([yes])
  280. CFLAGS="$CFLAGS -fexceptions"
  281. fi
  282. rm -f conftest.*
  283. fi
  284. dnl link against libm
  285. LIBS="$LIBS -lm"
  286. AC_SUBST(INSTALL_STRIP_FLAG)
  287. AC_CONFIG_FILES([Makefile src/Makefile include/Makefile])
  288. AC_OUTPUT
  289. # vim600: expandtab sw=2 ts=2 sts=2 fdm=marker