tzlib directory re-added; the installer can now be built using either zlib or libbz2, simply by tweaking the Makefile. - vaccinewars - be a doctor and try to vaccinate the world (HTM) git clone git://src.adamsgaard.dk/vaccinewars (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 6780b52840675ea0a7894175e01f4b4b3524bed0 (DIR) parent b8595f6d1113ac14460a14a483184ae6fe888229 (HTM) Author: Ben Webb <ben@salilab.org> Date: Sun, 29 Sep 2002 16:07:19 +0000 zlib directory re-added; the installer can now be built using either zlib or libbz2, simply by tweaking the Makefile. Diffstat: M win32/Makefile | 32 ++++++++++++++++++++----------- M win32/makeinstall.c | 78 +++++++++++++++++++++++-------- M win32/setup.c | 125 ++++++++++++++++++++++--------- M win32/setup.rc | 2 +- A win32/zlib/Makefile.nocygwin | 155 +++++++++++++++++++++++++++++++ A win32/zlib/README.zlib | 6 ++++++ 6 files changed, 332 insertions(+), 66 deletions(-) --- (DIR) diff --git a/win32/Makefile b/win32/Makefile t@@ -1,33 +1,43 @@ +# Use these flags to use libbz2 for compression +#LIBZ = bzlib/libbz2.a +#COMPFLAGS = -DLIBBZ2 + +# Use these flags to use libz for compression +LIBZ = zlib/libz.a +COMPFLAGS = + +CFLAGS = -Wall -mno-cygwin ${COMPFLAGS} + all: setup makeinstall uninstall clean: /bin/rm -f *.o *.res uninstall.exe setup.exe makeinstall.exe core *~ - /bin/rm -f installfiles.bz2 manifest + /bin/rm -f installfiles.z manifest setup: setup.o util.o guifunc.o setup.res - gcc -Wall -mno-cygwin -mwindows -o setup setup.o util.o guifunc.o setup.res bzlib/libbz2.a -lcomctl32 -lole32 -luuid + gcc ${CFLAGS} -mwindows -o setup setup.o util.o guifunc.o setup.res ${LIBZ} -lcomctl32 -lole32 -luuid strip setup.exe uninstall: uninstall.o util.o guifunc.o uninstall.res - gcc -Wall -mno-cygwin -mwindows -o uninstall uninstall.o util.o guifunc.o uninstall.res + gcc ${CFLAGS} -mwindows -o uninstall uninstall.o util.o guifunc.o uninstall.res strip uninstall.exe uninstall.o: uninstall.c util.h guifunc.h - gcc -Wall -mno-cygwin -c uninstall.c + gcc ${CFLAGS} -c uninstall.c uninstall.res: uninstall.rc windres -O coff -o uninstall.res uninstall.rc setup.o: setup.c contid.h util.h guifunc.h - gcc -Wall -mno-cygwin -c setup.c + gcc ${CFLAGS} -c setup.c util.o: util.c util.h - gcc -Wall -mno-cygwin -c util.c + gcc ${CFLAGS} -c util.c guifunc.o: guifunc.c guifunc.h - gcc -Wall -mno-cygwin -c guifunc.c + gcc ${CFLAGS} -c guifunc.c -manifest installfiles.bz2: filelist makeinstall uninstall +manifest installfiles.z: filelist makeinstall uninstall sed -e 's/LICENCE/licence.txt/' < ../doc/index.html > index.html sed -e 's/LICENCE/licence.txt/' < ../doc/developer.html > developer.html sed -e 's/example-cfg/example-cfg.txt/' < ../doc/configfile.html > configfile.html t@@ -38,11 +48,11 @@ manifest installfiles.bz2: filelist makeinstall uninstall /bin/rm -f index.html configfile.html developer.html licence.txt /bin/rm -f example-cfg.txt readme.txt -setup.res: setup.rc dialogs.rc contid.h manifest installfiles.bz2 +setup.res: setup.rc dialogs.rc contid.h manifest installfiles.z windres -O coff -o setup.res setup.rc makeinstall: makeinstall.o util.o - gcc -Wall -mno-cygwin -o makeinstall makeinstall.o util.o bzlib/libbz2.a + gcc ${CFLAGS} -o makeinstall makeinstall.o util.o ${LIBZ} makeinstall.o: makeinstall.c util.h - gcc -Wall -mno-cygwin -c makeinstall.c + gcc ${CFLAGS} -c makeinstall.c (DIR) diff --git a/win32/makeinstall.c b/win32/makeinstall.c t@@ -23,7 +23,11 @@ #include <windows.h> #include <stdio.h> #include <stdlib.h> -#include "bzlib/bzlib.h" +#ifdef LIBBZ2 +# include "bzlib/bzlib.h" +#else +# include "zlib/zlib.h" +#endif #include "util.h" char *read_line(HANDLE hin) t@@ -203,23 +207,34 @@ int main() char *inbuf, *outbuf; int status, count; bstr *str; - bz_stream bz; +#ifdef LIBBZ2 + bz_stream z; +#else + z_stream z; +#endif idata = ReadInstallData(); - fout = CreateFile("installfiles.bz2", GENERIC_WRITE, 0, NULL, + fout = CreateFile("installfiles.z", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); outbuf = bmalloc(BUFFER_SIZE); inbuf = bmalloc(BUFFER_SIZE); - bz.bzalloc = NULL; - bz.bzfree = NULL; - bz.opaque = NULL; - BZ2_bzCompressInit(&bz, COMPRESSION, 0, 30); - bz.avail_in = 0; - bz.next_out = outbuf; - bz.avail_out = BUFFER_SIZE; +#ifdef LIBBZ2 + z.bzalloc = NULL; + z.bzfree = NULL; + z.opaque = NULL; + BZ2_bzCompressInit(&z, COMPRESSION, 0, 30); +#else + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = Z_NULL; + deflateInit(&z, COMPRESSION); +#endif + z.avail_in = 0; + z.next_out = outbuf; + z.avail_out = BUFFER_SIZE; filept = NULL; fin = NULL; t@@ -229,8 +244,8 @@ int main() } while (fin != INVALID_HANDLE_VALUE) { - if (bz.avail_in == 0) { - bz.next_in = inbuf; + if (z.avail_in == 0) { + z.next_in = inbuf; bytes_read = 0; while (!bytes_read && fin) { if (!ReadFile(fin, inbuf, BUFFER_SIZE, &bytes_read, NULL)) { t@@ -241,27 +256,48 @@ int main() if (!bytes_read) OpenNextFile(idata->instfiles, &filept, &fin); } - bz.avail_in = bytes_read; + z.avail_in = bytes_read; } - status = BZ2_bzCompress(&bz, bz.avail_in == 0 ? BZ_FINISH : BZ_RUN); - count = BUFFER_SIZE - bz.avail_out; +#ifdef LIBBZ2 + status = BZ2_bzCompress(&z, z.avail_in == 0 ? BZ_FINISH : BZ_RUN); +#else + status = deflate(&z, z.avail_in == 0 ? Z_FINISH : Z_NO_FLUSH); +#endif + count = BUFFER_SIZE - z.avail_out; if (!WriteFile(fout, outbuf, count, &bytes_written, NULL)) { printf("Write error\n"); } - bz.next_out = outbuf; - bz.avail_out = BUFFER_SIZE; + z.next_out = outbuf; + z.avail_out = BUFFER_SIZE; + +#ifdef LIBBZ2 if (status == BZ_STREAM_END) { break; } else if (status != BZ_RUN_OK && status != BZ_FINISH_OK) { printf("Unexpected bzlib status: %d\n", status); break; } +#else + if (status == Z_STREAM_END) { + break; + } else if (status != Z_OK) { + printf("Unexpected libz status: %d\n", status); + break; + } +#endif } +#ifdef LIBBZ2 printf("Written compressed data: raw %d, compressed %d\n", - bz.total_in_lo32, bz.total_out_lo32); - bytes_written = bz.total_out_lo32; - BZ2_bzCompressEnd(&bz); + z.total_in_lo32, z.total_out_lo32); + bytes_written = z.total_out_lo32; + BZ2_bzCompressEnd(&z); +#else + printf("Written compressed data: raw %ld, compressed %ld\n", + z.total_in, z.total_out); + bytes_written = z.total_out; + deflateEnd(&z); +#endif CloseHandle(fout); t@@ -309,7 +345,9 @@ int main() return 0; } +#ifdef LIBBZ2 void bz_internal_error(int errcode) { printf("bzip error %d\n", errcode); } +#endif (DIR) diff --git a/win32/setup.c b/win32/setup.c t@@ -25,7 +25,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "bzlib/bzlib.h" +#ifdef LIBBZ2 +# include "bzlib/bzlib.h" +#else +# include "zlib/zlib.h" +#endif #include <shlobj.h> #include "contid.h" t@@ -429,7 +433,11 @@ char *GetFirstFile(InstFiles *filelist, DWORD totalsize) DWORD bufsiz; char *inbuf, *outbuf; int status; - bz_stream bz; +#ifdef LIBBZ2 + bz_stream z; +#else + z_stream z; +#endif if (!filelist) return NULL; t@@ -441,22 +449,42 @@ char *GetFirstFile(InstFiles *filelist, DWORD totalsize) bufsiz = filelist->filesize; outbuf = bmalloc(bufsiz + 1); - bz.bzalloc = NULL; - bz.bzfree = NULL; - bz.opaque = NULL; - bz.next_in = inbuf; - bz.avail_in = totalsize; - - BZ2_bzDecompressInit(&bz, 0, 0); - bz.next_out = outbuf; - bz.avail_out = bufsiz; +#ifdef LIBBZ2 + z.bzalloc = NULL; + z.bzfree = NULL; + z.opaque = NULL; + BZ2_bzDecompressInit(&z, 0, 0); +#else + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = Z_NULL; + inflateInit(&z); +#endif + + z.next_in = inbuf; + z.avail_in = totalsize; + z.next_out = outbuf; + z.avail_out = bufsiz; while (1) { - status = BZ2_bzDecompress(&bz); - if ((status != BZ_OK && status != BZ_STREAM_END) || bz.avail_out == 0) +#ifdef LIBBZ2 + status = BZ2_bzDecompress(&z); + if ((status != BZ_OK && status != BZ_STREAM_END) || z.avail_out == 0) { + break; + } +#else + status = inflate(&z, Z_SYNC_FLUSH); + if ((status != Z_OK && status != Z_STREAM_END) || z.avail_out == 0) { break; + } +#endif } - BZ2_bzDecompressEnd(&bz); + +#ifdef LIBBZ2 + BZ2_bzDecompressEnd(&z); +#else + inflateEnd(&z); +#endif outbuf[bufsiz] = '\0'; return outbuf; t@@ -827,7 +855,11 @@ DWORD WINAPI DoInstall(LPVOID lpParam) BOOL skipfile, service_installed; char *inbuf, *outbuf; int status, count; - bz_stream bz; +#ifdef LIBBZ2 + bz_stream z; +#else + z_stream z; +#endif InstFiles *listpt; InstData *oldidata; t@@ -877,28 +909,40 @@ DWORD WINAPI DoInstall(LPVOID lpParam) outbuf = bmalloc(BUFFER_SIZE); - bz.bzalloc = NULL; - bz.bzfree = NULL; - bz.opaque = NULL; - bz.next_in = inbuf; - bz.avail_in = idata->totalsize; - - BZ2_bzDecompressInit(&bz, 0, 0); - bz.next_out = outbuf; - bz.avail_out = BUFFER_SIZE; +#ifdef LIBBZ2 + z.bzalloc = NULL; + z.bzfree = NULL; + z.opaque = NULL; + BZ2_bzDecompressInit(&z, 0, 0); +#else + z.zalloc = Z_NULL; + z.zfree = Z_NULL; + z.opaque = Z_NULL; + inflateInit(&z); +#endif + + z.avail_in = idata->totalsize; + z.next_in = inbuf; + z.next_out = outbuf; + z.avail_out = BUFFER_SIZE; while (1) { - status = BZ2_bzDecompress(&bz); +#ifdef LIBBZ2 + status = BZ2_bzDecompress(&z); if (status == BZ_OK || status == BZ_STREAM_END) { - count = BUFFER_SIZE - bz.avail_out; - bz.next_out = outbuf; +#else + status = inflate(&z, Z_SYNC_FLUSH); + if (status == Z_OK || status == Z_STREAM_END) { +#endif + count = BUFFER_SIZE - z.avail_out; + z.next_out = outbuf; while (count >= fileleft) { if (fileleft && !skipfile - && !WriteFile(fout, bz.next_out, fileleft, &bytes_written, NULL)) { + && !WriteFile(fout, z.next_out, fileleft, &bytes_written, NULL)) { printf("Write error\n"); } count -= fileleft; - bz.next_out += fileleft; + z.next_out += fileleft; if (!OpenNextOutput(&fout, idata->instfiles, idata->keepfiles, &listpt, &fileleft, logf, &skipfile)) break; t@@ -906,18 +950,29 @@ DWORD WINAPI DoInstall(LPVOID lpParam) if (fout == INVALID_HANDLE_VALUE) break; if (count && !skipfile - && !WriteFile(fout, bz.next_out, count, &bytes_written, NULL)) { + && !WriteFile(fout, z.next_out, count, &bytes_written, NULL)) { printf("Write error\n"); } fileleft -= count; - bz.next_out = outbuf; - bz.avail_out = BUFFER_SIZE; + z.next_out = outbuf; + z.avail_out = BUFFER_SIZE; + } +#ifdef LIBBZ2 + if (status != BZ_OK) { + break; } - if (status != BZ_OK) +#else + if (status != Z_OK) { break; + } +#endif } - BZ2_bzDecompressEnd(&bz); +#ifdef LIBBZ2 + BZ2_bzDecompressEnd(&z); +#else + inflateEnd(&z); +#endif if (!skipfile) CloseHandle(fout); t@@ -1175,6 +1230,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, return 0; } +#ifdef LIBBZ2 void bz_internal_error(int errcode) { } +#endif (DIR) diff --git a/win32/setup.rc b/win32/setup.rc t@@ -3,6 +3,6 @@ 1 24 "setup.manifest" 0 INSTLIST "manifest" -1 INSTFILE "installfiles.bz2" +1 INSTFILE "installfiles.z" #include "dialogs.rc" (DIR) diff --git a/win32/zlib/Makefile.nocygwin b/win32/zlib/Makefile.nocygwin t@@ -0,0 +1,155 @@ +# Makefile for zlib +# Copyright (C) 1995-1998 Jean-loup Gailly. +# For conditions of distribution and use, see copyright notice in zlib.h + +# To compile and test, type: +# ./configure; make test +# The call of configure is optional if you don't have special requirements +# If you wish to build zlib as a shared library, use: ./configure -s + +# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: +# make install +# To install in $HOME instead of /usr/local, use: +# make install prefix=$HOME + +CC=gcc -mno-cygwin + +CFLAGS=-O +#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 +#CFLAGS=-g -DDEBUG +#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ +# -Wstrict-prototypes -Wmissing-prototypes + +LDFLAGS=-L. -lz +LDSHARED=$(CC) +CPP=$(CC) -E + +VER=1.1.3 +LIBS=libz.a +SHAREDLIB=libz.so + +AR=ar rc +RANLIB=ranlib +TAR=tar +SHELL=/bin/sh + +prefix = /usr/local +exec_prefix = ${prefix} +libdir = ${exec_prefix}/lib +includedir = ${prefix}/include + +OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ + zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o + +OBJA = +# to use the asm code: make OBJA=match.o + +DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \ + algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ + nt/Make*[a-z0-9] nt/zlib.dnt amiga/Make*.??? os2/M*.os2 os2/zlib.def \ + contrib/RE*.contrib contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \ + contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/asm[56]86/*.?86 \ + contrib/asm[56]86/*.S contrib/iostream/*.cpp \ + contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ + contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \ + contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? \ + contrib/delphi*/*.??? + +all: libz.a + +libz.a: $(OBJS) $(OBJA) + $(AR) $@ $(OBJS) $(OBJA) + -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 + +match.o: match.S + $(CPP) match.S > _match.s + $(CC) -c _match.s + mv _match.o match.o + rm -f _match.s + +$(SHAREDLIB).$(VER): $(OBJS) + $(LDSHARED) -o $@ $(OBJS) + rm -f $(SHAREDLIB) $(SHAREDLIB).1 + ln -s $@ $(SHAREDLIB) + ln -s $@ $(SHAREDLIB).1 + +install: $(LIBS) + -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi + -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi + cp zlib.h zconf.h $(includedir) + chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h + cp $(LIBS) $(libdir) + cd $(libdir); chmod 755 $(LIBS) + -@(cd $(libdir); $(RANLIB) libz.a || true) >/dev/null 2>&1 + cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \ + rm -f $(SHAREDLIB) $(SHAREDLIB).1; \ + ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB); \ + ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ + (ldconfig || true) >/dev/null 2>&1; \ + fi +# The ranlib in install is needed on NeXTSTEP which checks file times +# ldconfig is for Linux + +uninstall: + cd $(includedir); \ + v=$(VER); \ + if test -f zlib.h; then \ + v=`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`; \ + rm -f zlib.h zconf.h; \ + fi; \ + cd $(libdir); rm -f libz.a; \ + if test -f $(SHAREDLIB).$$v; then \ + rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ + fi + +clean: + rm -f *.o *~ libz.a libz.so* foo.gz so_locations \ + _match.s maketree + +distclean: clean + +zip: + mv Makefile Makefile~; cp -p Makefile.in Makefile + rm -f test.c ztest*.c contrib/minizip/test.zip + v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ + zip -ul9 zlib$$v $(DISTFILES) + mv Makefile~ Makefile + +dist: + mv Makefile Makefile~; cp -p Makefile.in Makefile + rm -f test.c ztest*.c contrib/minizip/test.zip + d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ + rm -f $$d.tar.gz; \ + if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ + files=""; \ + for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ + cd ..; \ + GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ + if test ! -d $$d; then rm -f $$d; fi + mv Makefile~ Makefile + +tags: + etags *.[ch] + +depend: + makedepend -- $(CFLAGS) -- *.[ch] + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +adler32.o: zlib.h zconf.h +compress.o: zlib.h zconf.h +crc32.o: zlib.h zconf.h +deflate.o: deflate.h zutil.h zlib.h zconf.h +gzio.o: zutil.h zlib.h zconf.h +infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h +infcodes.o: zutil.h zlib.h zconf.h +infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h +inffast.o: zutil.h zlib.h zconf.h inftrees.h +inffast.o: infblock.h infcodes.h infutil.h inffast.h +inflate.o: zutil.h zlib.h zconf.h infblock.h +inftrees.o: zutil.h zlib.h zconf.h inftrees.h +infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h +minigzip.o: zlib.h zconf.h +trees.o: deflate.h zutil.h zlib.h zconf.h trees.h +uncompr.o: zlib.h zconf.h +zutil.o: zutil.h zlib.h zconf.h (DIR) diff --git a/win32/zlib/README.zlib b/win32/zlib/README.zlib t@@ -0,0 +1,6 @@ +If you are intending to build the Win32 installer for dopewars, then place +the zlib distribution into this directory. The installer expects to +statically link with the file libz.a in this directory; the libz.a file +included in the Cygwin distribution should _not_ be used, as this requires +the CYGWIN.DLL file, which is not a standard Windows DLL. Use the +Makefile.nocygwin file to compile zlib, as this adds in the -mno-cygwin flag.