configure.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #! /bin/sh
  2. # local options: ac_help is the help message that describes them
  3. # and LOCAL_AC_OPTIONS is the script that interprets them. LOCAL_AC_OPTIONS
  4. # is a script that's processed with eval, so you need to be very careful to
  5. # make certain that what you quote is what you want to quote.
  6. # load in the configuration file
  7. #
  8. ac_help='--enable-amalloc Enable memory allocation debugging
  9. --with-tabstops=N Set tabstops to N characters (default is 4)
  10. --with-latex Enable latex passthrough
  11. --enable-all-features Turn on all stable optional features
  12. --shared Build shared libraries (default is static)'
  13. LOCAL_AC_OPTIONS='
  14. set=`locals $*`;
  15. if [ "$set" ]; then
  16. eval $set
  17. shift 1
  18. else
  19. ac_error=T;
  20. fi'
  21. locals() {
  22. K=`echo $1 | $AC_UPPERCASE`
  23. case "$K" in
  24. --SHARED)
  25. echo TRY_SHARED=T
  26. ;;
  27. --ENABLE-ALL|--ENABLE-ALL-FEATURES)
  28. echo WITH_AMALLOC=T
  29. ;;
  30. --ENABLE-*) enable=`echo $K | sed -e 's/--ENABLE-//' | tr '-' '_'`
  31. echo WITH_${enable}=T ;;
  32. --DEBIAN-GLITCH)
  33. echo DEBIAN_GLITCH=T
  34. ;;
  35. esac
  36. }
  37. TARGET=markdown
  38. . ./configure.inc
  39. AC_INIT $TARGET
  40. for banned_with in dl fenced-code id-anchor github-tags urlencoded-anchor; do
  41. banned_with_variable_ref=\$WITH_`echo "$banned_with" | $AC_UPPERCASE | tr - _`
  42. if [ "`eval echo "$banned_with_variable_ref"`" ]; then
  43. LOG "Setting theme default --with-$banned_with."
  44. fi
  45. done
  46. # theme wants the old behavior of --with-(foo)
  47. #
  48. case "`echo "$WITH_DL" | $AC_UPPERCASE`" in
  49. EXTRA) THEME_CF="MKD_DLEXTRA|MKD_NODLDISCOUNT";;
  50. BOTH) THEME_CF="MKD_DLEXTRA";;
  51. esac
  52. test "$WITH_FENCED_CODE" && THEME_CF="${THEME_CF:+$THEME_CF|}MKD_FENCEDCODE"
  53. AC_DEFINE THEME_CF "$THEME_CF"
  54. test "$DEBIAN_GLITCH" && AC_DEFINE 'DEBIAN_GLITCH' 1
  55. AC_PROG_CC
  56. test "$TRY_SHARED" && AC_COMPILER_PIC && AC_CC_SHLIBS
  57. if [ "IS_BROKEN_CC" ]; then
  58. case "$AC_CC $AC_CFLAGS" in
  59. *-pedantic*) ;;
  60. *) # hack around deficiencies in gcc and clang
  61. #
  62. AC_DEFINE 'while(x)' 'while( (x) != 0 )'
  63. AC_DEFINE 'if(x)' 'if( (x) != 0 )'
  64. if [ "$IS_CLANG" ]; then
  65. AC_CC="$AC_CC -Wno-implicit-int"
  66. elif [ "$IS_GCC" ]; then
  67. AC_CC="$AC_CC -Wno-return-type -Wno-implicit-int"
  68. fi ;;
  69. esac
  70. fi
  71. AC_PROG ar || AC_FAIL "$TARGET requires ar"
  72. AC_PROG ranlib
  73. AC_C_VOLATILE
  74. AC_C_CONST
  75. AC_C_INLINE
  76. AC_SCALAR_TYPES sub hdr
  77. AC_CHECK_BASENAME
  78. AC_CHECK_ALLOCA
  79. AC_CHECK_HEADERS sys/types.h pwd.h && AC_CHECK_FUNCS getpwuid
  80. if AC_CHECK_FUNCS srandom; then
  81. AC_DEFINE 'INITRNG(x)' 'srandom((unsigned int)x)'
  82. elif AC_CHECK_FUNCS srand; then
  83. AC_DEFINE 'INITRNG(x)' 'srand((unsigned int)x)'
  84. else
  85. AC_DEFINE 'INITRNG(x)' '(void)1'
  86. fi
  87. if AC_CHECK_FUNCS 'bzero((char*)0,0)'; then
  88. : # Yay
  89. elif AC_CHECK_FUNCS 'memset((char*)0,0,0)'; then
  90. AC_DEFINE 'bzero(p,s)' 'memset(p,s,0)'
  91. else
  92. AC_FAIL "$TARGET requires bzero or memset"
  93. fi
  94. if AC_CHECK_FUNCS random; then
  95. AC_DEFINE 'COINTOSS()' '(random()&1)'
  96. elif AC_CHECK_FUNCS rand; then
  97. AC_DEFINE 'COINTOSS()' '(rand()&1)'
  98. else
  99. AC_DEFINE 'COINTOSS()' '1'
  100. fi
  101. if AC_CHECK_FUNCS strcasecmp; then
  102. :
  103. elif AC_CHECK_FUNCS stricmp; then
  104. AC_DEFINE strcasecmp stricmp
  105. else
  106. AC_FAIL "$TARGET requires either strcasecmp() or stricmp()"
  107. fi
  108. if AC_CHECK_FUNCS strncasecmp; then
  109. :
  110. elif AC_CHECK_FUNCS strnicmp; then
  111. AC_DEFINE strncasecmp strnicmp
  112. else
  113. AC_FAIL "$TARGET requires either strncasecmp() or strnicmp()"
  114. fi
  115. if AC_CHECK_FUNCS fchdir || AC_CHECK_FUNCS getcwd ; then
  116. AC_SUB 'THEME' ''
  117. else
  118. AC_SUB 'THEME' '#'
  119. fi
  120. if [ -z "$WITH_TABSTOPS" ]; then
  121. TABSTOP=4
  122. elif [ "$WITH_TABSTOPS" -eq 1 ]; then
  123. TABSTOP=8
  124. else
  125. TABSTOP=$WITH_TABSTOPS
  126. fi
  127. AC_DEFINE 'TABSTOP' $TABSTOP
  128. AC_SUB 'TABSTOP' $TABSTOP
  129. if [ "$WITH_AMALLOC" ]; then
  130. AC_DEFINE 'USE_AMALLOC' 1
  131. AC_SUB 'AMALLOC' 'amalloc.o'
  132. else
  133. AC_SUB 'AMALLOC' ''
  134. fi
  135. [ "$OS_FREEBSD" -o "$OS_DRAGONFLY" ] || AC_CHECK_HEADERS malloc.h
  136. [ "$WITH_PANDOC_HEADER" ] && AC_DEFINE 'PANDOC_HEADER' '1'
  137. [ "$WITH_LATEX" ] && AC_DEFINE 'WITH_LATEX' '1'
  138. AC_OUTPUT Makefile version.c mkdio.h