-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbldgmake
159 lines (136 loc) · 3.82 KB
/
bldgmake
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#! /bin/sh
# Display commands and their arguments as they are executed.
#set -x
# file "bldgmake" -- Builds the TNS/E, TNS/X gmake
usage="Usage: bldgmake [-h grde|grdx|osse|ossx] [-ncb|--no-clean-build]"
# -h host Host machine that gmake being built will run on.
# The options are:
#
# grde
# grdx (default)
# osse
# ossx
# -ncb
# -no-clean-build
#
# Perform incremental (no clean) build i.e. build only the the object/target files
# whose corresponding/dependent source file(s) is(are) modified.
is_xpf_host=false
# By default perform clean build. But with this option enabled, do increment build.
no_clean_build=false
# Get options
while [ $# -gt 0 ]
do
case $1 in
-h )
if [ $# -lt 2 ]
then
echo $usage
exit 1
fi
shift
gmake_host=$1
shift
;;
-ncb | --no-clean-build )
no_clean_build=true
shift
;;
* )
echo $usage
exit 1
;;
esac
done
case $gmake_host in
grdx | ossx )
is_xpf_host=true
;;
grde | osse )
;;
* )
echo Unknown gmake host option: $gmake_host
exit
;;
esac
mkdir -p $gmake_host
cd $gmake_host
cp ../makein Makefile.0
# Fix up the Makefiles
# Erase custom markers for our machine/host. Those lines will be retained.
case $gmake_host in
osse | ossx)
if [ $no_clean_build == false ]
then
rm -f *.o
fi
echo Customizing Makefile for targetting for OSS
# Erase OSS custom markers "<OSS> ".
sed 's/^<OSS> //' < Makefile.0 > Makefile.1
;;
grde | grdx)
if [ $no_clean_build == false ]
then
rm -f *.o
fi
echo Customizing Makefile for targetting for Guardian
# Erase GRD custom markers "<GRD> ".
sed 's/^<GRD> //' < Makefile.0 > Makefile.1
;;
*)
echo Invalid gmake_host: $gmake_host
exit
;;
esac
if [ $is_xpf_host == true ]
then
sed 's/^<PRODUCTX> //' < Makefile.1 > Makefile.2
else
sed 's/^<PRODUCTE> //' < Makefile.1 > Makefile.2
fi
# Replace <cmd> markers with tabs.
sed 's/<cmd> /^/' < Makefile.2 | tr '^' '\011' > Makefile.3
# Delete all remaining lines with custom markers.
# Those lines are for some other machine.
sed '/^</d' < Makefile.3 > Makefile.4
if [ $no_clean_build == true ]
then
# "no clean build" is mentioned explicitly.
# So check the difference between generated Makefile and previous one (Makefile).
# If different, overwrite the previous Makefile. If not, don't replace it.
diff Makefile.4 Makefile
if [ $? != 0 ]
then
echo "Current generated Makefile differs from previously generated Makefile."
echo "So considering the new currently generated Makefile for this build."
echo "Hence this will be a full clean build."
no_clean_build=false
cp Makefile.4 Makefile
else
echo "Current generated Makefile is same as previously generated Makefile."
echo "So continuing to use the previously generated Makefile."
echo "Since no clean build option is mentioned explicitly this will be a incremental build."
echo "Meaning not a clean build."
no_clean_build=true
fi
else
# "no clean build" is not mentioned explicitly. So go ahead with it (clean build).
# Don't bother to check whether the generated Makefile is same as previous one.
# Overwrite the previous Makefile.
cp Makefile.4 Makefile
fi
# Clean up all the temporary Makefiles
rm -f Makefile.*
# Make all the components
echo ""
echo "##################"
echo "Building gmake ..."
# Do the build (incremental or full clean build).
if [ $no_clean_build == true ]
then
echo "Doing make with \"default\" target. This is a incremental build. Meaning not a clean build."
else
echo "Doing clean make. Meaning a clean build."
make -f Makefile clean
fi
make -f Makefile