-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkcompileheaderobj.sh
More file actions
executable file
·96 lines (90 loc) · 2.65 KB
/
mkcompileheaderobj.sh
File metadata and controls
executable file
·96 lines (90 loc) · 2.65 KB
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
#! /bin/sh
# vim: set sw=2 ts=8:
# Copyright (C) 2001 - 2006 Joachim Falk <joachim.falk@gmx.de>
#
# This file is part of the BuildSystem distribution of Joachim Falk;
# you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option) any later version.
#
# The BuildSystem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
if [ $# -eq 0 ]; then
echo "usage: `basename $0` headerfiles"
exit 0
fi
for header_file in "$@"; do
header=`basename $header_file`
header_prefix=`echo "${header}_CH" | tr '.' '_'`
rm -f ${header_prefix}*
case $header in
*.h)
SRCEXT="c"
;;
*.hh|*.hpp|*.hxx|*.tcc|*.tcpp|*.tcxx)
SRCEXT="cpp"
;;
*)
echo "Unknown header format for header $header"
exit 1
;;
esac
sed -e "s/^ *#.* *_COMPILEHEADER_\(.\+\)$/\1/;t;d" $header_file | {\
SRCS=""; OBJS=""; LTOBJS=""; DEPS=""
while read line; do
cat <<EOF > ${header_prefix}_${line}.${SRCEXT}
#define _COMPILEHEADER_
#define _COMPILEHEADER_$line
#include "$header_file"
EOF
SRCS="$SRCS ${header_prefix}_${line}.${SRCEXT}"
OBJS="$OBJS ${header_prefix}_${line}.o"
LTOBJS="$LTOBJS ${header_prefix}_${line}.lo"
DEPS="$DEPS .deps/${header_prefix}_${line}.Plo"
done
if [ "x$DEPS" != "x" ]; then
cat <<EOF > ${header_prefix}.mk
${header_prefix}_SRCS=$SRCS
${header_prefix}_OBJS=$OBJS
${header_prefix}_LTOBJS=$LTOBJS
-include $DEPS
EOF
fi
}
done
{
cat <<EOF
.PHONY: clean-compileheader
clean-am: clean-compileheader
EOF
SRCS=""; OBJS=""; LTOBJS=""; MKFRAGS=""
for header_file in "$@"; do
header=`basename $header_file`
header_prefix=`echo "${header}_CH" | tr '.' '_'`
if test -f "${header_prefix}.mk"; then
cat <<EOF
include ${header_prefix}.mk
EOF
SRCS="$SRCS \$(${header_prefix}_SRCS)"
OBJS="$OBJS \$(${header_prefix}_OBJS)"
LTOBJS="$LTOBJS \$(${header_prefix}_LTOBJS)"
MKFRAGS="$MKFRAGS ${header_prefix}.mk"
fi
done
cat <<EOF
CH_SRCS=$SRCS
CH_OBJS=$OBJS
CH_LTOBJS=$LTOBJS
CH_MKFRAGS=$MKFRAGS
clean-compileheader:
@\$(RM) compileheader.mk compileheader*.stamp
@\$(RM) \$(CH_SRCS) \$(CH_OBJS) \$(CH_LTOBJS) \$(CH_MKFRAGS)
EOF
} > compileheader.mk