File indexing completed on 2024-04-28 11:21:06
0001 #! /bin/sh 0002 0003 # local options: ac_help is the help message that describes them 0004 # and LOCAL_AC_OPTIONS is the script that interprets them. LOCAL_AC_OPTIONS 0005 # is a script that's processed with eval, so you need to be very careful to 0006 # make certain that what you quote is what you want to quote. 0007 0008 # load in the configuration file 0009 # 0010 ac_help='--enable-amalloc Enable memory allocation debugging 0011 --with-tabstops=N Set tabstops to N characters (default is 4) 0012 --shared Build shared libraries (default is static) 0013 --pkg-config Install pkg-config(1) glue files 0014 --cxx-binding Install header files with c++ wrappers 0015 --github-checkbox[=input] Enable github-style checkboxes in lists 0016 (if =input, use <input checkbox>, otherwise 0017 use html ballot entities)' 0018 0019 LOCAL_AC_OPTIONS=' 0020 set=`locals $*`; 0021 if [ "$set" ]; then 0022 eval $set 0023 shift 1 0024 else 0025 ac_error=T; 0026 fi' 0027 0028 locals() { 0029 K=`echo $1 | $AC_UPPERCASE` 0030 case "$K" in 0031 --SHARED) 0032 echo TRY_SHARED=T 0033 ;; 0034 --ENABLE-*) enable=`echo $K | sed -e 's/--ENABLE-//' | tr '-' '_'` 0035 echo WITH_${enable}=T ;; 0036 --DEBIAN-GLITCH) 0037 echo DEBIAN_GLITCH=T 0038 ;; 0039 --H1-TITLE) 0040 echo H1TITLE=T 0041 ;; 0042 --PKG-CONFIG) 0043 echo PKGCONFIG=T 0044 ;; 0045 --CXX-BINDING) 0046 echo CXX_BINDING=T 0047 ;; 0048 --GITHUB-CHECKBOX) 0049 echo GITHUB_CHECKBOX=T 0050 ;; 0051 --GITHUB-CHECKBOX=INPUT) 0052 echo GITHUB_CHECKBOX=T 0053 echo GITHUB_CHECKBOX_AS_INPUT=T 0054 ;; 0055 esac 0056 } 0057 0058 VERSION=`cat VERSION` 0059 TARGET=markdown 0060 . ./configure.inc 0061 0062 # if there's a makefile here, it's likely that it's a discount 0063 # makefile and there's bits of an old configuration here. So 0064 # blow everything away before we start the configuration. 0065 0066 test -f Makefile && make spotless 2>/dev/null >/dev/null 0067 0068 AC_INIT $TARGET 0069 AC_SUB 'PACKAGE_NAME' lib$TARGET 0070 AC_SUB 'PACKAGE_VERSION' $VERSION 0071 0072 for banned_with in dl fenced-code id-anchor github-tags urlencoded-anchor; do 0073 banned_with_variable_ref=\$WITH_`echo "$banned_with" | $AC_UPPERCASE | tr - _` 0074 if [ "`eval echo "$banned_with_variable_ref"`" ]; then 0075 LOG "Setting theme default --with-$banned_with." 0076 fi 0077 done 0078 0079 # theme wants the old behavior of --with-(foo) 0080 # 0081 case "`echo "$WITH_DL" | $AC_UPPERCASE`" in 0082 EXTRA) THEME_CF="MKD_DLEXTRA|MKD_NODLDISCOUNT";; 0083 BOTH) THEME_CF="MKD_DLEXTRA";; 0084 esac 0085 test "$WITH_FENCED_CODE" && THEME_CF="${THEME_CF:+$THEME_CF|}MKD_FENCEDCODE" 0086 0087 AC_DEFINE THEME_CF "$THEME_CF" 0088 0089 0090 test "$DEBIAN_GLITCH" && AC_DEFINE 'DEBIAN_GLITCH' 1 0091 0092 AC_PROG_CC 0093 AC_QUIET AC_PROG git && AC_DEFINE 'HAS_GIT' '1' 0094 AC_CHECK_ATTRIBUTE destructor 0095 0096 test "$TRY_SHARED" && AC_COMPILER_PIC && AC_CC_SHLIBS 0097 0098 if [ "IS_BROKEN_CC" ]; then 0099 case "$AC_CC $AC_CFLAGS" in 0100 *-pedantic*) ;; 0101 *) # hack around deficiencies in gcc and clang 0102 # 0103 AC_DEFINE 'while(x)' 'while( (x) != 0 )' 0104 AC_DEFINE 'if(x)' 'if( (x) != 0 )' 0105 0106 if [ "$IS_CLANG" ]; then 0107 AC_CC="$AC_CC -Wno-implicit-int" 0108 elif [ "$IS_GCC" ]; then 0109 AC_CC="$AC_CC -Wno-return-type -Wno-implicit-int" 0110 fi ;; 0111 esac 0112 fi 0113 0114 AC_PROG ar || AC_FAIL "$TARGET requires ar" 0115 AC_PROG ranlib 0116 0117 # should we create a .pc for pkg-config & GNU automake 0118 # 0119 if [ "$PKGCONFIG" ]; then 0120 AC_SUB MK_PKGCONFIG '' 0121 elif AC_PROG pkg-config || AC_PROG automake ; then 0122 PKGCONFIG=true 0123 AC_SUB MK_PKGCONFIG '' 0124 else 0125 AC_SUB MK_PKGCONFIG '#' 0126 fi 0127 0128 AC_C_VOLATILE 0129 AC_C_CONST 0130 AC_C_INLINE 0131 AC_SCALAR_TYPES sub hdr 0132 AC_CHECK_BASENAME 0133 AC_CHECK_ALLOCA 0134 0135 AC_CHECK_HEADERS sys/types.h pwd.h && AC_CHECK_FUNCS getpwuid 0136 if AC_CHECK_HEADERS sys/stat.h && AC_CHECK_FUNCS stat; then 0137 0138 # need to check some of the S_ISxxx stat macros, because they may not 0139 # exist (for notspecial.c) 0140 0141 cat > ngc$$.c << EOF 0142 #include <sys/stat.h> 0143 0144 main(argc, argv) 0145 char **argv; 0146 { 0147 struct stat info; 0148 0149 if ( stat(argv[0], &info) != 0 ) 0150 return 1; 0151 0152 return MACRO(info.st_mode); 0153 } 0154 EOF 0155 LOGN "special file macros in sys/stat.h:" 0156 _none="none" 0157 for x in ISSOCK ISCHR ISFIFO; do 0158 if $AC_CC -DMACRO=S_$x -o ngc$$.o ngc$$.c; then 0159 LOGN " S_${x}" 0160 AC_DEFINE "HAS_${x}" '1' 0161 unset _none 0162 fi 0163 done 0164 LOG "${_none}." 0165 __remove ngc$$.o ngc$$.c 0166 fi 0167 0168 if AC_CHECK_FUNCS srandom; then 0169 AC_DEFINE 'INITRNG(x)' 'srandom((unsigned int)x)' 0170 elif AC_CHECK_FUNCS srand; then 0171 AC_DEFINE 'INITRNG(x)' 'srand((unsigned int)x)' 0172 else 0173 AC_DEFINE 'INITRNG(x)' '(void)1' 0174 fi 0175 0176 AC_CHECK_FUNCS 'memset((char*)0,0,0)' 'string.h' || \ 0177 AC_CHECK_FUNCS 'memset((char*)0,0,0)' || \ 0178 AC_FAIL "$TARGET requires memset" 0179 0180 if AC_CHECK_FUNCS random; then 0181 AC_DEFINE 'COINTOSS()' '(random()&1)' 0182 elif AC_CHECK_FUNCS rand; then 0183 AC_DEFINE 'COINTOSS()' '(rand()&1)' 0184 else 0185 AC_DEFINE 'COINTOSS()' '1' 0186 fi 0187 0188 if AC_CHECK_FUNCS strcasecmp; then 0189 : 0190 elif AC_CHECK_FUNCS stricmp; then 0191 AC_DEFINE strcasecmp stricmp 0192 else 0193 AC_FAIL "$TARGET requires either strcasecmp() or stricmp()" 0194 fi 0195 0196 if AC_CHECK_FUNCS strncasecmp; then 0197 : 0198 elif AC_CHECK_FUNCS strnicmp; then 0199 AC_DEFINE strncasecmp strnicmp 0200 else 0201 AC_FAIL "$TARGET requires either strncasecmp() or strnicmp()" 0202 fi 0203 0204 if AC_CHECK_FUNCS fchdir || AC_CHECK_FUNCS getcwd ; then 0205 AC_SUB 'THEME' '' 0206 else 0207 AC_SUB 'THEME' '#' 0208 fi 0209 0210 if [ -z "$WITH_TABSTOPS" ]; then 0211 TABSTOP=4 0212 elif [ "$WITH_TABSTOPS" -eq 1 ]; then 0213 TABSTOP=8 0214 else 0215 TABSTOP=$WITH_TABSTOPS 0216 fi 0217 AC_DEFINE 'TABSTOP' $TABSTOP 0218 AC_SUB 'TABSTOP' $TABSTOP 0219 0220 0221 if [ "$WITH_AMALLOC" ]; then 0222 AC_DEFINE 'USE_AMALLOC' 1 0223 AC_SUB 'AMALLOC' 'amalloc.o' 0224 else 0225 AC_SUB 'AMALLOC' '' 0226 fi 0227 0228 if [ "$H1TITLE" ]; then 0229 AC_SUB 'H1TITLE' h1title.o 0230 AC_DEFINE USE_H1TITLE 1 0231 else 0232 AC_SUB 'H1TITLE' '' 0233 fi 0234 0235 if [ "$GITHUB_CHECKBOX" ]; then 0236 AC_DEFINE 'GITHUB_CHECKBOX' '1' 0237 test "$GITHUB_CHECKBOX_AS_INPUT" && AC_DEFINE 'CHECKBOX_AS_INPUT' '1' 0238 fi 0239 0240 0241 [ "$OS_FREEBSD" -o "$OS_DRAGONFLY" ] || AC_CHECK_HEADERS malloc.h 0242 0243 [ "$WITH_PANDOC_HEADER" ] && AC_DEFINE 'PANDOC_HEADER' '1' 0244 0245 GENERATE="Makefile version.c mkdio.h" 0246 0247 if [ "$PKGCONFIG" ]; then 0248 GENERATE="$GENERATE libmarkdown.pc" 0249 fi 0250 0251 AC_OUTPUT $GENERATE 0252 0253 if [ "$CXX_BINDING" ]; then 0254 LOG "applying c++ glue to mkdio.h" 0255 mv mkdio.h mkdio.h$$ 0256 ( echo '#ifdef __cplusplus' 0257 echo 'extern "C" {' 0258 echo '#endif' 0259 cat mkdio.h$$ 0260 echo '#ifdef __cplusplus' 0261 echo '}' 0262 echo '#endif' ) > mkdio.h 0263 rm mkdio.h$$ 0264 fi