-
Notifications
You must be signed in to change notification settings - Fork 7
/
configure
executable file
·466 lines (397 loc) · 13.3 KB
/
configure
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
#!/bin/sh
# This script was automatically generated by ACR v0.9.4
# @author: pancake <youterm.com>
# @url: http://www.nopcode.org
# @repo: hg clone http://hg.youterm.com/acr
do_remove() {
if [ "${ACR_RMFILES}" ]; then
printf "cleaning temporally files... "
rm -f ${ACR_RMFILES}
echo "done"
fi
}
control_c() {
printf "\n\n^C control-c : script execution interrupted.\n"
do_remove
exit 1
}
trap control_c 2
printf "checking for cpp... "
if [ "${CROSSBUILD}" = 1 ]; then
(exec ${HOST}-${CPP} --help >/dev/null 2>&1)
[ $? = 0 ] && CPP="${HOST}-${CPP}"
fi
(echo "main(){}" | ${CPP} >/dev/null 2>&1)
if [ $? = 0 ]; then echo ${CPP}; else
echo "ERROR: ${CPP} cannot parse sources"; fi
split_host() {
S="$"
while : ; do
ENVWORDS="${ENVWORDS} $1_CPU $1_OS"
STR=`eval "echo ${S}$1"`
SPLIT_CPU="`echo "$STR" | cut -d - -f 1`"
SPLIT_OS="`echo "$STR" | awk -F - '{if(NF==4){print $4}else{print $2}}'`"
eval "$1_CPU=\"$SPLIT_CPU\""
eval "$1_OS=\"$SPLIT_OS\""
shift
[ -z "$1" ] && break
done
}
VPATH=`dirname ${0}`
if [ "${VPATH}" = "." ]; then
WODIS=current
else
if [ "${VPATH}" = "${PWD}" ]; then
VPATH=.
WODIS=current
else
WODIS=crosspath
CURDIR=$PWD
cd $VPATH
VPATH="${PWD}/"
cd $CURDIR
fi
fi
guess_os() {
if [ -e "${VPATH}/config.guess" ]; then
sh ${VPATH}/config.guess
return
fi
CPU="`uname -m|sed -e 's, ,,g'|cut -d - -f 1`"
OS="`uname -s|tr A-Z a-z`"
GNU="`uname --help 2>&1 | grep gnu`"
[ "${GNU}" ] && OS="${OS}-gnu"
[ "${CPU}" = ppc ] && CPU="powerpc"
echo "${CPU}-unknown-${OS}"
}
SEARCHPATH="/usr /usr/local /usr/pkg /sw"
: ${PREFIX:=/usr/local}
CROSSBUILD=0
BUILD=`guess_os`
HOST="${BUILD}"
TARGET="${HOST}"
SYSCONFDIR=""
create_environ() {
: ${EPREFIX:=${PREFIX}}
: ${SPREFIX:=${PREFIX}}
: ${BINDIR:=${SPREFIX}/bin}
: ${SBINDIR:=${PREFIX}/sbin}
: ${SYSCONFDIR:=${SPREFIX}/etc}
: ${LIBDIR:=${SPREFIX}/lib}
: ${LIBEXECDIR:=${SPREFIX}/libexec}
: ${INCLUDEDIR:=${SPREFIX}/include}
: ${DATADIR:=${SPREFIX}/share}
: ${INFODIR:=${DATADIR}/info}
: ${MANDIR:=${DATADIR}/man}
: ${LOCALSTATEDIR:=${SPREFIX}/var}
for A in `echo ${PATH} | sed -e 's,:, ,g'` ; do
[ -e $A/ginstall ] && : ${INSTALL:=$A/ginstall} && break
[ -e $A/install ] && : ${INSTALL:=$A/install} && break
done
: ${INSTALL_DIR:=${INSTALL} -d}
: ${INSTALL_DATA:=${INSTALL} -m 644}
: ${INSTALL_SCRIPT:=${INSTALL} -m 755}
: ${INSTALL_PROGRAM:=${INSTALL} -m 755}
: ${INSTALL_PROGRAM_STRIP:=${INSTALL} -m 755 -s}
: ${INSTALL_MAN:=${INSTALL} -m 444}
: ${INSTALL_LIB:=${INSTALL} -c}
PKGNAME='tudu' ; VERSION='0.10.4' ; CONTACT_MAIL="[email protected]" ; CONTACT_NAME="Ruben Pollan" ; CONTACT="Ruben Pollan <[email protected]>" ;
}
show_usage() {
cat <<EOF2
'configure' configures tudu-0.10.4 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
-V, --version display version information and exit
-r, --report show what libs/programs require to work
Installation directories:
--prefix=PREFIX install arch-independent files in PREFIX [/usr/local]
--exec-prefix=EPREFIX install arch-dependent files in EPREFIX [PREFIX]
--sandbox=SPREFIX sandbox prefix directory: SPREFIX [PREFIX]
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--infodir=DIR info documentation [DATADIR/info]
--mandir=DIR man documentation [DATADIR/man]
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
EOF2
printf "
Some influential environment variables:
CXX C++ compiler command
CXXFLAGS C++ compiler flags
"
printf "
Report bugs to: Ruben Pollan <[email protected]>"
echo ""
exit 0
}
take_environ() {
: ${SH:=/bin/sh}
: ${CPP:=cpp}
: ${CXX:=g++}
: ${PREFIX:=/usr/local/}
}
show_version() {
echo "tudu-0.10.4 configuration script done with acr v0.9.4.
The 'Free Software Foundation' message is only for autodetection.
Originally written by pancake <youterm.com>."
exit 0
}
parse_options() {
flag=`echo $1| cut -d = -f 1`
value=`echo $1| awk 'BEGIN{FS="=";}{print $2}'`
flag2=`echo $flag|cut -f2- -d -| sed -e 's,-,_,g' -e 's,^_,,g'|tr '[a-z]' '[A-Z]'`
if [ "${TARGET_OS}" = "darwin" ]; then
LIBPATH=-Wl,-install_name,
else
LIBPATH=-Wl,-R
fi
case $flag in
"-h"|"--help"|"--hel"|"--h"|"--he"|"-help")
show_usage ; ;;
"-V"|"-version"|"--version")
show_version ; ;;
"-r"|"--r"|"--report")
echo "PKGNAME: tudu"
echo "VERSION: 0.10.4"
echo "LANGS: c++"
echo "OPTIONAL: libncursesw"
exit 0
;;
"--cache-file")
# ignored: acr have no cache
;;
"--build")
BUILD="$value"; split_host BUILD ; ;;
"--host")
CROSSBUILD=1 # XXX
HOST="$value"; split_host HOST ; ;;
"--target")
TARGET="$value"; split_host TARGET ; ;;
"--prefix")
PREFIX="$value"; ;;
"--exec-prefix")
EPREFIX="$value"; ;;
"--sandbox"|"--sprefix")
SPREFIX="$value"; ;;
"--bindir")
BINDIR="$value"; ;;
"--sbindir")
SBINDIR="$value"; ;;
"--libexecdir")
LIBEXECDIR="$value"; ;;
"--datadir")
DATADIR="$value"; ;;
"--sysconfdir")
SYSCONFDIR="$value"; ;;
"--sharedstatedir")
SHAREDSTATEDIR="$value"; ;;
"--localstatedir")
LOCALSTATEDIR="$value"; ;;
"--libdir")
LIBDIR="$value"; LDFLAGS="${LDFLAGS} -L$value ${LIBPATH}$value"; ;;
"--includedir")
INCLUDEDIR="$value"; CFLAGS="${CFLAGS} -I$value"; ;;
"--infodir")
INFODIR="$value"; ;;
"--mandir")
MANDIR="$value"; ;;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
else echo ; echo "WARNING: Unknown flag '$flag'." >&2 ; echo ; fi ;;
esac
}
# MAIN #
take_environ
split_host BUILD HOST TARGET
[ -z "$ACRHOOK" ] && ACRHOOK=./configure.hook
[ -e "$ACRHOOK" ] && . ${ACRHOOK}
while : ; do
[ -z "$1" ] && break
parse_options $1
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL YEAR CXX CXXFLAGS LDFLAGS HAVE_LANG_CXX CPP CPPFLAGS SRCS HAVE_XCURSES_H HAVE_NCURSESW_CURSES_H HAVE_NCURSES_CURSES_H HAVE_NCURSES_H HAVE_CURSES_H CURSES_INCLUDE HAVE_LIB_NCURSESW HAVE_LIB_NCURSES HAVE_LIB_CURSES LD_CURSES WIDEC_CURSES HAVE_STRING HAVE_VECTOR HAVE_MAP HAVE_FSTREAM HAVE_LIST HAVE_STACK HAVE_ALGORITHM HAVE_SET HAVE_CTIME HAVE_CSTRING HAVE_CSIGNAL HAVE_CSTDIO HAVE_CSTDLIB HAVE_SYS_TYPES_H HAVE_SYS_WAIT_H HAVE_SYS_STAT_H HAVE_UNISTD_H HAVE_FCNTL_H HAVE_LOCALE HAVE_CWCHAR HAVE_CLOCALE HAVE_CLIMITS HAVE_IOSTREAM HAVE_IOMANIP HAVE_SSTREAM HAVE_CERRNO"
create_environ
echo "checking build system type... ${BUILD}"
echo "checking host system type... ${HOST}"
echo "checking target system type... ${TARGET}"
[ "${CROSSBUILD}" = 1 ] && echo "using crosscompilation mode."
#split_host BUILD HOST TARGET
[ -n "${prefix}" ] && PREFIX=${prefix}
echo "checking for working directories... ${WODIS}"
echo "using prefix '${PREFIX}'"
ACR_RMFILES=" test.c test.cxx a.out a.exe"
:
YEAR="2020"
COMPILER=CXX
HAVE_LANG_CXX=1
printf "checking for c++ compiler... "
if [ "${CROSSBUILD}" = 1 ]; then
(command -v ${HOST}-${CXX} 2>&1 >/dev/null)
if [ "$?" = 0 ]; then CXX="${HOST}-${CXX}"; fi
fi
echo "#include <iostream>" > test.cxx
echo "main(){ std::cout << 1; }" >> test.cxx
(exec ${CXX} ${CXXFLAGS} ${LDFLAGS} test.cxx -lstdc++ >/dev/null 2>&1)
if [ $? = 0 ]; then echo ${CXX}; else
HAVE_LANG_CXX=0
echo no
echo "ERROR: ${CXX} cannot create executables" >&2 ;
do_remove
exit 1
fi
CXXFLAGS="${CXXFLAGS} -Wall -O2"
CPPFLAGS="${CPPFLAGS} "
SRCS="${SRCS} tudu.cc data.cc editor.cc interface.cc window.cc text.cc parser.cc config.cc date.cc screen.cc scheduler.cc cmd.cc"
check_include() {
VAR=$1
INC=$2
_REQUIRED=$3
printf "checking for $2... "
echo > test.c
echo "#include <${INC}>" >>test.c
echo "main(){}" >>test.c
eval \$${COMPILER} ${CFLAGS} ${CPPFLAGS} ${CXXFLAGS} test.c >/dev/null 2>&1
if [ $? = 0 ]; then
eval ${VAR}=1
echo yes
else
eval ${VAR}=0
echo no ; fi }
check_include HAVE_XCURSES_H xcurses.h 0
check_include HAVE_NCURSESW_CURSES_H ncursesw/curses.h 0
check_include HAVE_NCURSES_CURSES_H ncurses/curses.h 0
check_include HAVE_NCURSES_H ncurses.h 0
check_include HAVE_CURSES_H curses.h 0
if [ "$HAVE_XCURSES_H" = "1" ]; then
CURSES_INCLUDE="xcurses.h"; fi
if [ "$HAVE_NCURSESW_CURSES_H" = "1" ]; then
[ -z "${CURSES_INCLUDE}" ] && CURSES_INCLUDE="ncursesw/curses.h"; fi
if [ "$HAVE_NCURSES_CURSES_H" = "1" ]; then
[ -z "${CURSES_INCLUDE}" ] && CURSES_INCLUDE="ncurses/curses.h"; fi
if [ "$HAVE_NCURSES_H" = "1" ]; then
[ -z "${CURSES_INCLUDE}" ] && CURSES_INCLUDE="ncurses.h"; fi
if [ "$HAVE_CURSES_H" = "1" ]; then
[ -z "${CURSES_INCLUDE}" ] && CURSES_INCLUDE="curses.h"; fi
if [ "$CURSES_INCLUDE" = "" ]; then
case "$undefined_variable" in 0|"") echo ; echo "ERROR: There is no curses installed!" >&2 ; echo ; exit 1 ;; esac; fi
check_library() {
VAR=$1
S="$"
_REQUIRED=$3
_CHKLIB_NAME=$2
_CHKLIB_LIBS=$(echo "-l${_CHKLIB_NAME}" | sed 's,\+, -l,g')
printf "checking for lib${_CHKLIB_NAME} ... "
echo "main(){ }" > test.c
eval ${S}${COMPILER} ${CFLAGS} ${CPPFLAGS} ${CXXFLAGS} ${LDFLAGS} ${_CHKLIB_LIBS} test.c >/dev/null 2>&1
if [ $? = 0 ]; then
eval ${VAR}=1
echo yes
else
eval ${VAR}=0
echo no ; fi }
check_library HAVE_LIB_NCURSESW ncursesw 0
check_library HAVE_LIB_NCURSES ncurses 0
check_library HAVE_LIB_CURSES curses 0
if [ "$HAVE_LIB_NCURSESW" = "1" ]; then
LD_CURSES="-lncursesw"; fi
if [ "$HAVE_LIB_NCURSES" = "1" ]; then
[ -z "${LD_CURSES}" ] && LD_CURSES="-lncurses"; fi
if [ "$HAVE_LIB_CURSES" = "1" ]; then
[ -z "${LD_CURSES}" ] && LD_CURSES="-lcurses"; fi
if [ "$LD_CURSES" = "" ]; then
case "$undefined_variable" in 0|"") echo ; echo "ERROR: There is no curses installed!" >&2 ; echo ; exit 1 ;; esac; fi
LDFLAGS="${LDFLAGS} $LD_CURSES"
printf "checking for WIDEC_CURSES... "
echo "#define _XOPEN_SOURCE_EXTENDED" > test.c ; echo "#include<$CURSES_INCLUDE>" >> test.c ; echo "int main(){ addwstr(L\"\"); }" >> test.c ; eval \$${COMPILER} ${CXXFLAGS} test.c ${LDFLAGS} >/dev/null 2>&1 ; WIDEC_CURSES=$? ; rm test.c
if [ "$WIDEC_CURSES" = 0 ]; then
WIDEC_CURSES=1
echo yes
else
WIDEC_CURSES=0
echo no
fi
if [ "$WIDEC_CURSES" = "0" ]; then
case "$undefined_variable" in 0|"") echo ; echo "ERROR: There is no wide character support on curses!" >&2 ; echo ; exit 1 ;; esac; fi
check_include HAVE_STRING string 1
check_include HAVE_VECTOR vector 1
check_include HAVE_MAP map 1
check_include HAVE_FSTREAM fstream 1
check_include HAVE_LIST list 1
check_include HAVE_STACK stack 1
check_include HAVE_ALGORITHM algorithm 1
check_include HAVE_SET set 1
check_include HAVE_CTIME ctime 1
check_include HAVE_CSTRING cstring 1
check_include HAVE_CSIGNAL csignal 1
check_include HAVE_CSTDIO cstdio 1
check_include HAVE_CSTDLIB cstdlib 1
check_include HAVE_SYS_TYPES_H sys/types.h 1
check_include HAVE_SYS_WAIT_H sys/wait.h 1
check_include HAVE_SYS_STAT_H sys/stat.h 1
check_include HAVE_UNISTD_H unistd.h 1
check_include HAVE_FCNTL_H fcntl.h 1
check_include HAVE_LOCALE locale 1
check_include HAVE_CWCHAR cwchar 1
check_include HAVE_CLOCALE clocale 1
check_include HAVE_CLIMITS climits 1
check_include HAVE_IOSTREAM iostream 1
check_include HAVE_IOMANIP iomanip 1
check_include HAVE_SSTREAM sstream 1
check_include HAVE_CERRNO cerrno 1
SEDFLAGS=" -e '"
COUNT=0
for A in ${ENVWORDS} ; do
[ "${A}" = VPATH ] && continue
[ "${A}" = srcdir ] && continue
eval "VAR=\$${A}"
VAR="`echo ${VAR} | sed -e 's/\,/\\\,/g'`"
[ $COUNT = 10 ] && COUNT=0 && SEDFLAGS="${SEDFLAGS}' -e '"
COUNT=$(($COUNT+1))
SEDFLAGS="${SEDFLAGS}s,@${A}@,${VAR},g;"
done
SEDFLAGS="${SEDFLAGS}'"
for A in . src data src/defs.h ; do # SUBDIRS
if [ -f "${VPATH}/${A}.acr" ]; then
SD_TARGET=${A}
else
if [ -d "${VPATH}/${A}" ]; then
SD_TARGET=${A}/Makefile
mkdir -p ${A}
else
echo "ERROR: Cannot find ${VPATH}/${A}.acr" >&2
exit 1
fi
fi
echo "creating ${SD_TARGET}"
mkdir -p $(echo ${A} | sed -e "s,/`basename ${A}`$,,g")
cat ${VPATH}/${SD_TARGET}.acr | \
eval sed -e "s,@VPATH@,${VPATH}/${A},g" ${SEDFLAGS} > ${SD_TARGET}.tmp
for A in ${ENVWORDS}; do
VALUE=`eval echo "$"${A}`
if [ "$VALUE" = 0 ]; then ## FALSE
MARK="##${A}##"
if [ -n "`grep \"${MARK}\" ${SD_TARGET}.tmp`" ]; then
mv ${SD_TARGET}.tmp ${SD_TARGET}.tmp2
cat ${SD_TARGET}.tmp2 | MARK=$MARK awk 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){if(a)a=0;else a=1}else{if(!a)print;}}' > ${SD_TARGET}.tmp
fi
fi
done
mv ${SD_TARGET}.tmp ${SD_TARGET} && rm -f ${SD_TARGET}.tmp2
if [ ! $? = 0 ]; then echo Cannot write target file ; control_c ; fi
done
do_remove