File: zipwin.sh

package info (click to toggle)
allegro4.2 2:4.2.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 24,436 kB
  • ctags: 14,714
  • sloc: ansic: 126,425; asm: 17,011; cpp: 3,846; sh: 2,120; objc: 925; makefile: 715; python: 216; pascal: 179; perl: 73
file content (363 lines) | stat: -rwxr-xr-x 10,108 bytes parent folder | download | duplicates (4)
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#! /bin/sh
#
#  Shell script to create a Windows binary distribution. This will
#  compile the DLL files using MSVC or Cygwin, generate the batch file and
#  associated helpers needed for end users to build the example programs,
#  and finally zip up the results.
#
#  Note! If you use Cygwin to generate the DLLs make sure you have set up
#  your MINGDIR and ALLEGRO_USE_CYGWIN environment variables correctly.
#
#  It should be run from the root of the Allegro directory, eg.
#  bash misc/zipwin.sh, so that it can find misc/vcvars.c and misc/askq.c.


# check we have a filename, and strip off the path and extension from it
if [ $# -ne 1 ]; then
   echo "Usage: zipwin <archive_name>" 1>&2
   exit 1
fi

name=$(echo "$1" | sed -e 's/.*[\\\/]//; s/\.zip//')


# check that MSVC or Cygwin is available
if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
   if [ "$MINGDIR" = "" ]; then
      echo "You need to set up Cygwin before running this script" 1>&2
      exit 1
   fi
else
   if [ "$MSVCDIR" = "" ]; then
      echo "You need to set up MSVC (run vcvars32.bat) before running this script" 1>&2
      exit 1
   fi
fi


# check that we are in the Allegro dir
if [ ! -f include/allegro.h ]; then
   echo "Oops, you don't appear to be in the root of the Allegro directory" 1>&2
   exit 1
fi


# convert Allegro to MSVC or Cygwin format
if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
   ./fix.sh mingw32 --dtou
else
   ./fix.sh msvc --utod
fi


# delete all generated files
echo "Cleaning the Allegro tree..."
make.exe -s veryclean


# generate DLL export definition files
misc/fixdll.sh


# generate dependencies
echo "Generating dependencies..."
make.exe depend


# build all three libs
make.exe lib
make.exe lib DEBUGMODE=1
make.exe lib PROFILEMODE=1


# find what library version (DLL filename) the batch file should build
ver=`sed -n -e "s/LIBRARY_VERSION = \(.*\)/\1/p" makefile.ver`


# compile vcvars
echo "Compiling vcvars.exe..."
if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
   gcc -Wl,--subsystem,console -o vcvars.exe misc/vcvars.c -ladvapi32
else
   cl -nologo misc/vcvars.c advapi32.lib
   rm vcvars.obj
fi


# compile askq
echo "Compiling askq.exe..."
if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
   gcc -Wl,--subsystem,console -o askq.exe misc/askq.c
else
   cl -nologo misc/askq.c
   rm askq.obj
fi


# generate the setup code for msvcmake.bat (this bit checks for vcvars32,
# and builds the import libs)
echo "Generating msvcmake.bat..."

cat > msvcmake.bat << END_OF_BATCH
@echo off

rem Batch file for installing the precompiled Allegro DLL files,
rem and building the MSVC example and test programs.

rem Generated by misc/zipwin.sh

if not exist include\\allegro.h goto no_allegro

if not "%MSVCDIR%" == "" goto got_msvc

if "%VCVARS%" == "" goto no_vcvars

call "%VCVARS%"
goto got_msvc

:no_vcvars

echo MSVC environment variables not found: running vcvars.exe to look for them
vcvars.exe msvcmake.bat

goto the_end

:got_msvc

call fix.bat msvc --quick

echo Generating release mode import library
copy lib\\msvc\\allegro.def lib\\msvc\\alleg$ver.def > nul
lib /nologo /machine:ix86 /def:lib\\msvc\\alleg$ver.def /out:lib\\msvc\\alleg.lib

echo Generating debug mode import library
copy lib\\msvc\\allegro.def lib\\msvc\\alld$ver.def > nul
lib /nologo /machine:ix86 /def:lib\\msvc\\alld$ver.def /out:lib\\msvc\\alld.lib /debugtype:cv

echo Generating profile mode import library
copy lib\\msvc\\allegro.def lib\\msvc\\allp$ver.def > nul
lib /nologo /machine:ix86 /def:lib\\msvc\\allp$ver.def /out:lib\\msvc\\allp.lib

echo Compiling test and example programs
END_OF_BATCH


# If running Cygwin, we need to do some trickery
if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
   ./fix.sh msvc --utod
   export MSVCDIR="MSVCDIR"
   make.exe depend UNIX_TOOLS=1

   echo "Fooling the MSVC makefile ..."
   cp lib/mingw32/*.dll lib/msvc/
   make.exe -t lib
fi


# SED script for converting make -n output into a funky batch file
cat > _fix1.sed << END_OF_SED

# remove any echo messages from the make output
/^echo/d

# strip out references to runner.exe
s/obj\/msvc\/runner.exe //

# turn program name slashes into DOS format
s/\\//\\\\/g

# make sure were are using command.com copy, rather than cp
s/^.*cat tools.*msvc.plugins.h/copy \/B tools\\\\plugins\\\\*.inc obj\\\\msvc\\\\plugins.h/

# add blank lines, to make the batch output more readable
s/^\([^@]*\)$/\\
\1/

# turn any @ argfile references into an echo+tmpfile sequence
s/\(.*\) @ \(.*\)/\\
echo \2 > _tmp.arg\\
\1 @_tmp.arg\\
del _tmp.arg/

END_OF_SED


# second SED script, for splitting long echos into multiple segments
cat > _fix2.sed << END_OF_SED

s/echo \(................................................[^ ]*\) \(........*\) \(>>*\) _tmp\.arg/echo \1 \3 _tmp.arg\\
echo \2 >> _tmp.arg/

END_OF_SED


# run make -n, to see what commands are needed for building this thing
echo "Running make -n, to generate the command list..."

make.exe -n | \
   sed -f _fix1.sed | \
   sed -f _fix2.sed | \
   sed -f _fix2.sed | \
   sed -f _fix2.sed | \
   sed -f _fix2.sed | \
   sed -f _fix2.sed | \
   sed -f _fix2.sed | \
   sed -f _fix2.sed | \
   sed -f _fix2.sed \
      >> msvcmake.bat

rm _fix1.sed _fix2.sed

if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
   unset MSVCDIR
fi

# finish writing msvcmake.bat (this bit asks whether to install the headers,
# libs, and DLL files)
cat >> msvcmake.bat << END_OF_BATCH
askq.exe Would you like to copy the headers and libs to your MSVC directories
if errorlevel 1 goto no_lib_copy

if not "%MSVCDIR%" == "" set _VC_DIR_=%MSVCDIR%

echo Copying libraries
copy lib\\msvc\\*.lib "%_VC_DIR_%\\lib"

echo Copying allegro.h
copy include\\allegro.h "%_VC_DIR_%\\include"

echo Copying winalleg.h
copy include\\winalleg.h "%_VC_DIR_%\\include"

echo Copying module headers
md "%_VC_DIR_%\\include\\allegro"
copy include\\allegro\\*.h "%_VC_DIR_%\\include\\allegro"

echo Copying inline headers
md "%_VC_DIR_%\\include\\allegro\\inline"
copy include\\allegro\\inline\\*.inl "%_VC_DIR_%\\include\\allegro\\inline"

echo Copying internal headers
md "%_VC_DIR_%\\include\\allegro\\internal"
copy include\\allegro\\internal\\*.h "%_VC_DIR_%\\include\\allegro\\internal"

echo Copying platform headers
md "%_VC_DIR_%\\include\\allegro\\platform"
copy include\\allegro\\platform\\aintwin.h "%_VC_DIR_%\\include\\allegro\\platform"
copy include\\allegro\\platform\\al386vc.h "%_VC_DIR_%\\include\\allegro\\platform"
copy include\\allegro\\platform\\almsvc.h "%_VC_DIR_%\\include\\allegro\\platform"
copy include\\allegro\\platform\\alplatf.h "%_VC_DIR_%\\include\\allegro\\platform"
copy include\\allegro\\platform\\alwin.h "%_VC_DIR_%\\include\\allegro\\platform"

set _VC_DIR_=

goto lib_copy_done

:no_lib_copy
echo Library and header files were not installed.
echo You can find the headers in the allegro\\include directory,
echo and the libs in allegro\\lib\\msvc\\

:lib_copy_done

askq.exe Would you like to copy the DLL files to your Windows system directory
if errorlevel 1 goto no_dll_copy

if "%OS%" == "Windows_NT" set _WIN_DIR_=%SYSTEMROOT%\\system32
if "%OS%" == "" set _WIN_DIR_=%windir%\\system

echo Copying DLL files to %_WIN_DIR_%
copy lib\\msvc\\*.dll %_WIN_DIR_%

set _WIN_DIR_=

goto dll_copy_done

:no_dll_copy
echo DLL files were not installed.
echo You can find them in allegro\\lib\\msvc\\

:dll_copy_done

echo.
echo All done: Allegro is now installed on your system!

goto the_end

:no_allegro

echo Can't find the Allegro library source files! To install this binary
echo distribution, you must also have a copy of the library sources, so
echo that I can compile the support programs and convert the documentation.

:the_end

END_OF_BATCH


# generate the readme
cat > $name.txt << END_OF_README
     ______   ___    ___
    /\\  _  \\ /\\_ \\  /\\_ \\
    \\ \\ \\L\\ \\\\//\\ \\ \\//\\ \\      __     __   _ __   ___ 
     \\ \\  __ \\ \\ \\ \\  \\ \\ \\   /'__\`\\ /'_ \`\\/\\\`'__\\/ __\`\\
      \\ \\ \\/\\ \\ \\_\\ \\_ \\_\\ \\_/\\  __//\\ \\L\\ \\ \\ \\//\\ \\L\\ \\
       \\ \\_\\ \\_\\/\\____\\/\\____\\ \\____\\ \\____ \\ \\_\\\\ \\____/
	\\/_/\\/_/\\/____/\\/____/\\/____/\\/___L\\ \\/_/ \\/___/
				       /\\____/
				       \\_/__/


		 Windows binary distribution.



This package contains precompiled copies of the Windows DLL files for the 
Allegro library, to save you having to compile it yourself. This is not a 
complete distribution of Allegro, as it does not contain any of the 
documentation, example programs, headers, etc. You need to download the full 
source version, and then just unzip this package over the top of it.

To install, run the batch file msvcmake.bat, either from a command prompt or 
by double-clicking on it from the Windows explorer. This will hopefully be 
able to autodetect all the details of where to find your compiler, and will 
automatically compile the various support programs that come with Allegro.

At the end of the install process you will be asked whether to copy libs and 
headers into your compiler directories, and whether to install the DLL files 
into the Windows system directory. You should normally say yes here, but if 
you prefer, you can leave these files in the Allegro directory, and then 
specify the paths to them later on, when you come to compile your own 
programs using Allegro.

There are three versions of the DLL included in this zip:

   alleg$ver.dll is the normal optimised version
   alld$ver.dll is the debugging build, and should be used during development
   allp$ver.dll is a profiling build, for collecting performance info

For more general information about using Allegro, see the readme.txt and 
docs/build/msvc.txt files from the source distribution.

END_OF_README


# build the main zip archive
echo "Creating $name.zip..."
cd ..
if [ -f $name.zip ]; then rm $name.zip; fi

if [ "$ALLEGRO_USE_CYGWIN" = "1" ]; then
   unix2dos allegro/$name.txt
   unix2dos allegro/msvcmake.bat
fi

zip -9 $name.zip allegro/$name.txt allegro/msvcmake.bat allegro/vcvars.exe allegro/askq.exe allegro/lib/msvc/*.dll


# clean up after ourselves
cd allegro
rm $name.txt msvcmake.bat vcvars.exe askq.exe


echo "Done!"