-
Notifications
You must be signed in to change notification settings - Fork 38
/
build.sh
executable file
·214 lines (187 loc) · 4.21 KB
/
build.sh
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
set -e
WITH_UPX="no"
SED=sed
#workaround for Windows (set to binary mode)
if [ "$(expr substr $(uname -s) 1 5)" == 'MINGW' ]; then
SED='sed -b'
fi
export SWAP=YES-DXMS-SWAP____________________
# BEGIN Internal stuff for ska -- If one of these three commands
# fail for you, your distribution is broken! Please report.
for a in lib/lib.mak cmd/cmd.mak shell/command.mak; do if [ ! -f $a ]; then export SWAP=NO; fi; done
if [ "$SWAP" == "NO" ]; then
unset XMS_SWAP
dmake dist
fi
# end
export SWAP=
if [ ! -f config.mak ]; then
echo File config.mak missing, copying config.std to it
cp config.std config.mak || exit 1
fi
export XNASM=nasm
export COMPILER=watcom
if [ -z "$WATCOM" ]; then
export WATCOM=$HOME/watcom
export PATH=$PATH:$WATCOM/binl
fi
export PATH=$PATH:.
if [ -f lastmake.mk ] || [ "$1" == "-r" ]; then ./clean.sh; fi
if [ "$1" == "-r" ]; then ./clean.sh; shift; fi
if [ "$1" == "clean" ]; then ./clean.sh; exit 0; fi
export XMS_SWAP=1
while (( "$#" )); do
case "$1" in
-h)
echo Build FreeCOM
echo Usage: %0 [-r] [clean] [no-xms-swap] [debug] [language]
echo -r: Rebuild -- Clean before proceed
echo clean: Remove *.OBJ, *.COM, *.LIB, etc. files, then exit
echo no-xms-swap: Build FreeCOM without XMS-Only Swap support
echo debug: Build FreeCOM with debug settings.
echo You can select for which language to built FreeCOM by setting
echo the environment variable LNG before running this script, e.g.:
echo EXPORT LNG=german
echo selects the German language. For available language see STRINGS\*.LNG
exit 0
;;
no-xms-swap)
unset XMS_SWAP
;;
debug)
export DEBUG=1
;;
watcom)
export COMPILER=watcom
;;
wc)
export COMPILER=watcom
;;
gcc)
export COMPILER=gcc
;;
upx)
WITH_UPX="yes"
;;
*)
break
;;
esac
shift
done
if [ -n "$1" ]; then export LNG=$1; fi
if [ -z "$LNG" ]; then export LNG=english; fi
echo Building FreeCOM for language $LNG
if [ -z "$MAKE" ]; then
case "$COMPILER" in
watcom)
export MAKE="wmake -ms -h -f"
;;
gcc)
export MAKE="make -f gnumake.mak"
;;
*)
;;
esac
echo Make is $MAKE.
fi
# substitutions for GNU Make
gnumake_subst () {
$SED -e 's@^!@@' \
-e 's@^include "\(.*\)"@include \1@' \
-e 's@^include $(TOP)/config.mak@include $(TOP)/gnuconf.mak@' \
-e 's@if \(.*\) == \(.*\)[\r$]@ifeq (\1,\2)@' \
-e 's@^CC =@CC :=@' \
-e 's@^INCLUDEPATH =@INCLUDEPATH :=@' \
-e 's/\(-f obj.*$<\)/\1 -o $@/' \
< $1/$2 > $1/$3
}
if $MAKE -? 2>&1 | grep -q gnu; then
gnumake_subst . config.mak gnuconf.mak
for i in suppl utils strings criter lib cmd; do
gnumake_subst $i $i.mak gnumake.mak
done
gnumake_subst suppl/src suppl.mak gnumake.mak
gnumake_subst strings/strings strings.mak gnumake.mak
gnumake_subst shell command.mak gnumake.mak
fi
echo
echo Checking SUPPL library
cd suppl
if [ ! -f skip ]; then
echo Building SUPPL library
$MAKE suppl.mak all
cd src
$MAKE suppl.mak all
cd ..
fi
cd ..
echo
echo Making basic utilities for build process
echo
cd utils
$MAKE utils.mak all
cd ..
echo
echo Making STRINGS resource
echo
cd strings
$MAKE strings.mak all
cd strings
$MAKE strings.mak all
cd ../..
echo
echo Making CRITER resource
echo
cd criter
$MAKE criter.mak all
cd ..
echo
echo Making misc library
echo
cd lib
$MAKE lib.mak all
cd ..
echo
echo Making commands library
echo
cd cmd
$MAKE cmd.mak all
cd ..
echo
echo Making COMMAND.COM
echo
cd shell
$MAKE command.mak all
cd ..
utils/mkinfres.exe -Tinfo.txt infores shell/command.map shell/command.exe
cat shell/command.exe infores criter/criter1 criter/criter strings/strings.dat > command.com
[ -f command.com ] || exit 1
echo
echo Making supplemental tools
echo
cd tools
cat tools.m1 > tools.mak
../utils/mktools.exe >>tools.mak
cat tools.m2 >>tools.mak
if $MAKE -? 2>&1 | grep -q gnu; then
gnumake_subst . tools.mak gnumake.mak
fi
$MAKE tools.mak all
cd ..
echo
echo Patching heap size to 6KB
echo
tools/ptchsize.exe command.com +6KB
if [ $WITH_UPX = "yes" ]; then
rm -f command.upx
upx --8086 --best -o command.upx command.com
fi
echo
echo All done. COMMAND.COM is ready for use!
echo
if [ -z "$XMS_SWAP" ]; then
echo Note: To build FreeCOM without XMS-Only Swap, re-run
echo ./build.sh -r no-xms-swap $LNG
fi