File: configure

package info (click to toggle)
nspluginwrapper 0.9.91.5-2
  • links: PTS
  • area: contrib
  • in suites: lenny
  • size: 2,236 kB
  • ctags: 21,043
  • sloc: ansic: 43,450; cpp: 1,601; sh: 1,164; makefile: 58
file content (671 lines) | stat: -rwxr-xr-x 18,284 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
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
#!/bin/sh
#
#  nspluginwrapper configure script (C) 2005-2007 Gwenole Beauchesne
#  derived from qemu configure script, (C) 2003 Fabrice Bellard
#
PACKAGE=nspluginwrapper

# set temporary file name
if test ! -z "$TMPDIR" ; then
    TMPDIR1="${TMPDIR}"
elif test ! -z "$TEMPDIR" ; then
    TMPDIR1="${TEMPDIR}"
else
    TMPDIR1="/tmp"
fi

TMPC="${TMPDIR1}/npw-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="${TMPDIR1}/npw-conf-${RANDOM}-$$-${RANDOM}.o"
TMPE="${TMPDIR1}/npw-conf-${RANDOM}-$$-${RANDOM}"
TMPS="${TMPDIR1}/npw-conf-${RANDOM}-$$-${RANDOM}.S"

# default parameters
prefix="/usr"
lib32=""
lib64=""
x_base_dirs=""
biarch="guess"
build_viewer="guess"
linux_only="guess"
cc="gcc -std=c99"
cxx="g++"
host_os=`uname -s | tr '[A-Z]' '[a-z]'`
host_cpu=`uname -m`
target_os="linux"
target_cpu="i386"
case "$host_cpu" in
i386|i486|i586|i686|i86pc|BePC)
    host_cpu="i386"
    ;;
ia64)
    host_cpu="ia64"
    ;;
"Power Macintosh"|ppc)
    host_cpu="ppc"
    ;;
ppc64)
    host_cpu="ppc64"
    ;;
sparc)
    host_cpu="sparc"
    ;;
sparc64)
    host_cpu="sparc64"
    ;;
x86_64|amd64)
    host_cpu="x86_64"
    ;;
*)
    host_cpu="unknown"
    ;;
esac
bigendian="no"

# find source path
# XXX: we assume an absolute path is given when launching configure, 
# except in './configure' case.
source_path=${0%configure}
source_path=${source_path%/}
source_path_used="yes"
if test -z "$source_path" -o "$source_path" = "." ; then
    source_path=`pwd`
    source_path_used="no"
fi

for opt do
case "$opt" in
--prefix=*)
    prefix=`echo $opt | cut -d '=' -f 2`
    ;;
--pkglibdir=*)
    pkglibdir=`echo $opt | cut -d '=' -f 2`
    ;;
--target-os=*)
    target_os=`echo $opt | cut -d '=' -f 2 | tr '[A-Z]' '[a-z]'`
    ;;
--target-cpu=*)
    target_cpu=`echo $opt | cut -d '=' -f 2 | sed -e 's/^i.86$/i386/'`
    ;;
--generic-build)
    linux_only="no"
    ;;
--with-biarch)
    biarch="yes"
    ;;
--without-biarch)
    biarch="no"
    ;;
--with-viewer)
    build_viewer="yes"
    ;;
--without-viewer)
    build_viewer="no"
    ;;
--with-lib32=*)
    lib32=`echo $opt | cut -d '=' -f 2`
    ;;
--with-lib64=*)
    lib64=`echo $opt | cut -d '=' -f 2`
    ;;
--with-x11-prefix=*)
    x_base_dirs=`echo $opt | cut -d '=' -f 2`
    ;;
--with-cc=*)
    cc=`echo $opt | cut -d '=' -f 2`
    ;;
--with-cxx=*)
    cxx=`echo $opt | cut -d '=' -f 2`
    ;;
esac
done

# check for linux only build
if test "$linux_only" = "guess"; then
    if test "$host_os" = "linux" -a "$target_os" = "linux"; then
	linux_only="yes"
    else
	linux_only="no"
    fi
fi

# check for biarch build
if test "$biarch" = "guess"; then
    case $host_cpu:$target_cpu in
    x86_64:i386 | ppc64:ppc)
	biarch="yes"
	;;
    *)
	biarch="no"
	;;
    esac
