autogen.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #!/bin/sh
  2. # Run this to set up the build system: configure, makefiles, etc.
  3. package="jbig2dec"
  4. AUTOMAKE_FLAGS="$AUTOMAKE_FLAGS"
  5. srcdir=`dirname $0`
  6. test -z "$srcdir" && srcdir=.
  7. cd "$srcdir"
  8. echo "checking for autoconf... "
  9. (autoconf --version) < /dev/null > /dev/null 2>&1 || {
  10. echo
  11. echo "You must have autoconf installed to compile $package."
  12. echo "Download the appropriate package for your distribution,"
  13. echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  14. exit 1
  15. }
  16. VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/"
  17. VERSIONMKMAJ="sed -e s/\([0-9][0-9]*\)[^0-9].*/\\1/"
  18. VERSIONMKMIN="sed -e s/.*[0-9][0-9]*\.//"
  19. JBIG2VERSIONGREP="sed -e s/^.*(\([0-9][0-9]*\)).*/\\1/"
  20. JBIG2MAJOR=$(grep 'define JBIG2_VERSION_MAJOR' jbig2.h | $JBIG2VERSIONGREP)
  21. JBIG2MINOR=$(grep 'define JBIG2_VERSION_MINOR' jbig2.h | $JBIG2VERSIONGREP)
  22. sed -e "s/^\(AC_INIT[^,]*,\)[^,]*\(,.*\)$/\1 [$JBIG2MAJOR.$JBIG2MINOR]\2/" configure.ac.in > configure.ac
  23. # do we need automake?
  24. if test "x$USE_OLD" = "xyes" ; then
  25. if test -r Makefile.am; then
  26. AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am`
  27. AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP`
  28. if test "x$AM_NEEDED" = "x$AM_OPTIONS"; then
  29. AM_NEEDED=""
  30. fi
  31. if test -z "$AM_NEEDED"; then
  32. echo -n "checking for automake... "
  33. AUTOMAKE=automake
  34. ACLOCAL=aclocal
  35. if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
  36. echo "yes"
  37. else
  38. echo "no"
  39. AUTOMAKE=
  40. fi
  41. else
  42. echo -n "checking for automake $AM_NEEDED or later... "
  43. majneeded=`echo $AM_NEEDED | $VERSIONMKMAJ`
  44. minneeded=`echo $AM_NEEDED | $VERSIONMKMIN`
  45. for am in automake-$AM_NEEDED automake$AM_NEEDED automake \
  46. automake-1.7 automake-1.8 automake-1.9 automake-1.10; do
  47. ($am --version < /dev/null > /dev/null 2>&1) || continue
  48. ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP`
  49. maj=`echo $ver | $VERSIONMKMAJ`
  50. min=`echo $ver | $VERSIONMKMIN`
  51. if test $maj -eq $majneeded -a $min -ge $minneeded; then
  52. AUTOMAKE=$am
  53. echo $AUTOMAKE
  54. break
  55. fi
  56. done
  57. test -z $AUTOMAKE && echo "no"
  58. echo -n "checking for aclocal $AM_NEEDED or later... "
  59. for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal\
  60. aclocal-1.7 aclocal-1.8 aclocal-1.9 aclocal-1.10; do
  61. ($ac --version < /dev/null > /dev/null 2>&1) || continue
  62. ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP`
  63. maj=`echo $ver | $VERSIONMKMAJ`
  64. min=`echo $ver | $VERSIONMKMIN`
  65. if test $maj -eq $majneeded -a $min -ge $minneeded; then
  66. ACLOCAL=$ac
  67. echo $ACLOCAL
  68. break
  69. fi
  70. done
  71. test -z $ACLOCAL && echo "no"
  72. fi
  73. test -z $AUTOMAKE || test -z $ACLOCAL && {
  74. echo
  75. echo "You must have automake installed to compile $package."
  76. echo "Download the appropriate package for your distribution,"
  77. echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  78. exit 1
  79. }
  80. fi
  81. else
  82. AUTOMAKE=automake
  83. ACLOCAL=aclocal
  84. AM_VER=`$AUTOMAKE --version | grep "automake (GNU automake)" | sed 's/[^0-9\.]*//g'`
  85. AM_MAJ=`echo $AM_VER |cut -d. -f1`
  86. AM_MIN=`echo $AM_VER |cut -d. -f2`
  87. AM_PAT=`echo $AM_VER |cut -d. -f3`
  88. AM_NEEDED=`fgrep AUTOMAKE_OPTIONS Makefile.am | $VERSIONGREP`
  89. AM_MAJOR_REQ=`echo $AM_NEEDED |cut -d. -f1`
  90. AM_MINOR_REQ=`echo $AM_NEEDED |cut -d. -f2`
  91. echo "checking for automake $AM_NEEDED or later..."
  92. if [ $AM_MAJ -lt $AM_MAJOR_REQ -o $AM_MIN -lt $AM_MINOR_REQ ] ; then
  93. echo
  94. echo "You must have automake $AM_NEEDED or better installed to compile $package."
  95. echo "Download the appropriate package for your distribution,"
  96. echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  97. exit 1
  98. fi
  99. fi
  100. # do we need libtool?
  101. if ! test -z `grep -l -s -e PROG_LIBTOOL configure.ac configure.in`; then
  102. echo -n "Checking for libtoolize... "
  103. LIBTOOLIZE=
  104. for lt in glibtoolize libtoolize; do
  105. if ($lt --version < /dev/null > /dev/null 2>&1); then
  106. LIBTOOLIZE=$lt
  107. echo $lt
  108. break;
  109. fi
  110. done
  111. if test -z $LIBTOOLIZE; then
  112. echo
  113. echo "You must have GNU libtool installed to compile $package."
  114. echo "Download the appropriate package for your distribution,"
  115. echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
  116. exit 1
  117. fi
  118. fi
  119. echo "Generating configuration files for $package, please wait...."
  120. echo " $ACLOCAL $ACLOCAL_FLAGS"
  121. $ACLOCAL $ACLOCAL_FLAGS
  122. echo " $LIBTOOLIZE"
  123. $LIBTOOLIZE --copy
  124. echo " autoheader"
  125. autoheader
  126. echo " creating config_types.h.in"
  127. cat >config_types.h.in <<EOF
  128. /*
  129. generated header with missing types for the
  130. jbig2dec program and library. include this
  131. after config.h, within the HAVE_CONFIG_H
  132. ifdef
  133. */
  134. #ifdef HAVE_STDINT_H
  135. # include <stdint.h>
  136. #else
  137. # ifdef JBIG2_REPLACE_STDINT_H
  138. # include <@JBIG2_STDINT_H@>
  139. # else
  140. typedef unsigned @JBIG2_INT32_T@ uint32_t;
  141. typedef unsigned @JBIG2_INT16_T@ uint16_t;
  142. typedef unsigned @JBIG2_INT8_T@ uint8_t;
  143. typedef signed @JBIG2_INT32_T@ int32_t;
  144. typedef signed @JBIG2_INT16_T@ int16_t;
  145. typedef signed @JBIG2_INT8_T@ int8_t;
  146. # endif /* JBIG2_REPLACE_STDINT */
  147. #endif /* HAVE_STDINT_H */
  148. EOF
  149. echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
  150. $AUTOMAKE --add-missing --copy $AUTOMAKE_FLAGS
  151. echo " autoconf"
  152. autoconf
  153. if test -z "$*"; then
  154. echo "I am going to run ./configure with no arguments - if you wish "
  155. echo "to pass any to it, please specify them on the $0 command line."
  156. else
  157. echo "running ./configure $@"
  158. fi
  159. $srcdir/configure "$@" && echo