2016-03-17 13:05:15 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
#
|
|
|
|
# Copyright (C) 2016 Eistec AB
|
|
|
|
#
|
|
|
|
# This file is subject to the terms and conditions of the GNU Lesser General
|
|
|
|
# Public License v2.1. See the file LICENSE in the top level directory for more
|
|
|
|
# details.
|
|
|
|
#
|
2018-03-16 18:13:12 +01:00
|
|
|
# Usage: $0 [CFLAGS]...
|
|
|
|
#
|
|
|
|
# Extract all macros from CFLAGS and generate a header file format"
|
|
|
|
#
|
2016-03-17 13:05:15 +01:00
|
|
|
|
|
|
|
# exit on any errors below this line
|
|
|
|
set -e
|
|
|
|
|
2018-03-16 18:13:12 +01:00
|
|
|
echo "/* DO NOT edit this file, your changes will be overwritten and won't take any effect! */"
|
|
|
|
echo "/* Generated from CFLAGS: $@ */"
|
2016-08-30 13:42:19 +02:00
|
|
|
|
2018-03-16 18:13:12 +01:00
|
|
|
[ -n "${LTOFLAGS}" ] && echo "/* LTOFLAGS=${LTOFLAGS} */"
|
2016-08-30 13:42:19 +02:00
|
|
|
|
2016-03-17 13:05:15 +01:00
|
|
|
for arg in "$@"; do
|
|
|
|
case ${arg} in
|
|
|
|
-D*)
|
|
|
|
# Strip leading -D
|
|
|
|
d=${arg#-D}
|
|
|
|
if [ -z "${d##*=*}" ]; then
|
|
|
|
# key=value pairs
|
|
|
|
key=${d%%=*}
|
|
|
|
value=${d#*=}
|
2018-03-16 18:13:12 +01:00
|
|
|
echo "#define $key $value"
|
2016-03-17 13:05:15 +01:00
|
|
|
else
|
|
|
|
# simple #define
|
2018-03-16 18:13:12 +01:00
|
|
|
echo "#define $d 1"
|
2016-03-17 13:05:15 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
-U*)
|
|
|
|
# Strip leading -U
|
|
|
|
d=${arg#-U}
|
2018-03-16 18:13:12 +01:00
|
|
|
echo "#undef $d"
|
2016-03-17 13:05:15 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|