fi

# check for viewer builds
if test "$build_viewer" = "guess"; then
    build_viewer="no"
    case $host_os in
    linux)
	if test "$host_cpu" = "$target_cpu" -o "$biarch" = "yes"; then
	    build_viewer="yes"
	fi
	;;
    esac
fi

# check for libdir name
if test -z "$lib64"; then
    case $host_os in
    linux)
	# test if the compiler is 64bit
        echo 'int i;' > $TMPC
	nspluginwrapper_64bit_output=no
	if $cc -o $TMPO -c $TMPC; then
	    case `/usr/bin/file $TMPO` in
	    *"ELF 64"*)
		nspluginwrapper_64bit_output=yes
		;;
	    esac
	fi
	rm -f $TMPC $TMPO
	;;
    esac
    case $host_cpu:$nspluginwrapper_64bit_output in
    ppc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
	lib64="lib64"
	;;
    *)
	lib64="lib"
	;;
    esac
fi
if test -z "$lib32"; then
    lib32="lib"
fi

# check for installation root
if test -z "$pkglibdir"; then
    pkglibdir="$prefix/lib/$PACKAGE"
fi

# check for __attribute__((visibility())) support
cat > $TMPC << EOF
int foo __attribute__((visibility("hidden"))) = 1;
int bar __attribute__((visibility("protected"))) = 1;
EOF
has_visibility_attribute=no
if $cc -Werror -S $TMPC -o $TMPS >/dev/null 2>&1; then
    if grep '\.hidden.*foo' $TMPS >/dev/null; then
	if grep '\.protected.*bar' $TMPS >/dev/null; then
	    has_visibility_attribute=yes
	fi
    fi
fi
rm -f $TMPC $TMPS

# check for .init_array/.fini_array support
cat > $TMPC << EOF
static int x = -1;
int main(void) { return x; }
int foo(void) { x = 0; }
int (*fp)(void) __attribute__((section(".init_array"))) = foo;
EOF
has_initfini_array=no
if $cc -Werror $TMPC -o $TMPE >/dev/null 2>&1; then
    if $TMPE; then
	has_initfini_array=yes
    fi
fi
rm -f $TMPC $TMPE

# check for egrep program
if echo a | (grep -E '(a|b)') >/dev/null 2>&1; then
    EGREP='grep -E'
else
    EGREP='egrep'
fi

# check for __stack_chk_fail() in target GNU C library
if test "$biarch" = "yes"; then
    glibc_header_dir="/usr/include"
    libc_provides_ssp=no
    if test -f $glibc_header_dir/features.h \
	&& $EGREP '^[ 	]*#[ 	]*define[ 	]+__GNU_LIBRARY__[ 	]+([1-9][0-9]|[6-9])' \
	$glibc_header_dir/features.h > /dev/null; then
	if $EGREP '^[ 	]*#[ 	]*define[ 	]+__GLIBC__[ 	]+([1-9][0-9]|[3-9])' \
	    $glibc_header_dir/features.h > /dev/null; then
	    libc_provides_ssp=yes
	elif $EGREP '^[ 	]*#[ 	]*define[ 	]+__GLIBC__[ 	]+2' \
	    $glibc_header_dir/features.h > /dev/null \
	    && $EGREP '^[ 	]*#[ 	]*define[ 	]+__GLIBC_MINOR__[ 	]+([1-9][0-9]|[4-9])' \
	    $glibc_header_dir/features.h > /dev/null; then
	    libc_provides_ssp=yes
	fi
    fi
fi

# check for compiler flag
check_cc_option() {
    echo "int i;" > $TMPC
    if $cc $* -c $TMPC -o $TMPO > /dev/null 2>&1; then
	rm -f $TMPC $TMPO
	return 0
    fi
    rm -f $TMPC
    return 1
}

# check for CFLAGS
if test -z "$CFLAGS"; then
    CFLAGS="-O2 -g"
    if check_cc_option -mtune=generic $CFLAGS; then
	CFLAGS="$CFLAGS -mtune=generic"
    fi
