From: Mika Lindqvist Date: Sat, 2 Apr 2016 00:11:43 +0000 (+0300) Subject: Add support for ARM ACLE instructions. X-Git-Tag: 1.9.9-b1~660^2~22^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02f5b0b9c6666573024d3b149adc64ecc785caee;p=thirdparty%2Fzlib-ng.git Add support for ARM ACLE instructions. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 31ee6e3b5..a84da4adc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,9 @@ option(WITH_OPTIM "Build with optimisation" ON) option(WITH_NEW_STRATEGIES "Use new strategies" ON) option(WITH_NATIVE_INSTRUCTIONS "Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF) +if("${ARCH}" MATCHES "arm") + option(WITH_ACLE "Build with ACLE CRC" OFF) +endif() if(${CMAKE_C_COMPILER} MATCHES "icc" OR ${CMAKE_C_COMPILER} MATCHES "icpc" OR ${CMAKE_C_COMPILER} MATCHES "icl") if(WITH_NATIVE_INSTRUCTIONS) @@ -86,6 +89,9 @@ elseif(MSVC) if(NOT ${ARCH} MATCHES "AMD64") set(SSE2FLAG "/arch:SSE2") endif() + if("${ARCH}" MATCHES "arm") + add_definitions("-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1") + endif() if(WITH_NATIVE_INSTRUCTIONS) message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not supported on this configuration") endif() @@ -117,10 +123,16 @@ else() set(PCLMULFLAG "-mpclmul") endif() endif() + if("${ARCH}" MATCHES "arm") + set(ACLEFLAG "-march=armv8-a+crc") + endif() else(NOT NATIVEFLAG) set(SSE2FLAG ${NATIVEFLAG}) set(SSE4FLAG ${NATIVEFLAG}) set(PCLMULFLAG ${NATIVEFLAG}) + if("${ARCH}" MATCHES "arm") + set(ACLEFLAG "${NATIVEFLAG}") + endif() endif(NOT NATIVEFLAG) endif() @@ -128,6 +140,9 @@ add_feature_info(ZLIB_COMPAT ZLIB_COMPAT "Provide a zlib-compatible API") add_feature_info(WITH_GZFILEOP WITH_GZFILEOP "Compile with support for gzFile-related functions") add_feature_info(WITH_OPTIM WITH_OPTIM "Build with optimisation") add_feature_info(WITH_NEW_STRATEGIES WITH_NEW_STRATEGIES "Use new strategies") +if("${ARCH}" MATCHES "arm") + add_feature_info(WITH_ACLE WITH_ACLE "Build with ACLE CRC") +endif() # # Check to see if we have large file support @@ -323,37 +338,44 @@ else() add_definitions(-DX86 -DUNALIGNED_OK -DUNROLL_LESS) add_feature_info(SSE2 1 "Support the SSE2 instruction set, using \"${SSE2FLAG}\"") endif() - -if("${ARCHDIR}" MATCHES "arch/x86" AND WITH_OPTIM) - add_definitions("-DX86_CPUID") - set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/x86.c) - if(HAVE_SSE42_INTRIN) - add_definitions(-DX86_SSE4_2_CRC_HASH) - set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/insert_string_sse.c) - add_feature_info(SSE4_CRC 1 "Support CRC hash generation using the SSE4.2 instruction set, using \"${SSE4FLAG}\"") - add_intrinsics_option(${SSE4FLAG}) - if(WITH_NEW_STRATEGIES) - add_definitions(-DX86_QUICK_STRATEGY) - set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/deflate_quick.c) - add_feature_info(SSE4DEFLATE 1 "Support SSE4.2-accelerated quick decompression") - endif() - endif() - if(HAVE_SSE2_INTRIN) - add_definitions(-DX86_SSE2_FILL_WINDOW) - set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/fill_window_sse.c) - if(NOT ${ARCH} MATCHES "x86_64") - add_intrinsics_option(${SSE2FLAG}) +if(WITH_OPTIM) + if("${ARCH}" MATCHES "arm") + if(WITH_ACLE) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/crc32_acle.c ${ARCHDIR}/insert_string_acle.c) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ACLEFLAG}") + add_definitions("-DARM_ACLE_CRC_HASH") + add_feature_info(ACLE_CRC 1 "Support CRC hash generation using the ACLE instruction set, using \"${ACLEFLAG}\"") endif() - endif() - if(HAVE_PCLMULQDQ_INTRIN) - add_definitions(-DX86_PCLMULQDQ_CRC) - set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/crc_folding.c ${ARCHDIR}/crc_pclmulqdq.c) - add_intrinsics_option(${PCLMULFLAG}) + elseif("${ARCHDIR}" MATCHES "arch/x86") + add_definitions("-DX86_CPUID") + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/x86.c) if(HAVE_SSE42_INTRIN) - add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${PCLMULFLAG}\"") - else() - add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${PCLMULFLAG} ${SSE4FLAG}\"") + add_definitions(-DX86_SSE4_2_CRC_HASH) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/insert_string_sse.c) + add_feature_info(SSE4_CRC 1 "Support CRC hash generation using the SSE4.2 instruction set, using \"${SSE4FLAG}\"") add_intrinsics_option(${SSE4FLAG}) + if(WITH_NEW_STRATEGIES) + add_definitions(-DX86_QUICK_STRATEGY) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/deflate_quick.c) + add_feature_info(SSE4DEFLATE 1 "Support SSE4.2-accelerated quick decompression") + endif() + endif() + if(HAVE_SSE2_INTRIN) + add_definitions(-DX86_SSE2_FILL_WINDOW) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/fill_window_sse.c) + if(NOT ${ARCH} MATCHES "x86_64") + add_intrinsics_option(${SSE2FLAG}) + endif() + endif() + if(HAVE_PCLMULQDQ_INTRIN) + add_definitions(-DX86_PCLMULQDQ_CRC) + set(ZLIB_ARCH_SRCS ${ZLIB_ARCH_SRCS} ${ARCHDIR}/crc_folding.c ${ARCHDIR}/crc_pclmulqdq.c) + add_intrinsics_option(${PCLMULFLAG}) + if(HAVE_SSE42_INTRIN) + add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${PCLMULFLAG}\"") + else() + add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${PCLMULFLAG} ${SSE4FLAG}\"") + endif() endif() endif() endif() diff --git a/Makefile.in b/Makefile.in index c50e51263..9ad751279 100644 --- a/Makefile.in +++ b/Makefile.in @@ -323,6 +323,8 @@ inffast.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SRC inftrees.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h trees.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/trees.h zutil.o: $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h $(SRCDIR)/zlib.h zconf.h +arch/arm/crc32_acle.o: zconf.h +arch/arm/insert_string_acle.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h arch/x86/crc_folding.o: $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h arch/x86/crc_pclmulqdq.o: $(SRCDIR)/arch/x86/x86.h $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h arch/x86/deflate_quick.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h @@ -342,6 +344,8 @@ inffast.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SR inftrees.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h trees.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/trees.h zutil.lo: $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h $(SRCDIR)/zlib.h zconf.h +arch/arm/crc32_acle.lo: zconf.h +arch/arm/insert_string_acle.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h arch/x86/crc_folding.lo: $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h arch/x86/crc_pclmulqdq.lo: $(SRCDIR)/arch/x86/x86.h $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h arch/x86/deflate_quick.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h diff --git a/arch/arm/Makefile.in b/arch/arm/Makefile.in index be8c18545..a2c96bd06 100644 --- a/arch/arm/Makefile.in +++ b/arch/arm/Makefile.in @@ -11,11 +11,39 @@ SRCDIR=. SRCTOP=../.. TOPDIR=$(SRCTOP) -all: +all: crc32_acle.o crc32_acle.lo insert_string_acle.o insert_string_acle.lo +crc32_acle.o: $(SRCDIR)/crc32_acle.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c + +crc32_acle.lo: $(SRCDIR)/crc32_acle.c + $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c + +insert_string_acle.o: $(SRCDIR)/insert_string_acle.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c + +insert_string_acle.lo: $(SRCDIR)/insert_string_acle.c + $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c mostlyclean: clean clean: - rm -f *.o *.lo *~ \ + rm -f *.o *.lo *~ rm -rf objs rm -f *.gcda *.gcno *.gcov + +distclean: + rm -f Makefile + +depend: + makedepend -Y -- $(CFLAGS) -- $(SRCDIR)/*.c + makedepend -Y -a -o.lo -- $(SFLAGS) -- $(SRCDIR)/*.c + @sed "s=^$(SRCDIR)/\([a-zA-Z0-9_]*\.\(lo\|o\):\)=\1=g" < Makefile > Makefile.tmp + @mv -f Makefile.tmp Makefile + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +crc32_acle.o: $(TOPDIR)/zconf.h +insert_string_acle.o: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h + +crc32_acle.lo: $(TOPDIR)/zconf.h +insert_string_acle.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h diff --git a/arch/arm/crc32_acle.c b/arch/arm/crc32_acle.c new file mode 100644 index 000000000..829311829 --- /dev/null +++ b/arch/arm/crc32_acle.c @@ -0,0 +1,71 @@ +/* crc32_acle.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler + * Copyright (C) 2016 Yang Zhang + * For conditions of distribution and use, see copyright notice in zlib.h + * +*/ + +#ifdef __ARM_FEATURE_CRC32 +#include +#include "zconf.h" +#ifdef __linux__ +# include +#endif + +uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, size_t len) +{ + register uint32_t c; + register const uint16_t *buf2; + register const uint32_t *buf4; + + c = ~crc; + if (len && ((ptrdiff_t)buf & 1)) { + c = __crc32b(c, *buf++); + len--; + } + + if ((len > 2) && ((ptrdiff_t)buf & 2)) { + buf2 = (const uint16_t *) buf; + c = __crc32h(c, *buf2++); + len -= 2; + buf4 = (const uint32_t *) buf2; + } else { + buf4 = (const uint32_t *) buf; + } + +#ifndef UNROLL_LESS + while (len >= 32) { + c = __crc32w(c, *buf4++); + c = __crc32w(c, *buf4++); + c = __crc32w(c, *buf4++); + c = __crc32w(c, *buf4++); + c = __crc32w(c, *buf4++); + c = __crc32w(c, *buf4++); + c = __crc32w(c, *buf4++); + c = __crc32w(c, *buf4++); + len -= 32; + } +#endif + + while (len >= 4) { + c = __crc32w(c, *buf4++); + len -= 4; + } + + if (len >= 2) { + buf2 = (const uint16_t *) buf4; + c = __crc32h(c, *buf2++); + len -= 2; + buf = (const unsigned char *) buf2; + } else { + buf = (const unsigned char *) buf4; + } + + if (len) { + c = __crc32b(c, *buf); + } + + c = ~c; + return c; +} +#endif diff --git a/arch/arm/insert_string_acle.c b/arch/arm/insert_string_acle.c new file mode 100644 index 000000000..985b726cf --- /dev/null +++ b/arch/arm/insert_string_acle.c @@ -0,0 +1,50 @@ +/* insert_string_acle.c -- insert_string variant using ACLE's CRC instructions + * + * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + */ + +#ifdef __ARM_FEATURE_CRC32 +#include +#endif +#include "deflate.h" + +/* =========================================================================== + * Insert string str in the dictionary and set match_head to the previous head + * of the hash chain (the most recent string with same hash key). Return + * the previous length of the hash chain. + * IN assertion: all calls to to INSERT_STRING are made with consecutive + * input characters and the first MIN_MATCH bytes of str are valid + * (except for the last MIN_MATCH-1 bytes of the input file). + */ +#ifdef ARM_ACLE_CRC_HASH +Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned int count) { + Pos p, lp; + + if (unlikely(count == 0)) { + return s->prev[str & s->w_mask]; + } + + lp = str + count - 1; /* last position */ + + for (p = str; p <= lp; p++) { + unsigned *ip, val, h, hm; + + ip = (unsigned *)&s->window[p]; + val = *ip; + + if (s->level >= TRIGGER_LEVEL) + val &= 0xFFFFFF; + + h = __crc32w(0, val); + hm = h & s->hash_mask; + + if (s->head[hm] != p) { + s->prev[p & s->w_mask] = s->head[hm]; + s->head[hm] = p; + } + } + return s->prev[lp & s->w_mask]; +} +#endif diff --git a/configure b/configure index 8e68b7faf..903698a05 100755 --- a/configure +++ b/configure @@ -105,6 +105,7 @@ compat=0 cover=0 build32=0 build64=0 +buildacle=0 native=0 sse2flag="-msse2" sse4flag="-msse4" @@ -145,6 +146,7 @@ case "$1" in echo ' configure [--zlib-compat] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log echo ' [--static] [--32] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log + echo ' [--acle]' | tee -a configure.log exit 0 ;; -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; @@ -162,6 +164,7 @@ case "$1" in --cover) cover=1; shift ;; -3* | --32) build32=1; shift ;; -6* | --64) build64=1; shift ;; + --acle) buildacle=1; shift ;; -n | --native) native=1; shift ;; -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;; --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; @@ -195,7 +198,7 @@ show() # check for gcc vs. cc and set compile and link flags based on the system identified by uname cat > $test.c <> configure.log 2>&1; then if test $build32 -ne 1; then ARCH=$GCC_ARCH fi ;; + arm) + if test "${uname}" = "eabi"; then + uname=arm + fi + if test $buildacle -eq 1; then + if test $native -eq 0; then + ARCH=armv8-a+crc + else + ARCH=native + fi + fi ;; esac CFLAGS="${CFLAGS--O3}" if test -n "${ARCHS}"; then @@ -808,7 +822,7 @@ case "${ARCH}" in ;; # ARM specific optimizations - armv3l | armv4b | armv4l | armv4tl | armv5tel | armv5tejl | armv6l | armv6hl | armv7l | armv7hl | armv7hnl) + arm | armv3l | armv4b | armv4l | armv4tl | armv5tel | armv5tejl | armv6l | armv6hl | armv7l | armv7hl | armv7hnl | armv8-a | armv8-a+crc | armv8.1-a) ARCHDIR=arch/arm case "${ARCH}" in @@ -818,6 +832,14 @@ case "${ARCH}" in CFLAGS="${CFLAGS} -DUNALIGNED_OK -DUNROLL_LESS" SFLAGS="${SFLAGS} -DUNALIGNED_OK -DUNROLL_LESS" ;; + armv8-a+crc | armv8.1-a) + CFLAGS="-march=${ARCH} ${CFLAGS} -DARM_ACLE_CRC_HASH -DUNALIGNED_OK -DUNROLL_LESS" + SFLAGS="-march=${ARCH} ${SFLAGS} -DARM_ACLE_CRC_HASH -DUNALIGNED_OK -DUNROLL_LESS" + + ARCH_STATIC_OBJS="${ARCH_STATIC_OBJS} crc32_acle.o insert_string_acle.o" + ARCH_SHARED_OBJS="${ARCH_SHARED_OBJS} crc32_acle.lo insert_string_acle.lo" + + ;; esac ;; diff --git a/crc32.c b/crc32.c index 4f71b2202..000a86808 100644 --- a/crc32.c +++ b/crc32.c @@ -16,12 +16,14 @@ #elif defined(WIN32) || defined(_WIN32) # define LITTLE_ENDIAN 1234 # define BIG_ENDIAN 4321 -# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) +# if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) # define BYTE_ORDER LITTLE_ENDIAN # else # error Unknown endianness! # endif -#elif __APPLE__ +#elif defined(__linux__) +# include +#elif defined(__APPLE__) || defined(__arm__) # include #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) # include @@ -65,6 +67,10 @@ ZLIB_INTERNAL uint32_t crc32_generic(uint32_t, const unsigned char *, z_off64_t); +#ifdef __ARM_FEATURE_CRC32 +extern uint32_t crc32_acle(uint32_t, const unsigned char *, z_off64_t); +#endif + #if BYTE_ORDER == LITTLE_ENDIAN ZLIB_INTERNAL uint32_t crc32_little(uint32_t, const unsigned char *, size_t); #elif BYTE_ORDER == BIG_ENDIAN @@ -217,7 +223,11 @@ uint32_t ZEXPORT crc32_z(uint32_t crc, const unsigned char *buf, size_t len) { if (sizeof(void *) == sizeof(ptrdiff_t)) { #if BYTE_ORDER == LITTLE_ENDIAN +# if __ARM_FEATURE_CRC32 + return crc32_acle(crc, buf, len); +# else return crc32_little(crc, buf, len); +# endif #elif BYTE_ORDER == BIG_ENDIAN return crc32_big(crc, buf, len); #endif diff --git a/deflate_p.h b/deflate_p.h index a446544da..4860ff9a5 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -34,6 +34,8 @@ void flush_pending(z_stream *strm); #ifdef X86_SSE4_2_CRC_HASH extern Pos insert_string_sse(deflate_state *const s, const Pos str, unsigned int count); +#elif defined(ARM_ACLE_CRC_HASH) +extern Pos insert_string_acle(deflate_state *const s, const Pos str, unsigned int count); #endif static inline Pos insert_string_c(deflate_state *const s, const Pos str, unsigned int count) { @@ -56,7 +58,11 @@ static inline Pos insert_string(deflate_state *const s, const Pos str, unsigned if (x86_cpu_has_sse42) return insert_string_sse(s, str, count); #endif +#if defined(ARM_ACLE_CRC_HASH) + return insert_string_acle(s, str, count); +#else return insert_string_c(s, str, count); +#endif } /* =========================================================================== diff --git a/win32/Makefile.arm b/win32/Makefile.arm new file mode 100644 index 000000000..fee2d0548 --- /dev/null +++ b/win32/Makefile.arm @@ -0,0 +1,161 @@ +# Makefile for zlib using Microsoft (Visual) C +# zlib is copyright (C) 1995-2006 Jean-loup Gailly and Mark Adler +# +# Usage: +# nmake -f win32/Makefile.arm (standard build) +# nmake -f win32/Makefile.arm LOC=-DFOO (nonstandard build) + +# The toplevel directory of the source tree. +# +TOP = . + +# optional build flags +LOC = + +# variables +STATICLIB = zlib.lib +SHAREDLIB = zlib1.dll +IMPLIB = zdll.lib + +CC = cl +LD = link +AR = lib +RC = rc +CP = copy /y +CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) +WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DUNALIGNED_OK -DUNROLL_LESS -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 +LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest +ARFLAGS = -nologo +RCFLAGS = /dARM /r +DEFFILE = zlib.def +WITH_GZFILEOP = +WITH_ACLE = + +OBJS = adler32.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_slow.obj \ + infback.obj inflate.obj inftrees.obj inffast.obj match.obj trees.obj uncompr.obj zutil.obj +!if "$(WITH_GZFILEOP)" != "" +WFLAGS = $(WFLAGS) -DWITH_GZFILEOP +OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj +DEFFILE = zlibcompat.def +!endif +!if "$(WITH_ACLE)" != "" +WFLAGS = $(WFLAGS) -DARM_ACLE_CRC_HASH +OBJS = $(OBJS) crc32_acle.obj insert_string_acle.obj +!endif + +# targets +all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ + example.exe minigzip.exe example_d.exe minigzip_d.exe + +zconf: $(TOP)/zconf.h.in + $(CP) $(TOP)\zconf.h.in $(TOP)\zconf.h + +$(STATICLIB): zconf $(OBJS) + $(AR) $(ARFLAGS) -out:$@ $(OBJS) + +$(IMPLIB): $(SHAREDLIB) + +$(SHAREDLIB): zconf $(TOP)/win32/zlib.def $(OBJS) zlib1.res + $(LD) $(LDFLAGS) -def:$(TOP)/win32/$(DEFFILE) -dll -implib:$(IMPLIB) \ + -out:$@ -base:0x5A4C0000 $(OBJS) zlib1.res + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;2 + +example.exe: example.obj $(STATICLIB) + $(LD) $(LDFLAGS) example.obj $(STATICLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +minigzip.exe: minigzip.obj $(STATICLIB) + $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +example_d.exe: example.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +minigzip_d.exe: minigzip.obj $(IMPLIB) + $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) + if exist $@.manifest \ + mt -nologo -manifest $@.manifest -outputresource:$@;1 + +{$(TOP)}.c.obj: + $(CC) -c $(WFLAGS) $(CFLAGS) $< + +{$(TOP)/arch/arm}.c.obj: + $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< + +{$(TOP)/test}.c.obj: + $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< + +$(TOP)/zconf.h: zconf + +adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h + +compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h + +crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h + +deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h + +gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h + +infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ + $(TOP)/inffast.h $(TOP)/inffixed.h + +inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ + $(TOP)/inffast.h + +inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ + $(TOP)/inffast.h $(TOP)/inffixed.h + +inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h + +match.obj: $(TOP)/match.c $(TOP)/deflate.h + +trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h + +uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h + +zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h + +example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h + +minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h + +zlib1.res: $(TOP)/win32/zlib1.rc + $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc + +# testing +test: example.exe minigzip.exe + example + echo hello world | minigzip | minigzip -d + +testdll: example_d.exe minigzip_d.exe + example_d + echo hello world | minigzip_d | minigzip_d -d + + +# cleanup +clean: + -del $(STATICLIB) + -del $(SHAREDLIB) + -del $(IMPLIB) + -del *.obj + -del *.res + -del *.exp + -del *.exe + -del *.pdb + -del *.manifest + -del foo.gz + +distclean: clean + -del zconf.h