1#!/bin/sh -e
2
3# Turn .config into a header file
4
5if [ -z "$1" ] ; then
6	echo "Usage: conf-header.sh <.config>"
7	exit 1
8fi
9
10cat <<EOF
11#if !defined _FEATURES_H && !defined __need_uClibc_config_h
12# error Never include <bits/uClibc_config.h> directly; use <features.h> instead
13#endif
14
15#define __UCLIBC_MAJOR__ ${MAJOR_VERSION}
16#define __UCLIBC_MINOR__ ${MINOR_VERSION}
17#define __UCLIBC_SUBLEVEL__ ${SUBLEVEL}
18EOF
19
20exec \
21sed \
22	-e '/^#$/d' \
23	-e '/^[^#]/s:^\([^=]*\)=\(.*\):#define __\1__ \2:' \
24	-e '/^#define /s: y$: 1:' \
25	-e '/^# .* is not set$/s:^# \(.*\) is not set$:#undef __\1__:' \
26	-e 's:^# \(.*\)$:/* \1 */:' \
27	$1
28