-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·763 lines (696 loc) · 19.6 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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
#!/bin/bash
#
# symlookup configure script
# Copyright © 2007-2011 Andrew Savchenko
#
# This file is part of symlookup.
#
# symlookup is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation
#
# symlookup is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License version 3 for more details.
#
# You should have received a copy of the GNU General Public License version 3
# along with symlookup. If not, see <http://www.gnu.org/licenses/>.
#
# This script is inspired by ideas of hand-made FFmpeg and MPlayer
# configure scripts, but their code is not used in current version.
# See AUTHORS in the source tree for details.
#
export LANG=C
display_help(){
cat << EOF
Usage: $0 [options...]
Installation directories:
--destdir=DIR use custom destination directory
--prefix=DIR prefix directory for installation [/usr/local]
--bindir=DIR directory for binaries installation [\$prefix/bin]
--datadir=DIR directory for program data installation [\$prefix/share]
--docdir=DIR directory for program documentation installation [\$datadir/doc/symlookup]
--mandir=DIR directory for manual page installation [\$datadir/man]
External libraries support:
--disable-rpm disable rpm support [autodetect]
--enable-rpm enable rpm4 support [autodetect]
--enable-rpm5 enable rpm5 support [autodetect]
--disable-portage disable portage support [autodetect]
--incdir-elf=DIR use custom include dir for libelf
--incdir-rpm=DIR use custom include dir for librpm
--libdir-elf=DIR use custom library dir for libelf
--libdir-rpm=DIR use custom library dir for librpm
Compilation options:
--cc=COMPILER use custom C compiler [gcc]
--strip=STRIP use custom strip program [strip]
--cpu=CPU specify target cpu [autodetect]
--enable-debug compile with full debug data [disabled]
--enable-cflags honor CFLAGS enviroment variable [disabled]
--disable-strip do not strip binaries [enabled]
Useful eviromental variables:
CFLAGS tweak compiler flags (overrides optimization defaults and --cpu,
but disabled by default: autodetection should work fine)
LDFLAGS additional linker flags
DESTDIR use custom destination directory (overrided by --destdir)
prefix use custom prefix for destination directory (overrided by --prefix)
bindir use custom binaries directory (overrided by --bindir)
docdir use custom documentation directory (overrided by --docdir)
mandir use custom manuals directory (overrided by --mandir)
EOF
exit
}
# echo to both stdout and log
echolog(){
echo "$@"
echo "$@" >> $_logfile
}
# echo to logfile only
log(){
echo "$@" >> $_logfile
}
# check start routine
echocheck(){
echo -n "Checking for $@ ... "
log
log "============ Checking for $@ ============"
}
# test result routine
echores(){
echo "$@"
log "Result is: $@"
}
# show error message, cleanup and exit
error(){
printf "$@""\n"
printf "$@""\n" >> $_logfile
rm -f $_tmpfile
exit 1
}
# common part of gcc tests
gcc_check_common(){
# cat source to logfile
cat $_tmpfile >> $_logfile
log
log $_cc $_tmpfile -o ${_tmpfile}_elf "$@"
$_cc $_tmpfile -o ${_tmpfile}_elf "$@" >>$_logfile 2>&1
res="$?"
log
return $res
}
# generic gcc compilation test
gcc_check(){
gcc_check_common "$@"
rm -f ${_tmpfile}_elf
return $res
}
# check compilation and performance
runtime_check(){
gcc_check_common "$@" || return $res
log
log "==> Running '${_tmpfile}_elf':"
${_tmpfile}_elf >>$_logfile 2>&1
res="$?"
[[ $res == 0 ]] && log "<== succeed" || log "<== failed"
log
return $res
}
# gcc cpu parameters test
cpu_test(){
gcc_check -march=$_cpu
return "$?"
}
# library parameters test
lib_test(){
gcc_check $_cflags "$@"
return "$?"
}
# cpu autodetection
cpu_detect(){
# check for sse support
echocheck "sse support"
_sse="no"
[[ -n "`grep flags /proc/cpuinfo | grep sse`" ]] && {
_sse="yes";
[[ $_enable_debug == "no" && $_enable_cflags == "no" ]] && {
#this is experimental, but try it anyway
_cflags="$_cflags $_sse_flags"
}
}
echores $_sse
# gcc >= 4.2.0 supports 'native' target,
# so cpu autodetection isn't required
[[ _gcc_ver -ge 4 && _gcc_maj -ge 2 ]] && {
_cpu="native"
return
}
# Check for sse3 support.
# Unfortunately, /proc/cpuinfo is insufficient and x86info is not
# widely installed.
echocheck "sse3 support"
_sse3="(skipped)"
[[ $_sse == "yes" ]] && {
_sse3="no"
cat << EOF > $_tmpfile
#include <signal.h>
#include <stdlib.h>
// catch sigill
void handler(int signum) {
exit(1);
}
int main() {
signal(SIGILL, handler);
__asm__ __volatile__ ("addsubpd %%xmm0, %%xmm1":::"memory");
return 0;
}
EOF
runtime_check && _sse3="yes"
}
echores $_sse3
cpu_vendor=`gawk '{if ($1=="vendor_id") {print $3; exit}}' /proc/cpuinfo`
cpu_family=`gawk '{if (index($0,"cpu family") == 1) {print $4; exit}}' /proc/cpuinfo`
cpu_model=`gawk '{if ($1=="model") {print $3; exit}}' /proc/cpuinfo`
# there is no need to support CPU after gcc >= 4.2.0, thus native
# will be used in such cases
case $cpu_vendor in
AuthenticAMD)
case $cpu_family in
3) _cpu="i386"
;;
4) _cpu="i486"
;;
5)
if [[ cpu_model -le 4 ]]
then _cpu="i586"
elif [[ cpu_model -le 7 ]]
then _cpu="k6"
else
_cpu="k6-2"
fi
;;
6)
# select by sse support
if [[ $_sse == "no" ]]
then _cpu="athlon"
else
_cpu="athlon-xp"
fi
;;
15) _cpu="k8"
[[ $_sse3 == "yes" ]] && _cpu="k8-sse3"
;;
16) _cpu="amdfam10"
;;
esac
;;
GenuineIntel)
case $cpu_family in
3) _cpu="i386"
;;
4) _cpu="i486"
;;
5)
if [[ cpu_model == 4 || cpu_model == 8 ]]
then _cpu="pentium-mmx"
esle
_cpu="pentium"
fi
;;
6)
if [[ cpu_model -le 2 ]]
then _cpu="pentiumpro"
elif [[ cpu_model -le 6 ]]
then _cpu="pentium2"
elif [[ cpu_model -ge 15 ]]
then _cpu="core2"
elif [[ cpu_model == 9 || cpu_model -ge 13 ]]
then _cpu="pentium-m"
else
_cpu="pentium3"
fi
;;
15)
if [[ cpu_model -le 2 ]]
then _cpu="pentium4"
elif [[ cpu_model == 3 ]]
then _cpu="prescott"
else
_cpu="nocona"
fi
esac
;;
CentaurHauls)
case $cpu_family in
5)
if [[ cpu_model -le 3 ]]
then _cpu="i586"
elif [[ cpu_model -le 7 ]]
then _cpu="winchip-c6"
else
_cpu="winchip2"
fi
;;
6)
if [[ cpu_model -le 8 ]]
then _cpu="c3"
else
_cpu="c3-2"
fi
;;
esac
;;
*)
case $cpu_family in
3) _cpu="i386"
;;
4) _cpu="i486"
;;
5) _cpu="i586"
;;
6) _cpu="i686"
;;
esac
;;
esac
### check -march option,
# old compilers may not support some options
# suppose any compiler understand i[3456]86
printf "int main() {return 0;}\n" > $_tmpfile
# AMD branch
if [[ $_cpu == "amdfam10" ]]
then cpu_test || _cpu="k8-sse3"
fi
if [[ $_cpu == "k8-sse3" ]]
then cpu_test || _cpu="k8"
fi
if [[ $_cpu == "k8" ]]
then cpu_test || _cpu="athlon-xp"
fi
if [[ $_cpu == "athlon-xp" ]]
then cpu_test || _cpu="athlon"
fi
if [[ $_cpu == "athlon" ]]
then cpu_test || _cpu="k6-2"
fi
if [[ $_cpu == "k6-2" ]]
then cpu_test || _cpu="k6"
fi
if [[ $_cpu == "k6" ]]
then cpu_test || _cpu="i686"
fi
# Intel branch
if [[ $_cpu == "core2" ]]
then cpu_test || _cpu="nocona"
fi
if [[ $_cpu == "nocona" ]]
then cpu_test || _cpu="prescott"
fi
if [[ $_cpu == "prescott" ]]
then cpu_test || _cpu="pentium4"
fi
if [[ $_cpu == "pentium4" ]]
then cpu_test || _cpu="pentium-m"
fi
if [[ $_cpu == "pentium-m" ]]
then cpu_test || _cpu="pentium3"
fi
if [[ $_cpu == "pentium3" ]]
then cpu_test || _cpu="pentium2"
fi
if [[ $_cpu == "pentium2" ]]
then cpu_test || _cpu="i686"
fi
# Centaur (VIA) branch
if [[ $_cpu == "c3-2" ]]
then cpu_test || _cpu="c3"
fi
if [[ $_cpu == "c3" ]]
then cpu_test || _cpu="winchip2"
fi
if [[ $_cpu == "winchip2" ]]
then cpu_test || _cpu="winchip-c6"
fi
if [[ $_cpu == "winchip-c6" ]]
then cpu_test || _cpu="i586"
fi
# Fallback test if CPU is misdetected (e.g. some new CPU)
if [[ $_cpu == "i686" ]] || [[ $_cpu == "i686" ]]
then cpu_test || _cpu_t="generic"
fi
}
#temporary file
_tmpfile=`mktemp /tmp/symlookup-configure.XXXXXXXXX`
mv -f $_tmpfile ${_tmpfile}.c
_tmpfile=${_tmpfile}.c
#logfile
_logfile="configure.log"
# log initial environments
printf "$0 $*\n\n" > $_logfile
log Recognized environmental variables:
log CC=$CC
log CFLAGS=$CFLAGS
log LDFLAGS=$LDFLAGS
log DESTDIR=$DESTDIR
log prefix=$prefix
log bindir=$bindir
log datadir=$datadir
log docdir=$docdir
log mandir=$mandir
### setup defaults
#directories
_destdir=${DESTDIR}
_prefix=${prefix:="/usr/local"}
_bindir=${bindir}
_datadir=${datadir}
_docdir=${docdir}
_mandir=${mandir}
_bindir_suff="/bin"
_datadir_suff="/share"
_docdir_suff="/doc"
_mandir_suff="/man"
#libraries (auto|yes|no)
_enable_rpm="auto"
_enable_portage="auto"
_incdir_elf=""
_incdir_rpm="-I/usr/include/rpm"
_libdir_elf=""
_libdir_rpm=""
LDFLAGS="$LDFLAGS -Wl,-O1"
unset _incflags
unset _have_rpm
unset _have_portage
#compilation
_cc=${CC:="gcc"}
_strip="strip"
_cpu_t="auto"
unset _cpu
_enable_debug="no"
_enable_cflags="no"
### CFLAGS
_cflags="--std=gnu99 -Wall -D_GNU_SOURCE"
_optflags="-O2 -funswitch-loops -fgcse-after-reload -fomit-frame-pointer -pipe"
# tree-vectorize is broken on x86
_optflags_x86_64="-ftree-vectorize"
# gcc-4.3
_optflags_gcc43="-fpredictive-commoning"
# gcc-4.4 (-floop-block is broken and fixed only in 4.5)
_optflags_gcc44="-ftree-loop-linear -floop-interchange -floop-strip-mine"
# for old gcc versions
_optflags_old="-O2 -pipe"
# sse fpu flags
_sse_flags="-mfpmath=sse"
# other
_strip_flags="-s"
_debugflags="-ggdb3 -pipe"
_libelf_flags="-lelf"
_librpm_flags="-lrpm"
# parse command line options
for ((i=1; i<=$#; i++ )); do
optarg="${!i#*=}"
case "${!i}" in
--destdir=*) _destdir="$optarg"
;;
--prefix=*) _prefix="$optarg"
;;
--bindir=*) _bindir="$optarg"
;;
--datadir=*) _datadir="$optarg"
;;
--docdir=*) _docdir="$optarg"
;;
--mandir=*) _mandir="$optarg"
;;
--disable-rpm) _enable_rpm="no"
;;
--enable-rpm) _enable_rpm="yes"
;;
--enable-rpm5) _enable_rpm="yes_5"
;;
--disable-portage) _enable_portage="no"
;;
--enable-portage) _enable_portage="yes"
;;
--cc=*) _cc="$optarg"
;;
--strip=*) _strip="$optarg"
;;
--incdir-elf=*) _incdir_elf="-I$optarg"
;;
--incdir-rpm=*) _incdir_rpm="-I$optarg"
;;
--libdir-elf=*) _libdir_elf="-L$optarg"
;;
--libdir-rpm=*) _libdir_rpm="-L$optarg"
;;
--cpu=*) _cpu="$optarg"; _cpu_t="manual"
;;
--enable-debug) _enable_debug="yes"
;;
--enable-cflags) _enable_cflags="yes"
;;
--disable-strip) _strip_flags=""
;;
--help) display_help
;;
# ignore unknown options to be compatible with rpm build system
*) echo warning: unrecognized option ["${!i}"]
;;
esac
done
### parameters processing
# destdir and prefix are already setup
# leave prefix for redefinition at runtime in make install
_bindir=${_bindir:='$(prefix)'${_bindir_suff}}
_datadir=${_datadir:='$(prefix)'${_datadir_suff}}
_docdir=${_docdir:='$(datadir)'${_docdir_suff}}
_mandir=${_mandir:='$(datadir)'${_mandir_suff}}
#add strip flags
_optflags="$_optflags $_strip_flags"
# forced cflags
echo -n "Checking for forced CFLAFS ... "
[[ $_enable_cflags == "yes" ]] && _optflags=$CFLAGS
echo $_enable_cflags
# setup debug flags
echo -n "Checking for debug mode ... "
[[ $_enable_debug == "yes" ]] && {
_optflags=$_debugflags
[[ $_enable_cflags == "yes" ]] && _optflags="$CFLAGS $_debugflags"
}
echo $_enable_debug
# check gcc_version
echocheck "gcc version"
gcc_version=`$_cc -v 2>&1 | gawk '{ if (index($0,"gcc version") == 1) print $3 }'`
[[ -z $gcc_version ]] && \
error "Fatal: compiler \"$_cc\" was not found on your system!"
_gcc_ver=`echo $gcc_version | gawk -F '.' '{ print $1 }'`
_gcc_maj=`echo $gcc_version | gawk -F '.' '{ print $2 }'`
_gcc_min=`echo $gcc_version | gawk -F '.' '{ print $3 }'`
echores ${_gcc_ver}.${_gcc_maj}.${_gcc_min}
# check for different gcc generations when using normal flags
[[ $_enable_debug == "no" && $_enable_cflags == "no" ]] && {
if [[ $_gcc_ver -lt 4 ]];
then
_optflags=$_optflags_old
log "gcc < 4.x detected, engaging old compiler flags"
else
#enable additional optimizations for gcc >= 4.3.0
[[ $_gcc_maj -ge 3 ]] && {
_optflags="$_optflags $_optflags_gcc43"
log "gcc >= 4.3.0 detected, engaging additional compiler flags"
}
[[ $_gcc_maj -ge 4 ]] && {
_optflags="$_optflags $_optflags_gcc44"
log "gcc >= 4.4.0 detected, engaging additional compiler flags"
}
fi
}
# check cpu
if [[ $_cpu_t == "auto" && $_enable_cflags == "no" ]]
then
cpu_detect
else
# Check for predefined CPU SSE support, enable sse if possible.
# Well, it will be no harm to enable it always, but additional
# warning for SSE disabled will be produced.
# Change only if CFLAGS are not overrided.
if [[ $_enable_debug == "no" && $_enable_cflags == "no" &&
# Intel family
$_cpu == "pentium3" || $_cpu == "pentium3m" ||
$_cpu == "pentium-m" ||
$_cpu == "pentium4" || $_cpu == "pentium4m" ||
$_cpu == "prescott" ||
$_cpu == "nocona" ||
$_cpu == "core2" ||
# AMD family
$_cpu == "athlon-4" || $_cpu == "athlon-xp" || $_cpu == "athlon-mp" ||
$_cpu == "k8" || $_cpu == "opteron" || $_cpu == "athlon64" || $_cpu == "athlon-fx" ||
$_cpu == "k8-sse3" || $_cpu == "opteron-sse3" || $_cpu == "athlon64-sse3" ||
$_cpu == "amdfam10" || $_cpu == "barcelona" ]]
then
_cflags="$_cflags $_sse_flags"
fi
fi
echocheck "target architecture"
[[ $_cpu == "native" ]] &&
log "gcc >= 4.2.0 detected, using native architecture"
# In case of forced CFLAGS we have no march at all
# if not specified explicitly and still have zero $_cpu
if [[ -z $_cpu ]]
then
echores "not specified and CFLAGS are forced"
_march=""
else
# Special case for misdetected CPU:
if [[ $_cpu_t == "generic" ]]
then
_march="-mtune=generic"
echores "generic tuning"
echolog "*************************"
echolog "WARNING! You CPU is not detected properly."
echolog "Please use a modern compiler (gcc >= 4.2) and report this bug."
echolog "*************************"
else
echores $_cpu
_march="-march=$_cpu"
fi
fi
# construct final cflags
_cflags="$_cflags $_march $_optflags"
# check if gcc with cflags and cpu type can produce executables
echocheck "compiler can produce executables"
printf "int main() {return 0;}\n" > $_tmpfile
if gcc_check $_cflags;
then
echores yes
else
echores no
str="Your compiler seems to be broken, check your system."
[[ $_enable_cflags == "yes" ]] && str="$str\nOr your CFLAGS are bad."
[[ $_cpu_t == "manual" ]] && str="$str\nOr your CPU type is bad."
error "$str"
fi
### libraries support
# libelf support
echocheck "libelf"
cat << EOF > $_tmpfile
#include <gelf.h>
int main() {
if (elf_version(EV_CURRENT) == EV_NONE)
return 1;
}
EOF
if lib_test $_libelf_flags $_incdir_elf $_libdir_elf;
then
echores yes
else
echores no
error "libelf is mandatory, please install it properly\nor specify correct headers and shared object paths"
fi
_incflags="$_incflags $_incdir_elf"
_libs="$_libs $_libelf_flags $_libdir_elf"
# rpm support
echocheck "librpm"
if [[ $_enable_rpm == "auto" ]]
then
cat << EOF > $_tmpfile
#include <rpmlib.h>
int main() {
rpmSetVerbosity(RPMMESS_FATALERROR);
}
EOF
if lib_test $_librpm_flags $_incdir_rpm $_libdir_rpm;
then
echores "yes (using rpm-4)"
_enable_rpm="yes"
else
# check for rpm v5 support
cat << EOF > $_tmpfile
#include <rpm4compat.h>
int main() {
rpmSetVerbosity(RPMMESS_FATALERROR);
}
EOF
if lib_test $_librpm_flags $_incdir_rpm $_libdir_rpm;
then
echores "yes (using rpm-5)"
_enable_rpm="yes_5"
else
echores no
_enable_rpm="no"
fi
fi
elif [[ $_enable_rpm == "yes" ]]
then
echores "yes (rpm-4 forced by user)"
elif [[ $_enable_rpm == "yes_5" ]]
then
echores "yes (rpm-5 forced by user)"
else
echores "no (forced by user)"
fi
[[ $_enable_rpm == "yes" ]] || [[ $_enable_rpm == "yes_5" ]] && {
_have_rpm="HAVE_RPM = yes"
_cflags="$_cflags -DHAVE_RPM"
_libs="$_libs $_librpm_flags $_libdir_rpm"
[[ $_enable_rpm == "yes_5" ]] && _cflags="$_cflags -DHAVE_RPM_5"
}
# portage support
echocheck "portage"
if [[ $_enable_portage == "auto" ]]
then
log "Checking for /var/db/pkg..."
[[ -d "/var/db/pkg" ]] && {
echores "yes"
_enable_portage="yes"
} || {
echores "no"
_enable_portage="no"
}
elif [[ $_enable_portage == "yes" ]]
then
echores "yes (forced by user)"
else
echores "no (forced by user)"
fi
[[ $_enable_portage == "yes" ]] && {
_have_portage="HAVE_PORTAGE = yes"
_cflags="$_cflags -DHAVE_PORTAGE"
}
### remove temporary file
rm -f $_tmpfile
### create config.mak
#strip only if no debug
echo "Creating config.mak..."
if [[ $_enable_debug == "yes" || -z $_strip_flags ]]
then
_strip_cmd=""
else
_strip_cmd="$_strip --strip-unneeded -R .comment symlookup"
fi
# retrive version from the header
_version=$(gawk '{ if ($2 == "VERSION") printf $3 }' version.h)
cat << EOF > config.mak
####### generated by configure #######
CC=$_cc
STRIP=$_strip_cmd
CFLAGS=$_cflags $_incflags
LDFLAGS=$LDFLAGS
LIBS=$_libs
DESTDIR ?= $DESTDIR
RPM_INCFLAGS = $_incdir_rpm
prefix ?= $_prefix
bindir ?= $_bindir
datadir ?= $_datadir
docdir ?= $_docdir
mandir ?= $_mandir
VERSION=$_version
$_have_rpm
$_have_portage
EOF
# final message
echo
echo "Now type 'make' to compile the program."
echo "If you encounter any configuration problem or misdetection,"
echo "look at the $_logfile."
# remove binary in order to allow recompilation
rm -f symlookup