1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
#!/bin/sh
# This configure script has been written by Han Boetes
# <han@mijncomputer.nl> and is released in public domain.
add_inc()
{
echo "#define $1" >> config.h
}
note()
{
echo -n "Looking for $@... "
echo "Looking for $@... " >&3
}
case $1 in
-*)
echo "No help and options available. Just run ./configure"
exit 0;
;;
esac
# initial config.h. I think this can be more customizable.
# (Common) compile-time options:
#
# STARTUP -- look for and handle initialization file
# FKEYS -- add support for function key sequences.
# XKEYS -- use termcap function key definitions.
# Warning: XKEYS and bsmap mode do _not_ get along.
# REGEX -- create regular expression functions
cat << EOF > config.h
#define FKEYS
#define REGEX
#define XKEYS
#ifndef LOGIN_NAME_MAX
#define MAXLOGNAME _POSIX_LOGIN_NAME_MAX
#endif
#ifndef MAXLOGNAME
#define MAXLOGNAME LOGIN_NAME_MAX
#endif
EOF
exec 3> config.log
# Checks to see if GCC defines a given macro and returns true if it does.
gcc_defines()
{
DEFSTR=$1
cat << EOF > testfile.c
#include <stdio.h>
int main(void)
{
#ifdef ${DEFSTR}
garbage that will make gcc fail
#endif
return 0;}
EOF
! ${CC:-gcc} -Wall testfile.c -o testfile 2>&3
}
note 'internal arc4random'
cat << EOF > testfile.c
#include <stdlib.h>
int main(void)
{arc4random();return 0;}
EOF
if ${CC:-gcc} testfile.c -o testfile 2>&3; then
echo Found.
add_inc HAVE_ARC4RANDOM
else
echo Not Found.
note 'external arc4random'
cat << EOF > testfile.c
#include <stdlib.h>
#include <arc4random.h>
int main(void)
{arc4random();return 0;}
EOF
if ${CC:-gcc} -larc4random testfile.c -o testfile 2>&3; then
echo Found.
add_inc HAVE_ARC4RANDOM_EXT
extralibs="$extralibs -larc4random"
else
echo Not Found.
fi
fi
note 'strtonum'
cat << EOF > testfile.c
#include <stdlib.h>
#include <limits.h>
int main(void)
{strtonum(NULL, 1, 1, NULL);return 0;}
EOF
if ${CC:-gcc} -Wall testfile.c -o testfile 2>&3; then
echo 'Found.'
else
echo 'Not Found, adding.'
add_inc HAVE_NOSTRTONUM
extraobjs="$extraobjs strtonum.o"
fi
note 'strlcpy'
cat << EOF > testfile.c
#include <string.h>
int main(void)
{strlcpy(NULL, NULL, 1);return 0;}
EOF
if ${CC:-gcc} -Wall testfile.c -o testfile 2>&3; then
echo 'Found.'
else
echo 'Not Found, adding.'
add_inc HAVE_NOSTRLCPY
extraobjs="$extraobjs strlcpy.o"
fi
note 'strlcat'
cat << EOF > testfile.c
#include <string.h>
int main(void)
{strlcat(NULL, NULL, 1);return 0;}
EOF
if ${CC:-gcc} -Wall testfile.c -o testfile 2>&3; then
echo 'Found.'
else
echo 'Not Found, adding.'
add_inc HAVE_NOSTRLCAT
extraobjs="$extraobjs strlcat.o"
fi
note 'fgetln'
cat << EOF > testfile.c
#include <stdio.h>
int main(void)
{fgetln(NULL, NULL);return 0;}
EOF
if ${CC:-gcc} -Wall testfile.c -o testfile 2>&3; then
echo 'Found.'
else
echo 'Not Found, adding.'
add_inc HAVE_NOFGETLN
extraobjs="$extraobjs fgetln.o"
fi
# With -O2 or higher you get a warning for strict-aliasing on
# some versions of gcc.
echo -n 'Testing for strict aliasing... '
echo 'Testing for strict aliasing... ' >&3
cat << EOF > testfile.c
int main(void)
{return 0;}
EOF
if ${CC:-gcc} -Wno-strict-aliasing testfile.c -o testfile 2>&3; then
echo 'Works OK.'
extraflags="$extraflags -Wno-strict-aliasing"
else
echo 'Fails.'
fi
if [ ! -r /usr/include/term.h ]; then
note 'term.h'
if [ -r /usr/include/ncurses/term.h ]; then
echo "Found in /usr/include/ncurses"
extraflags="$extraflags -I/usr/include/ncurses"
else
for i in pkg local; do
if [ -r /usr/$i/include/term.h ]; then
echo "Found in /usr/$i/include"
extralibs="$extralibs -L/usr/$i/lib"
extraflags="$extraflags -I/usr/$i/include"
break
else
false
fi
done ||
{
echo 'Not found!' >&2
echo 'Do you have the ncurses devel package installed?' >&2
echo 'If you know where term.h is, please email the author!' >&2
exit 1
}
fi
fi
note 'base and dirname'
if gcc_defines "__GLIBC__" || gcc_defines "__CYGWIN__" ; then
echo 'Not present, adding.'
extraobjs="$extraobjs dirname.o basename.o"
else
echo 'Present on this system.'
fi
note 'version'
if ls --version > testfile.o 2>&3; then
echo 'GNU ls'
add_inc GNU_LS
else
echo 'Other ls'
fi
note '.exe extension'
cat << EOF > testfile.c
int main(void)
{return 0;}
EOF
if ${CC:-gcc} -Wall testfile.c -o testfile 2>&3; then
if [ -x testfile.exe ]; then
echo 'Yes.'
exe_ext='.exe'
else
echo 'No.'
exe_ext=''
fi
else
echo 'Could not test for .exe extension!' >&2
exit 1
fi
# Suppress DLL auto-import error when linking on Cygwin
if uname -s | grep -q '^CYGWIN' ; then
extralibs="$extralibs -Wl,--enable-auto-import -Wno-char-subscripts"
fi
rm testfile*
sed -e "s|@extraflags@|$extraflags|" \
-e "s|@extralibs@|$extralibs|" \
-e "s|@extraobjs@|$extraobjs|" \
-e "s|@exe_ext@|$exe_ext|" \
Makefile.in > Makefile
echo "OK, now run \`make'."
|