From a72350256977eebfa72748be18f9efee232095f5 Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 8 Jun 2019 11:59:19 +0100 Subject: [PATCH 1/8] Fix test paths. Test files were moved into a subdirectory in commit f6f3326c. --- makefile.msc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/makefile.msc b/makefile.msc index e58b016..1058c54 100644 --- a/makefile.msc +++ b/makefile.msc @@ -24,25 +24,25 @@ lib: $(OBJS) lib /out:libbz2.lib $(OBJS) test: bzip2 - type words1 - .\\bzip2 -1 < tests\sample1.ref > sample1.rb2 - .\\bzip2 -2 < tests\sample2.ref > sample2.rb2 - .\\bzip2 -3 < tests\sample3.ref > sample3.rb2 - .\\bzip2 -d < tests\sample1.bz2 > sample1.tst - .\\bzip2 -d < tests\sample2.bz2 > sample2.tst - .\\bzip2 -ds < tests\sample3.bz2 > sample3.tst + type tests\words1 + .\\bzip2 -1 < tests\sample1.ref > tests\sample1.rb2 + .\\bzip2 -2 < tests\sample2.ref > tests\sample2.rb2 + .\\bzip2 -3 < tests\sample3.ref > tests\sample3.rb2 + .\\bzip2 -d < tests\sample1.bz2 > tests\sample1.tst + .\\bzip2 -d < tests\sample2.bz2 > tests\sample2.tst + .\\bzip2 -ds < tests\sample3.bz2 > tests\sample3.tst @echo All six of the fc's should find no differences. @echo If fc finds an error on sample3.bz2, this could be @echo because WinZip's 'TAR file smart CR/LF conversion' @echo is too clever for its own good. Disable this option. @echo The correct size for sample3.ref is 120,244. If it @echo is 150,251, WinZip has messed it up. - fc tests\sample1.bz2 sample1.rb2 - fc tests\sample2.bz2 sample2.rb2 - fc tests\sample3.bz2 sample3.rb2 - fc tests\sample1.tst sample1.ref - fc tests\sample2.tst sample2.ref - fc tests\sample3.tst sample3.ref + fc tests\sample1.bz2 tests\sample1.rb2 + fc tests\sample2.bz2 tests\sample2.rb2 + fc tests\sample3.bz2 tests\sample3.rb2 + fc tests\sample1.tst tests\sample1.ref + fc tests\sample2.tst tests\sample2.ref + fc tests\sample3.tst tests\sample3.ref From a85d910eef9091ebd7bd5b400491cf0ece848d68 Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 8 Jun 2019 12:03:39 +0100 Subject: [PATCH 2/8] Ignore Windows build outputs. --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index b964615..b727158 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,8 @@ builddir # vscode config directory .vscode + +# Windows build outputs +*.exe +*.lib +*.obj From 2b374b821145b5df4a05f30e8627d5f6a441183f Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 8 Jun 2019 12:06:17 +0100 Subject: [PATCH 3/8] Replace the deprecated cl -o option with /Fe. From https://github.com/philr/bzip2-windows/blob/v1.0.6.1/patches/01-replace_deprecated_compile_options.diff --- makefile.msc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/makefile.msc b/makefile.msc index 1058c54..70f1a94 100644 --- a/makefile.msc +++ b/makefile.msc @@ -17,8 +17,8 @@ OBJS= blocksort.obj \ all: lib bzip2 test bzip2: lib - $(CC) $(CFLAGS) -o bzip2 bzip2.c libbz2.lib setargv.obj - $(CC) $(CFLAGS) -o bzip2recover bzip2recover.c + $(CC) $(CFLAGS) /Febzip2 bzip2.c libbz2.lib setargv.obj + $(CC) $(CFLAGS) /Febzip2recover bzip2recover.c lib: $(OBJS) lib /out:libbz2.lib $(OBJS) @@ -59,5 +59,5 @@ clean: del tests\sample3.tst .c.obj: - $(CC) $(CFLAGS) -c $*.c -o $*.obj + $(CC) $(CFLAGS) -c $*.c /Fe$*.obj From e0f6201b4014c6d2c247be96c186bc8bd1ba6baa Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 8 Jun 2019 12:19:15 +0100 Subject: [PATCH 4/8] Build bz2-1.dll and dynamically link executables. From https://github.com/philr/bzip2-windows/blob/v1.0.6.1/patches/02-build_dll.diff --- .gitignore | 2 ++ makefile.msc | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b727158..fcec2ec 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,8 @@ builddir .vscode # Windows build outputs +*.dll *.exe +*.exp *.lib *.obj diff --git a/makefile.msc b/makefile.msc index 70f1a94..cf83297 100644 --- a/makefile.msc +++ b/makefile.msc @@ -14,14 +14,17 @@ OBJS= blocksort.obj \ decompress.obj \ bzlib.obj -all: lib bzip2 test +all: dll lib bzip2 test -bzip2: lib - $(CC) $(CFLAGS) /Febzip2 bzip2.c libbz2.lib setargv.obj +bzip2: dll + $(CC) $(CFLAGS) /Febzip2 bzip2.c bz2-1.lib setargv.obj $(CC) $(CFLAGS) /Febzip2recover bzip2recover.c +dll: $(OBJS) libbz2.def + link /dll /implib:bz2-1.lib /out:bz2-1.dll /def:libbz2.def $(OBJS) + lib: $(OBJS) - lib /out:libbz2.lib $(OBJS) + lib /out:bz2-static.lib $(OBJS) test: bzip2 type tests\words1 @@ -48,7 +51,10 @@ test: bzip2 clean: del *.obj - del libbz2.lib + del bz2-1.dll + del bz2-1.exp + del bz2-1.lib + del bz2-static.lib del bzip2.exe del bzip2recover.exe del tests\sample1.rb2 From a715b86f578854289711b645fe7a6548efc71fd6 Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 8 Jun 2019 12:33:18 +0100 Subject: [PATCH 5/8] Add version information to the dll and exe files. From https://github.com/philr/bzip2-windows/blob/v1.0.6.1/patches/03-add_version_resource.diff --- .gitignore | 1 + makefile.msc | 23 ++++++++++++++++++----- version.rc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 version.rc diff --git a/.gitignore b/.gitignore index fcec2ec..174c33a 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ builddir *.exp *.lib *.obj +*.res diff --git a/makefile.msc b/makefile.msc index cf83297..abc4004 100644 --- a/makefile.msc +++ b/makefile.msc @@ -5,6 +5,7 @@ CC=cl CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo +RC=rc OBJS= blocksort.obj \ huffman.obj \ @@ -16,16 +17,25 @@ OBJS= blocksort.obj \ all: dll lib bzip2 test -bzip2: dll - $(CC) $(CFLAGS) /Febzip2 bzip2.c bz2-1.lib setargv.obj - $(CC) $(CFLAGS) /Febzip2recover bzip2recover.c +bzip2: dll bzip2.res bzip2recover.res + $(CC) $(CFLAGS) /Febzip2 bzip2.c bz2-1.lib setargv.obj bzip2.res + $(CC) $(CFLAGS) /Febzip2recover bzip2recover.c bzip2recover.res -dll: $(OBJS) libbz2.def - link /dll /implib:bz2-1.lib /out:bz2-1.dll /def:libbz2.def $(OBJS) +dll: $(OBJS) libbz2.def bz2-1.res + link /dll /implib:bz2-1.lib /out:bz2-1.dll /def:libbz2.def $(OBJS) bz2-1.res lib: $(OBJS) lib /out:bz2-static.lib $(OBJS) +bzip2.res: + $(RC) /fobzip2.res /d BZIP2 version.rc + +bzip2recover.res: + $(RC) /fobzip2recover.res /d BZIP2RECOVER version.rc + +bz2-1.res: + $(RC) /fobz2-1.res /d BZ21DLL version.rc + test: bzip2 type tests\words1 .\\bzip2 -1 < tests\sample1.ref > tests\sample1.rb2 @@ -54,9 +64,12 @@ clean: del bz2-1.dll del bz2-1.exp del bz2-1.lib + del bz2-1.res del bz2-static.lib del bzip2.exe + del bzip2.res del bzip2recover.exe + del bzip2recover.res del tests\sample1.rb2 del tests\sample2.rb2 del tests\sample3.rb2 diff --git a/version.rc b/version.rc new file mode 100644 index 0000000..7776f81 --- /dev/null +++ b/version.rc @@ -0,0 +1,48 @@ +#include + +LANGUAGE 0x09,0x01 + +1 VERSIONINFO + FILEVERSION 1,0,7,0 + PRODUCTVERSION 1,0,7,0 + FILEFLAGSMASK 0x3fL + FILEFLAGS 0x00L + FILEOS VOS__WINDOWS32 +#if defined(BZ21DLL) + FILETYPE VFT_DLL +#else + FILETYPE VFT_APP +#endif + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + // VALUE "Comments", "\0" + VALUE "CompanyName", "bzip2, https://gitlab.com/federicomenaquintero/bzip2\0" + VALUE "FileDescription", "bzip2\0" + VALUE "FileVersion", "1.0.7\0" +#if defined(BZ21DLL) + VALUE "InternalName", "bz2-1\0" + VALUE "OriginalFilename", "bz2-1.dll\0" +#elif defined(BZIP2) + VALUE "InternalName", "bzip2\0" + VALUE "OriginalFilename", "bzip2.exe\0" +#elif defined(BZIP2RECOVER) + VALUE "InternalName", "bzip2recover\0" + VALUE "OriginalFilename", "bzip2recover.exe\0" +#endif + VALUE "LegalCopyright", "Copyright (C) 1996-2010 Julian Seward . Copyright (C) 2019 Federico Mena Quintero . All rights reserved.\0" + // VALUE "LegalTrademarks", "\0" + // VALUE "PrivateBuild", "\0" + VALUE "ProductName", "bzip2\0" + VALUE "ProductVersion", "1.0.7\0" + // VALUE "SpecialBuild", "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 0x4b0 + END +END From 6c19bf79c959eb923c24643d6d7d4096a1858d6a Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 8 Jun 2019 12:35:31 +0100 Subject: [PATCH 6/8] Remove the unsupported DESCRIPTION statement. This causes a warning during the build: libbz2.def(2) : warning LNK4017: DESCRIPTION statement not supported for the target platform; ignored From https://github.com/philr/bzip2-windows/blob/v1.0.6.1/patches/04-remove_unsupported_description_option.diff --- libbz2.def | 1 - 1 file changed, 1 deletion(-) diff --git a/libbz2.def b/libbz2.def index 80fc2d1..f480c05 100644 --- a/libbz2.def +++ b/libbz2.def @@ -1,5 +1,4 @@ LIBRARY bz2-1 -DESCRIPTION "bz2: library for data compression" EXPORTS BZ2_bzCompressInit BZ2_bzCompress From 21c0d94bc4bcd4d033b46e991b216346916f4bca Mon Sep 17 00:00:00 2001 From: Phil Ross Date: Sat, 8 Jun 2019 12:47:57 +0100 Subject: [PATCH 7/8] Update README and makefile.msc comments with Windows build changes. --- COMPILING.md | 10 +++++----- makefile.msc | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/COMPILING.md b/COMPILING.md index 04e090c..61a9eb1 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -189,13 +189,13 @@ make install ## Using nmake on Windows -At least using MS Visual C++ 6, you can build from the unmodified -sources with [makefile.msc](makefile.msc) by issuing, in a command -shell: +Bzip2 can be built with Microsoft Visual Studio 2013 or later. From a Visual +Studio Tools Command Prompt run: ``` nmake -f makefile.msc ``` -(you may need to first run the MSVC-provided script `VCVARS32.BAT` -so as to set up paths to the MSVC tools correctly). +The build will produce `bzip2.exe` and `bzip2recover.exe` files that are dependent +on `bz2-1.dll` and the Microsoft C Runtime library. Dynamic import and static +libraries are also built: `bz2-1.lib` and `bz2-static.lib`. diff --git a/makefile.msc b/makefile.msc index abc4004..5585f34 100644 --- a/makefile.msc +++ b/makefile.msc @@ -1,4 +1,4 @@ -# Makefile for Microsoft Visual C++ 6.0 +# Makefile for Microsoft Visual Studio 2013 and later. # usage: nmake -f makefile.msc # K.M. Syring (syring@gsf.de) # Fixed up by JRS for bzip2-0.9.5d release. From 6fdb85cb75da88a59db9078ee898521711679e5e Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Fri, 14 Jun 2019 09:22:46 -0500 Subject: [PATCH 8/8] List CMake as being available, too --- COMPILING.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/COMPILING.md b/COMPILING.md index 61a9eb1..c1c9143 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -3,14 +3,17 @@ The following build systems are available for Bzip2: * [Meson]: This is our preferred build system for Unix-like systems. +* [CMake]: Build tool for Unix and Windows. * GNU [Autotools]: Another traditional build system for Unix-like systems. -* nmake: Unsupported; used only for Windows. +* nmake: Unsupported; used only for Windows and Microsoft Visual + Studio 2013 or later. Autotools is only supported on Unix-like OSes, nmake is only for Windows, meson works for both. [Meson]: https://mesonbuild.com +[CMake]: https://cmake.org [Autotools]: https://autotools.io/index.html