~mirabilos/jupp/trunk

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
#!/bin/mksh
# $MirOS: contrib/code/jupp/Make-w32.sh,v 1.25 2020/03/27 06:08:10 tg Exp $

usage() {
	print -ru2 "Usage: $0 [-bCgn]"
	print -ru2 '	Builds jupp32 (with debugging if -g): clean (unless -n),'
	print -ru2 '	configure (unless -n), make, package (unless -b), clean (unless -C)'
	exit 1
}

nopkg=0
nocln=0
debug=0
contb=0
while getopts "bCgn" c; do
	case $c {
	(b)	nopkg=1 ;;
	(C)	nocln=1 ;;
	(g)	debug=1 ;;
	(n)	contb=1 ;;
	(*)	usage ;;
	}
done

extrawarnings="-Wall -Wextra"
(( debug )) && extrawarnings="$extrawarnings -g3"
extrawarnings="$extrawarnings -Wno-unused-parameter"
extrawarnings="$extrawarnings -Wno-strict-prototypes"

export LC_ALL=C
set -ex
[[ -s configure && -s jupprc && -s charmaps/klingon.in ]]

jupp=$(sed -n "/^PACKAGE_VERSION='3\.1jupp\([0-9]*\)[~'].*\$/s//\1/p" configure)
jwin=
jwnt=$jupp
while (( jwnt > 34 )); do
	jwin=${jwin}z
	(( jwnt -= 25 ))
done
typeset -i1 tmp
(( tmp = 1#a - 10 + jwnt ))
jwin=$jwin${tmp#1#}
jtop=jwin31$jwin
typeset -u jWIN=$jwin

if (( contb )); then
	[[ -s mkw32/build/Makefile ]]
else
	rm -rf mkw32 JWIN31$jWIN.*
	mkdir mkw32{,/{build,$jtop}}
fi
date >>JWIN31$jWIN.log
cd mkw32/build
export CFLAGS='-Os -march=i486 -mtune=pentium-mmx'
export CPPFLAGS='-DJUPPRC_BUILTIN_NAME=\"jupp32rc\"'
(( contb )) || mksh ../../configure \
    --build=i486-pc-cygwin --host=i486-pc-cygwin \
    --prefix=c:/windows/system32 \
    --sysconfdir=c:/windows/system32 \
    --disable-dependency-tracking \
    --disable-terminfo \
    --disable-search-libs \
    --disable-getpwnam \
    --disable-termidx \
    --enable-win32reloc | tee -a ../../JWIN31$jWIN.log
make AM_CFLAGS="$extrawarnings" | tee -a ../../JWIN31$jWIN.log
if (( nopkg )); then
	ln -f joe.exe jupp.exe
	ln -sf ../../jupprc .
	exit 0
fi
cp charmaps/* syntax/* ../$jtop/
cp jmacsrc joerc jpicorc jstarrc ../$jtop/
cp joe.exe ../$jtop/jupp32.exe
cd ../..
cp COPYING mkw32/$jtop/copying.txt
cp /bin/cygwin1.dll mkw32/$jtop/
cp joe.txt mkw32/$jtop/jupp32.txt
cp jupprc mkw32/$jtop/jupp32rc
cd mkw32/$jtop
:>setup.inf
for x in *; do
	[[ $x = *[A-Z]* ]] || continue
	mv "$x" ../_TMP
	typeset -l lc
	lc=$x
	mv ../_TMP "$lc"
done
sed -b -e "s!@jwin@!$jupp!g" -e "s!@ts@!$(date -u +%m/%d/%Y)!g" \
    <../../setup.inf | while IFS= read -r line; do
	if [[ $line = '@files@'* ]]; then
		stat -c '%n=1,,%s
' *
	else
		print -r -- "$line"
	fi
done >setup.inf
sz=$(stat -c '%n=1,,%s
' setup.inf)
sed -bi "/^setup.inf=1,,/s/^.*\$/$sz/" setup.inf
sz=$(stat -c '%n=1,,%s
' setup.inf)
sed -bi "/^setup.inf=1,,/s/^.*\$/$sz/" setup.inf
if [[ $sz != "$(stat -c '%n=1,,%s
' setup.inf)" ]]; then
	print -rnu2 "Size of SETUP.INF destabilises between $sz and "
	stat -c '%n=1,,%s
' setup.inf
	exit 1
fi
chmod 444 *
cd ..
zip -D -X -9 -k ../JWIN31$jWIN.ZIP $jtop/*
cd ..
ls -l JWIN31$jWIN.*
(( nocln )) || rm -rf mkw32