File: configure

package info (click to toggle)
mg 20070918-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 664 kB
  • ctags: 892
  • sloc: ansic: 12,205; sh: 148; makefile: 81; modula3: 7
file content (200 lines) | stat: -rwxr-xr-x 4,096 bytes parent folder | download
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
#!/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

note 'internal arc4random'
cat << EOF > testfile.c
#include <stdlib.h>
int main(void)
{arc4random();return 0;}
EOF
if 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 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 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 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 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 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 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'
    for i in pkg local; do
	if [ -e /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
	fi
	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
    done
fi

note 'glibc'
cat << EOF > testfile.c
#include <stdio.h>
int main(void)
{
#ifdef __GLIBC__
garbage that will make gcc fail
#endif
return 0;}
EOF
if gcc -Wall testfile.c -o testfile 2>&3; then
    echo 'Not on this system'
else
    echo 'found, adding base and dirname.'
    extraobjs="$extraobjs dirname.o basename.o"
fi


note 'version'
if ls --version > testfile.o 2>&3; then
    echo 'GNU ls'
    add_inc GNU_LS
else
    echo 'Other ls'
fi


rm testfile*

sed -e "s|@extraflags@|$extraflags|" \
    -e "s|@extralibs@|$extralibs|" \
    -e "s|@extraobjs@|$extraobjs|" \
    Makefile.in > Makefile

echo "OK, now run \`make'."