Fixup programs/{Makefile,lz4cli.c,lz4io.c} to build with Andrew Wu's build-djgpp...
authorLouis P. Santillan <lpsantil@gmail.com>
Tue, 26 May 2015 04:41:45 +0000 (21:41 -0700)
committerLouis P. Santillan <lpsantil@gmail.com>
Tue, 26 May 2015 04:41:45 +0000 (21:41 -0700)
README.DJ [new file with mode: 0644]
programs/Makefile
programs/lz4cli.c
programs/lz4io.c

diff --git a/README.DJ b/README.DJ
new file mode 100644 (file)
index 0000000..4d6cbcd
--- /dev/null
+++ b/README.DJ
@@ -0,0 +1,19 @@
+# lz4 for DOS/djgpp
+This file details on how to compile lz4.exe, and liblz4.a for use on DOS/djgpp using
+Andrew Wu's build-djgpp cross compilers ([GH][0], [Binaries][1]) on OSX, Linux.
+
+## Setup
+* Download a djgpp tarball [Binaries][1] for your platform.  
+* Extract and install it (`tar jxvf djgpp-linux64-gcc492.tar.bz2`).  Note the path.  We'll assume `/home/user/djgpp`.
+* Add the `bin` folder to your `PATH`.  In bash, do `export PATH=/home/user/djgpp/bin:$PATH`.
+
+## Building LZ4 binary for DOS
+* Run `make` substituting the cross compiler for `CC` and `AR`, e.g., `CC=i586-pc-msdosdjgpp-gcc AR=i586-pc-msdosdjgpp-ar make lz4programs`
+* `lz4` and `lz4.exe` are then in the `programs/` subfolder.
+
+## Building LZ4 library for DOS
+* Run `make` substituting the cross compiler for `CC` and `AR`, e.g., `CC=i586-pc-msdosdjgpp-gcc AR=i586-pc-msdosdjgpp-ar make lz4lib-djgpp`
+* `liblz4.z`, `lz4.h`, `lz4hc.h`, `lz4frame.h`, and `xxhash.h` are then in the `lib/` subfolder.
+
+[0]: https://github.com/andrewwutw/build-djgpp
+[1]: https://github.com/andrewwutw/build-djgpp/releases
index 39335db..5e818e4 100644 (file)
@@ -39,7 +39,7 @@ RELEASE?= r129
 DESTDIR?=
 PREFIX ?= /usr/local
 CFLAGS ?= -O3
-CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\"
+CFLAGS += -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\"
 FLAGS  := -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
 
 BINDIR := $(PREFIX)/bin
index 970856d..fc5a34a 100644 (file)
 *****************************/
 #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32)
 #  include <io.h>       /* _isatty */
+#  if defined(__DJGPP__)
+#    include <unistd.h>
+#    define _isatty isatty
+#    define _fileno fileno
+#  endif
 #  ifdef __MINGW32__
    int _fileno(FILE *stream);   /* MINGW somehow forgets to include this prototype into <stdio.h> */
 #  endif
index 209f5ed..10f3020 100644 (file)
 #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32)
 #  include <fcntl.h>   /* _O_BINARY */
 #  include <io.h>      /* _setmode, _fileno, _get_osfhandle */
-#  define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY)
-#  include <Windows.h> /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */
-#  define SET_SPARSE_FILE_MODE(file) { DWORD dw; DeviceIoControl((HANDLE) _get_osfhandle(_fileno(file)), FSCTL_SET_SPARSE, 0, 0, 0, 0, &dw, 0); }
-#  if defined(_MSC_VER) && (_MSC_VER >= 1400)  /* Avoid MSVC fseek()'s 2GiB barrier */
-#    define fseek _fseeki64
+#  if !defined(__DJGPP__)
+#    define SET_BINARY_MODE(file) _setmode(_fileno(file), _O_BINARY)
+#    include <Windows.h> /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */
+#    define SET_SPARSE_FILE_MODE(file) { DWORD dw; DeviceIoControl((HANDLE) _get_osfhandle(_fileno(file)), FSCTL_SET_SPARSE, 0, 0, 0, 0, &dw, 0); }
+#    if defined(_MSC_VER) && (_MSC_VER >= 1400)  /* Avoid MSVC fseek()'s 2GiB barrier */
+#      define fseek _fseeki64
+#    endif
+#  else
+#    define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
+#    define SET_SPARSE_FILE_MODE(file)
 #  endif
 #else
 #  define SET_BINARY_MODE(file)