aboutsummaryrefslogtreecommitdiffstats
path: root/bs/mkconfig_header.sh
blob: 0f3f0d0e3800ef83ca71076ec2d50425c96ddd84 (plain) (blame)
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
#!/bin/sh

# basic package info
p=mpd
v=0.12.0
b=warren.dukes@gmail.com

. bs/bs-lib.sh

cat <<EOF
#define PACKAGE "$p"
#define VERSION "$p"
#define PACKAGE_BUGREPORT "$b"
#define PACKAGE_NAME "$p"
#define PACKAGE_STRING "$p $v"
#define PACKAGE_TARNAME "$p"
#define PACKAGE_VERSION "$v"
EOF

# check for common headers:
ansi_headers='
assert
ctype
errno
limits
locale
math
signal
stdarg
stddef
stdint
stdio
stdlib
string
'
common_headers='
dlfcn
inttypes
memory
strings
sys/inttypes
sys/stat
sys/types
unistd
'

all_ansi=t
for h in $ansi_headers; do
	H="HAVE_`echo $h | tr a-z A-Z | tr / _`_H"
	if test_header $h; then
		echo "#define $H 1"
	else
		echo "/* #undef $H */"
		all_ansi=
	fi
done
test x$all_ansi = xt && echo "#define STDC_HEADERS 1"

for h in $common_headers; do
	H="HAVE_`echo $h | tr a-z A-Z | tr / _`_H"
	if test_header $h; then
		echo "#define $H 1"
	else
		echo "/* #undef $H */"
	fi
done

# test for langinfo.h and codeset
cat > t.c <<EOF
#include <langinfo.h>
int main () { char *cs = nl_langinfo(CODESET); return 0; }
EOF
run_cc
test $? -eq 0 && echo '#define HAVE_LANGINFO_CODESET 1'

# the only feature (non-external library) feature we currently have
if test x$want_ipv6 != xno; then
	cat > t.c <<EOF
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#ifdef PF_INET6
#ifdef AF_INET6
AP_maGiC_VALUE
#endif
#endif
EOF
	if $CPP t.c 2>&1 | grep AP_maGiC_VALUE >/dev/null 2>&1; then
		echo '#define HAVE_IPV6 1'
	fi
fi

rm -f t.o t.c