fi
if test "$biarch" = "yes" -a -z "$CFLAGS_32"; then
    CFLAGS_32="-m32 -O2 -g"
    if check_cc_option -mtune=generic $CFLAGS_32; then
	CFLAGS_32="$CFLAGS_32 -mtune=generic"
    fi
fi

# check for pkg-config
pkgconfig=`which pkg-config`
if test -z "$pkgconfig"; then
    echo "pkg-config not found"
    exit 1
fi

# check for Glib 2.0 compile CFLAGS
if $pkgconfig --exists glib-2.0; then
    GLIB_CFLAGS=`$pkgconfig --cflags glib-2.0`
    GLIB_LDFLAGS=`$pkgconfig --libs glib-2.0`
else
    echo "GLIB 2.0 environment not found"
    exit 1
fi
cat > $TMPC << EOF
#include <glib.h>
int main(void) {
    (void) g_main_pending();
    return 0;
}
EOF
if ! $cc $CFLAGS $GLIB_CFLAGS $GLIB_LDFLAGS $TMPC -o $TMPE > /dev/null 2>&1; then
    echo "GLIB 2.0 environment not usable"
    rm -f $TMPC
    exit 1
fi
rm -f $TMPC $TMPE

# check for GTK+ 2.0 compile CFLAGS
if test "$build_viewer" = "yes"; then
    if $pkgconfig --exists gtk+-2.0; then
	GTK_CFLAGS=`$pkgconfig --cflags gtk+-2.0`
	GTK_LDFLAGS=`$pkgconfig --libs gtk+-2.0`
    else
	echo "GTK+ 2.0 environment not found"
	exit 1
    fi
    cat > $TMPC << EOF
#include <gtk/gtk.h>
int main(void) {
    gtk_main_quit();
    return 0;
}
EOF
    if ! $cc $CFLAGS $GTK_CFLAGS $GTK_LDFLAGS $TMPC -o $TMPE > /dev/null 2>&1; then
	echo "GTK+ 2.0 environment not usable"
	rm -f $TMPC
	exit 1
    fi
    rm -f $TMPC $TMPE
fi

# check for X11 base dir
if test -z "$x_base_dirs"; then
    x_base_dirs="
	/usr
	/usr/X11R6
	/usr/local/X11R6
	$prefix
    "
fi
for dir in $x_base_dirs; do
    x_include_dir="$dir/include"
    if test -f $x_include_dir/X11/Intrinsic.h; then
	x_lib_dir="$dir/$lib64"
	if test -f $x_lib_dir/libX11.so; then
	    x_base_dir=$dir
	    break
	fi
    fi
done
if test -z "$x_base_dir"; then
    echo "X11 environment not found"
    exit 1
fi

# big/little endian test
cat > $TMPC << EOF
#include <inttypes.h>
int main(int argc, char ** argv){
    volatile uint32_t i=0x01234567;
    return (*((uint8_t*)(&i))) == 0x67;
}
EOF

if $cc -o $TMPE $TMPC 2>/dev/null ; then
    $TMPE && bigendian="yes"
else
    echo "big/little test failed"
fi

rm -f $TMPO $TMPC $TMPE $TMPS

# floating point endian test
cat > $TMPC << EOF
/* This will not work unless sizeof(double) == 8.  */
extern char sizeof_double_must_be_8 [sizeof(double) == 8 ? 1 : -1];

/* This structure must have no internal padding.  */
struct possibility {
  char prefix[8];
  double candidate;
  char postfix[8];
};

#define C(cand) { "\nformat:", cand, ":tamrof\n" }
struct possibility table [] =
{
  C( 3.25724264705901305206e+01), /* @@IEEEFP - IEEE 754 */
  C( 3.53802595280598432000e+18), /* D__float - VAX */
  C( 5.32201830133125317057e-19), /* D.PDP-10 - PDP-10 - the dot is 0x13a */
  C( 1.77977764695171661377e+10), /* IBMHEXFP - s/390 format, ascii */
  C(-5.22995989424860458374e+10)  /* IBMHEXFP - s/390 format, EBCDIC */
};
EOF

