summaryrefslogtreecommitdiff
path: root/extra/scripts/conf-header.sh
blob: 8044f8c06f4aeee6bd4ee9bcf2c4f38d331ec68f (plain)
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
#!/bin/sh -e

# Turn .config into a header file

if [ -z "$1" ] ; then
	echo "Usage: conf-header.sh <.config>"
	exit 1
fi

cat <<EOF
#if !defined _FEATURES_H && !defined __need_uClibc_config_h
# error Never include <bits/uClibc_config.h> directly; use <features.h> instead
#endif

#define __UCLIBC_MAJOR__ ${MAJOR_VERSION}
#define __UCLIBC_MINOR__ ${MINOR_VERSION}
#define __UCLIBC_SUBLEVEL__ ${SUBLEVEL}
EOF

exec \
sed \
	-e '/^#$/d' \
	-e '/^[^#]/s:^\([^=]*\)=\(.*\):#define __\1__ \2:' \
	-e '/^#define /s: y$: 1:' \
	-e '/^# .* is not set$/s:^# \(.*\) is not set$:#undef __\1__:' \
	-e 's:^# \(.*\)$:/* \1 */:' \
	$1