add a CVS snapshot, to thoroughly test on the Debian side
[alioth/jupp.git] / Make-w32.sh
1 #!/bin/mksh
2 # $MirOS: contrib/code/jupp/Make-w32.sh,v 1.12 2017/01/10 20:23:23 tg Exp $
3
4 nopkg=0
5 debug=0
6 contb=0
7 while getopts "bgn" c; do
8         case $c {
9         (b)     nopkg=1 ;;
10         (g)     debug=1 ;;
11         (n)     contb=1 ;;
12         (*)     exit 1 ;;
13         }
14 done
15
16 extrawarnings="-Wall -Wextra"
17 (( debug )) && extrawarnings="$extrawarnings -g3"
18 extrawarnings="$extrawarnings -Wno-unused-parameter"
19 echo "N: gcc-3.4.4-999 does not support -Wno-missing-field-initializers"
20 echo "N: expect warnings about those, they are known, do not report them"
21 extrawarnings="$extrawarnings -Wno-old-style-definition -Wno-strict-prototypes"
22 extrawarnings="$extrawarnings -Wno-cast-qual"
23 extrawarnings="$extrawarnings -Wno-missing-prototypes -Wno-missing-declarations"
24
25 export LC_ALL=C
26 set -ex
27 [[ -s configure && -s jupprc && -s charmaps/klingon.in ]]
28
29 jupp=$(sed -n "/^PACKAGE_VERSION='3\.1jupp\([0-9]*\)[~'].*\$/s//\1/p" configure)
30 jwin=
31 while (( jupp > 34 )); do
32         jwin=${jwin}z
33         (( jupp -= 25 ))
34 done
35 typeset -i1 tmp
36 (( tmp = 1#a - 10 + jupp ))
37 jwin=$jwin${tmp#1#}
38 jtop=jwin31$jwin
39 typeset -u jWIN=$jwin
40
41 if (( contb )); then
42         [[ -s mkw32/build/Makefile ]]
43 else
44         rm -rf mkw32
45         mkdir mkw32{,/{build,$jtop}}
46 fi
47 cd mkw32/build
48 export CFLAGS='-Os -march=i486 -mtune=pentium-mmx'
49 export CPPFLAGS='-DJUPPRC_BUILTIN_NAME=\"jupp32rc\"'
50 (( contb )) || mksh ../../configure \
51     --prefix=c:/windows/system32 \
52     --sysconfdir=c:/windows/system32 \
53     --disable-dependency-tracking \
54     --disable-curses \
55     --disable-termcap \
56     --disable-search-libs \
57     --disable-getpwnam \
58     --disable-termidx \
59     --enable-win32reloc
60 make AM_CFLAGS="$extrawarnings"
61 if (( nopkg )); then
62         ln -f joe.exe jupp.exe
63         ln -sf ../../jupprc .
64         exit 0
65 fi
66 cp charmaps/* syntax/* ../$jtop/
67 cp jmacsrc joerc jpicorc jstarrc ../$jtop/
68 cp joe.exe ../$jtop/jupp32.exe
69 cd ../..
70 cp COPYING mkw32/$jtop/copying.txt
71 cp /bin/cygwin1.dll mkw32/$jtop/
72 cp joe.txt mkw32/$jtop/jupp32.txt
73 cp jupprc mkw32/$jtop/jupp32rc
74 cd mkw32/$jtop
75 :>setup.inf
76 for x in *; do
77         [[ $x = *[A-Z]* ]] || continue
78         mv "$x" ../_TMP
79         typeset -l lc
80         lc=$x
81         mv ../_TMP "$lc"
82 done
83 sed -b -e "s!@jwin@!$jupp!g" -e "s!@ts@!$(date -u +%m/%d/%Y)!g" \
84     <../../setup.inf | while IFS= read -r line; do
85         if [[ $line = '@files@'* ]]; then
86                 stat -c '%n=1,,%s\r' *
87         else
88                 print -r -- "$line"
89         fi
90 done >setup.inf
91 sed -bi "/^setup.inf=1,,/s/^.*\$/$(stat -c '%n=1,,%s\r' setup.inf)/" setup.inf
92 sed -bi "/^setup.inf=1,,/s/^.*\$/$(stat -c '%n=1,,%s\r' setup.inf)/" setup.inf
93 chmod 444 *
94 cd ..
95 zip -D -X -9 -k ../JWIN31$jWIN.ZIP $jtop/*
96 cd ..
97 ls -l JWIN31$jWIN.ZIP
98 rm -rf mkw32