if $cc -o $TMPO -c $TMPC 2>/dev/null; then
    od -c $TMPO |
    sed 's/^[0-7]*[ 	]*/ /
	 s/\*/./g
	 s/ \\n/*/g
	 s/ [0-9][0-9][0-9]/./g
	 s/  \\[^ ]/./g' |
    tr -d '
 ' | tr -s '*' '
' | fold | sed '$a\
' > $TMPE

    if grep 'format:.@IEEEF.:tamrof' $TMPE >/dev/null 2>&1; then
	float_format='IEEE (big-endian)'
    elif grep 'format:.I@@PFE.:tamrof' $TMPE >/dev/null 2>&1; then
	float_format='IEEE (big-endian)'
    elif grep 'format:.FEEEI@.:tamrof' $TMPE >/dev/null 2>&1; then
	float_format='IEEE (little-endian)'
    elif grep 'format:.EFP@@I.:tamrof' $TMPE >/dev/null 2>&1; then
	float_format='IEEE (little-endian)'
    elif grep 'format:.__floa.:tamrof' $TMPE >/dev/null 2>&1; then
	float_format='VAX D-float'
    elif grep 'format:..PDP-1.:tamrof' $TMPE >/dev/null 2>&1; then
	float_format='PDP-10'
    elif grep 'format:.BMHEXF.:tamrof' $TMPE >/dev/null 2>&1; then
	float_format='IBM 370 hex'
    else
	echo "unknown floating point format"
	exit 1
    fi

    fbigendian=
    case $float_format in
    'IEEE (big-endian)')
	if test "$bigendian" = "no"; then
	    fbigendian=1
	fi
	;;
    'IEEE (little-endian)')
	if test "$bigendian" = "yes"; then
	    fbigendian=0
	fi
	;;
    *)
	echo "unsupported floating point format $float_format"
	exit 1
	;;
    esac
else
    echo "floating point endian test failed"
fi

rm -f $TMPO $TMPC $TMPE

# print configure help
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
cat << EOF

Usage: configure [options]
Options: [defaults in brackets after descriptions]

EOF
echo "Standard options:"
echo "  --help                      print this message"
echo "  --prefix=PREFIX             install in PREFIX [$prefix]"
echo "  --pkglibdir=ROOT            install private files in ROOT [$pkglibdir]"
echo "  --target-os=OS              build plugin support for target OS [$target_os]"
echo "  --target-cpu=CPU            build plugin support for target CPU [$target_cpu]"
echo "  --with-viewer               build viewer [$build_viewer]"
echo ""
echo "Advanced options (experts only):"
echo "  --source-path=PATH          path of source code [$source_path]"
echo "  --generic-build             don't use system-specific additions"
echo "  --with-biarch               build both 32-bit and 64-bit components at once"
echo "  --with-lib32=NAME           use NAME as the 32-bit library dir name [$lib32]"
echo "  --with-lib64=NAME           use NAME as the 64-bit library dir name [$lib64]"
echo "  --with-x11-prefix=PREFIX    use PREFIX as the X11 base dir [autodetect]"
echo "  --with-cc=CC                use C compiler CC [$cc]"
echo "  --with-cxx=CXX              use C++ compiler CXX [$cxx]"
echo ""
echo "NOTE: The object files are built at the place where configure is launched"
exit 1
fi

echo "Install prefix            $prefix"
echo "nspluginwrapper root dir  $pkglibdir"
echo "Bi-arch build             $biarch"
echo "Build viewer              $build_viewer"
echo "Build for Linux only      $linux_only"
echo "32-bit library dir name   $lib32"
echo "64-bit library dir name   $lib64"
echo "Source path               $source_path"
echo "C compiler                $cc"
echo "C++ compiler              $cxx"
echo "host OS                   $host_os"
echo "host CPU                  $host_cpu"
echo "host big endian           $bigendian"
echo "target OS                 $target_os"
echo "target CPU                $target_cpu"

config_mak="config-host.mak"
echo "# Automatically generated by configure - do not modify" > $config_mak

config_h="config-host.h"
echo "/* Automatically generated by configure - do not modify */" > $config_h

echo "CC=$cc" >> $config_mak
echo "CXX=$cxx" >> $config_mak
echo "CFLAGS=$CFLAGS" >> $config_mak
echo "GLIB_CFLAGS=$GLIB_CFLAGS" >> $config_mak
echo "GLIB_LDFLAGS=$GLIB_LDFLAGS" >> $config_mak
echo "GTK_CFLAGS=$GTK_CFLAGS" >> $config_mak
echo "GTK_LDFLAGS=$GTK_LDFLAGS" >> $config_mak
if test "$biarch" = "yes"; then
echo "LDFLAGS_32=-m32" >> $config_mak
echo "CFLAGS_32=$CFLAGS_32" >> $config_mak
else
echo 'CFLAGS_32=$(CFLAGS)' >> $config_mak
fi
if test "$host_os" = "linux"; then
    echo "OS=linux" >> $config_mak
    echo "#define HOST_LINUX 1" >> $config_h
    echo "#define HOST_OS \"linux\"" >> $config_h
elif test "$host_os" = "dragonfly"; then
    echo "OS=dragonfly" >> $config_mak
    echo "#define HOST_DRAGONFLY 1" >> $config_h
    echo "#define HOST_OS \"dragonfly\"" >> $config_h
elif test "$host_os" = "freebsd"; then
    echo "OS=freebsd" >> $config_mak
    echo "#define HOST_FREEBSD 1" >> $config_h
    echo "#define HOST_OS \"freebsd\"" >> $config_h
elif test "$host_os" = "netbsd"; then
    echo "OS=netbsd" >> $config_mak
    echo "#define HOST_NETBSD 1" >> $config_h
    echo "#define HOST_OS \"netbsd\"" >> $config_h
else
    echo "Unsupported OS"
    exit 1
fi
if test "$host_cpu" = "i386" ; then
    echo "ARCH=i386" >> $config_mak
    echo "#define HOST_I386 1" >> $config_h
    echo "#define HOST_ARCH \"i386\"" >> $config_h
elif test "$host_cpu" = "x86_64" ; then
    echo "ARCH=x86_64" >> $config_mak
    echo "#define HOST_X86_64 1" >> $config_h
    echo "#define HOST_ARCH \"x86_64\"" >> $config_h
elif test "$host_cpu" = "ppc" ; then
    echo "ARCH=ppc" >> $config_mak
    echo "#define HOST_PPC 1" >> $config_h
    echo "#define HOST_ARCH \"ppc\"" >> $config_h
elif test "$host_cpu" = "ppc64" ; then
    echo "ARCH=ppc64" >> $config_mak
    echo "#define HOST_PPC64 1" >> $config_h
    echo "#define HOST_ARCH \"ppc64\"" >> $config_h
elif test "$host_cpu" = "sparc" ; then
    echo "ARCH=sparc" >> $config_mak
    echo "#define HOST_SPARC 1" >> $config_h
    echo "#define HOST_ARCH \"sparc\"" >> $config_h
elif test "$host_cpu" = "sparc64" ; then
    echo "ARCH=sparc64" >> $config_mak
    echo "#define HOST_SPARC64 1" >> $config_h
    echo "#define HOST_ARCH \"sparc64\"" >> $config_h
elif test "$host_cpu" = "ia64" ; then
    echo "ARCH=ia64" >> $config_mak
    echo "#define HOST_IA64 1" >> $config_h
    echo "#define HOST_ARCH \"ia64\"" >> $config_h
else
    echo "Unsupported CPU"
    exit 1
fi
if test "$bigendian" = "yes" ; then
    echo "WORDS_BIGENDIAN=yes" >> $config_mak
    echo "#define WORDS_BIGENDIAN 1" >> $config_h
fi
if test -n "$fbigendian" ; then
    echo "#define FLOAT_WORDS_BIGENDIAN $fbigendian" >> $config_h
fi

echo "SRC_PATH=$source_path" >> $config_mak
echo "build_viewer=$build_viewer" >> $config_mak
echo "biarch=$biarch" >> $config_mak
echo "lib32=$lib32" >> $config_mak
echo "lib64=$lib64" >> $config_mak
echo "prefix=$prefix" >> $config_mak
echo "bindir=$prefix/bin" >> $config_mak
libdir="$prefix/$lib64"
echo "libdir=$libdir" >> $config_mak
echo "#define LIB \"$lib64\"" >> $config_h
echo "#define LIBDIR \"$libdir\"" >> $config_h
echo "x11prefix=$x_base_dir" >> $config_mak

VERSION=`sed < $source_path/$PACKAGE.spec -n '/^\%define version[	]*/s///p'`
RELEASE=`sed < $source_path/$PACKAGE.spec -n '/^\%define release[	]*/s///p'`
SVNDATE=`sed < $source_path/$PACKAGE.spec -n '/^\%define svndate[ 	]*/s///p'`
if test -z "$SVNDATE"; then
    SVNDATE=`date '+%Y%m%d'`
fi
SNAPSHOT=0
if echo "$RELEASE" | grep -q ^0; then
    SNAPSHOT=1
fi
echo "VERSION=$VERSION" >> $config_mak
echo "SVNDATE=$SVNDATE" >> $config_mak
echo "SNAPSHOT=$SNAPSHOT" >> $config_mak
echo "#define NPW_SNAPSHOT $SNAPSHOT" >> $config_h
if test "$SNAPSHOT" = "1"; then
    echo "#define NPW_VERSION \"$VERSION-Pre ($SVNDATE)\"" >> $config_h
else
    echo "#define NPW_VERSION \"$VERSION\"" >> $config_h
fi

echo "pkglibdir=$pkglibdir" >> $config_mak
echo "#define NPW_LIBDIR \"$pkglibdir\"" >> $config_h

if test "$has_visibility_attribute" = "yes"; then
    echo "#define attribute_hidden __attribute__((visibility(\"hidden\")))" >> $config_h
    echo "#define attribute_protected __attribute__((visibility(\"protected\")))" >> $config_h
else
    echo "#define attribute_hidden" >> $config_h
    echo "#define attribute_protected" >> $config_h
fi
if test "$has_initfini_array" = "yes"; then
    echo "#define HAVE_INITFINI_ARRAY 1" >> $config_h
else
    echo "#undef HAVE_INITFINI_ARRAY" >> $config_h
fi
if test "$libc_provides_ssp" = "yes"; then
    echo "#define TARGET_LIBC_PROVIDES_SSP 1" >> $config_h
else
    echo "#undef TARGET_LIBC_PROVIDES_SSP" >> $config_h
fi

config_mak="config.mak"
echo "# Automatically generated by configure - do not modify" > $config_mak
echo "include config-host.mak" >> $config_mak

config_h="config.h"
echo "/* Automatically generated by configure - do not modify */" > $config_h
echo "#include \"config-host.h\"" >> $config_h

if test "$linux_only" = "yes"; then
    echo "#define BUILD_LINUX_ONLY 1" >> $config_h
fi

if test "$target_os" = "linux"; then
    echo "TARGET_OS=linux" >> $config_mak
    echo "#define TARGET_OS \"linux\"" >> $config_h
    echo "#define TARGET_LINUX 1" >> $config_h
elif test "$target_os" = "solaris"; then
    echo "TARGET_OS=solaris" >> $config_mak
    echo "#define TARGET_OS \"solaris\"" >> $config_h
    echo "#define TARGET_SOLARIS 1" >> $config_h
else
    echo "Unsupported target OS"
    exit 1
fi

if test "$target_cpu" = "i386" ; then
    echo "TARGET_ARCH=i386" >> $config_mak
    echo "#define TARGET_ARCH \"i386\"" >> $config_h
    echo "#define TARGET_I386 1" >> $config_h
elif test "$target_cpu" = "x86_64" ; then
    echo "TARGET_ARCH=x86_64" >> $config_mak
    echo "#define TARGET_ARCH \"x86_64\"" >> $config_h
    echo "#define TARGET_X86_64 1" >> $config_h
elif test "$target_cpu" = "ppc" ; then
    echo "TARGET_ARCH=ppc" >> $config_mak
    echo "#define TARGET_ARCH \"ppc\"" >> $config_h
    echo "#define TARGET_PPC 1" >> $config_h
else
    echo "Unsupported target CPU"
    exit 1
fi

# build tree in object directory if source path is different from current one
if test "$source_path_used" = "yes" ; then
    case $source_path in
    ..*)
	sp1=..
	;;
    esac
    ln -sf $source_path/Makefile Makefile
fi