Skip to content

Commit

Permalink
Add support for name mangling
Browse files Browse the repository at this point in the history
This is useful when zlib-ng is embedded into another library,
such as ITK: https://itk.org/

Closes #1025.

Co-authored-by: Mika Lindqvist <[email protected]>
  • Loading branch information
2 people authored and Dead2 committed Oct 9, 2021
1 parent 92107a9 commit 714f624
Show file tree
Hide file tree
Showing 26 changed files with 767 additions and 272 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.c text
*.h text
Makefile text
configure text eol=lf
testCVEinputs.sh text eol=lf
33 changes: 29 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if(NOT CMAKE_C_STANDARD IN_LIST VALID_C_STANDARDS)
endif()

# Parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h _zlib_h_contents)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h.in _zlib_h_contents)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9]+.[0-9]+.[0-9]+).*\".*"
"\\1" ZLIB_HEADER_VERSION ${_zlib_h_contents})
string(REGEX REPLACE ".*#define[ \t]+ZLIBNG_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
Expand Down Expand Up @@ -86,6 +86,10 @@ option(WITH_INFLATE_STRICT "Build with strict inflate distance checking" OFF)
option(WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances" OFF)
option(WITH_UNALIGNED "Support unaligned reads on platforms that support it" ON)

set(ZLIB_SYMBOL_PREFIX "" CACHE STRING "Give this prefix to all publicly exported symbols.
Useful when embedding into a larger library.
Default is no prefix (empty prefix).")

# Add multi-choice option
set(WITH_SANITIZER AUTO CACHE STRING "Enable sanitizer support")
set_property(CACHE WITH_SANITIZER PROPERTY STRINGS "Memory" "Address" "Undefined" "Thread")
Expand All @@ -111,6 +115,7 @@ endif()
option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF)

mark_as_advanced(FORCE
ZLIB_SYMBOL_PREFIX
ZLIB_DUAL_LINK
WITH_REDUCED_MEM
WITH_ACLE WITH_NEON
Expand Down Expand Up @@ -841,7 +846,8 @@ endif()

set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h
zlib${SUFFIX}.h
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h
)
set(ZLIB_PRIVATE_HDRS
adler32_p.h
Expand Down Expand Up @@ -901,7 +907,7 @@ set(ZLIB_GZFILE_PRIVATE_HDRS
)
set(ZLIB_GZFILE_SRCS
gzlib.c
gzread.c
${CMAKE_CURRENT_BINARY_DIR}/gzread.c
gzwrite.c
)

Expand Down Expand Up @@ -1040,6 +1046,23 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file(${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h.in
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gzread.c.in
${CMAKE_CURRENT_BINARY_DIR}/gzread.c @ONLY)


if (NOT ZLIB_SYMBOL_PREFIX STREQUAL "")
add_feature_info(ZLIB_SYMBOL_PREFIX ON "Publicly exported symbols have a custom prefix")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling${SUFFIX}.h.in
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h @ONLY)
else()
add_feature_info(ZLIB_SYMBOL_PREFIX OFF "Publicly exported symbols DO NOT have a custom prefix")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling.h.empty
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h COPYONLY)
endif()
# add_definitions(-DZLIB_SYMBOL_PREFIX=${ZLIB_SYMBOL_PREFIX}) # not needed


if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
install(TARGETS ${ZLIB_INSTALL_LIBRARIES}
Expand All @@ -1048,8 +1071,10 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
LIBRARY DESTINATION "${LIB_INSTALL_DIR}")
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
install(FILES zlib${SUFFIX}.h
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h
DESTINATION "${INC_INSTALL_DIR}" RENAME zlib${SUFFIX}.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h
DESTINATION "${INC_INSTALL_DIR}" RENAME zlib_name_mangling${SUFFIX}.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h
DESTINATION "${INC_INSTALL_DIR}" RENAME zconf${SUFFIX}.h)
endif()
Expand Down
32 changes: 25 additions & 7 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ EXE=
SRCDIR=.
INCLUDES=-I$(SRCDIR)

BUILDDIR=.

ARCHDIR=arch/generic
ARCH_STATIC_OBJS=
ARCH_SHARED_OBJS=
Expand Down Expand Up @@ -225,7 +227,7 @@ example_dict_fuzzer$(EXE): example_dict_fuzzer.o standalone_fuzz_target_runner.o
minigzip_fuzzer$(EXE): minigzip_fuzzer.o standalone_fuzz_target_runner.o $(OBJG) $(STATICLIB)
$(CC) $(LDFLAGS) -o $@ $(LIB_FUZZING_ENGINE) minigzip_fuzzer.o $(OBJG) $(STATICLIB) -lpthread

infcover.o: $(SRCDIR)/test/infcover.c $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h
infcover.o: $(SRCDIR)/test/infcover.c zlib$(SUFFIX).h zconf$(SUFFIX).h zlib_name_mangling$(SUFFIX).h
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/infcover.c

infcover$(EXE): infcover.o $(STATICLIB)
Expand Down Expand Up @@ -275,9 +277,24 @@ zlibrc.o: win32/zlib$(SUFFIX)1.rc
%.lo: $(SRCDIR)/%.c
$(CC) $(SFLAGS) -DPIC $(INCLUDES) -c -o $@ $<

$(OBJG): %.o: $(SRCDIR)/%.c
gzlib.o: $(SRCDIR)/gzlib.c
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<

gzlib.lo: $(SRCDIR)/gzlib.c
$(CC) $(SFLAGS) -DPIC -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<

gzread.o: gzread.c
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<

gzread.lo: gzread.c
$(CC) $(SFLAGS) -DPIC -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<

gzwrite.o: $(SRCDIR)/gzwrite.c
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<

gzwrite.lo: $(SRCDIR)/gzwrite.c
$(CC) $(SFLAGS) -DPIC -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<

$(SHAREDTARGET): $(PIC_OBJS) $(DEFFILE) $(RCOBJS)
ifneq ($(SHAREDTARGET),)
$(LDSHARED) $(CFLAGS) $(LDSHAREDFLAGS) $(LDFLAGS) -o $@ $(DEFFILE) $(PIC_OBJS) $(RCOBJS) $(LDSHAREDLIBC)
Expand Down Expand Up @@ -393,10 +410,11 @@ install-libs: install-shared install-static

install: install-libs
-@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
rm -f $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h
cp $(SRCDIR)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zlib$(SUFFIX).h
rm -f $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h $(DESTDIR)$(includedir)/zlib_name_mangling$(SUFFIX).h
cp zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zlib$(SUFFIX).h
cp zconf$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h
chmod 644 $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h
cp zlib_name_mangling$(SUFFIX).h $(DESTDIR)$(includedir)/zlib_name_mangling$(SUFFIX).h
chmod 644 $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h $(DESTDIR)$(includedir)/zlib_name_mangling$(SUFFIX).h

uninstall-static:
cd $(DESTDIR)$(libdir) && rm -f $(STATICLIB)
Expand All @@ -410,7 +428,7 @@ ifneq ($(IMPORTLIB),)
endif

uninstall: uninstall-static uninstall-shared
cd $(DESTDIR)$(includedir) && rm -f zlib$(SUFFIX).h zconf$(SUFFIX).h
cd $(DESTDIR)$(includedir) && rm -f zlib$(SUFFIX).h zconf$(SUFFIX).h zlib_name_mangling$(SUFFIX).h
cd $(DESTDIR)$(pkgconfigdir) && rm -f $(PKGFILE)

mostlyclean: clean
Expand All @@ -437,7 +455,7 @@ maintainer-clean: distclean
distclean: clean
@if [ -f $(ARCHDIR)/Makefile ]; then $(MAKE) -C $(ARCHDIR) distclean; fi
@if [ -f test/Makefile ]; then $(MAKE) -C test distclean; fi
rm -f $(PKGFILE) configure.log zconf.h zconf.h.cmakein
rm -f $(PKGFILE) configure.log zconf.h zconf.h.cmakein zlib$(SUFFIX).h zlib_name_mangling$(SUFFIX)}.h
-@rm -f .DS_Store
# Reset Makefile if building inside source tree
@if [ -f Makefile.in ]; then \
Expand Down
39 changes: 29 additions & 10 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ neonflag=
noltoflag="-fno-lto"
vgfmaflag="-march=z13"
vmxflag="-maltivec"
symbol_prefix=""
without_optimizations=0
without_new_strategies=0
reducedmem=0
Expand Down Expand Up @@ -150,6 +151,7 @@ case "$1" in
echo ' configure [--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 ' [--sprefix=SYMBOL_PREFIX] Adds a prefix to all exported symbols' | tee -a configure.log
echo ' [--warn] Enables extra compiler warnings' | tee -a configure.log
echo ' [--debug] Enables extra debug prints during operation' | tee -a configure.log
echo ' [--zlib-compat] Compiles for zlib-compatible API instead of zlib-ng API' | tee -a configure.log
Expand All @@ -171,12 +173,14 @@ case "$1" in
exit 0 ;;
-p*=* | --prefix=*) prefix=$(echo $1 | sed 's/.*=//'); shift ;;
-e*=* | --eprefix=*) exec_prefix=$(echo $1 | sed 's/.*=//'); shift ;;
-m*=* | --sprefix=*) symbol_prefix=$(echo $1 | sed 's/.*=//'); shift ;;
-l*=* | --libdir=*) libdir=$(echo $1 | sed 's/.*=//'); shift ;;
--sharedlibdir=*) sharedlibdir=$(echo $1 | sed 's/.*=//'); shift ;;
-i*=* | --includedir=*) includedir=$(echo $1 | sed 's/.*=//');shift ;;
-u*=* | --uname=*) uname=$(echo $1 | sed 's/.*=//');shift ;;
-p* | --prefix) prefix="$2"; shift; shift ;;
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
-m* | --sprefix) symbol_prefix="$2"; shift; shift ;;
-l* | --libdir) libdir="$2"; shift; shift ;;
-i* | --includedir) includedir="$2"; shift; shift ;;
-s* | --shared | --enable-shared) shared=1; shift ;;
Expand Down Expand Up @@ -282,15 +286,15 @@ MAPNAME=${LIBNAME2}.map

# extract zlib version numbers from zlib.h
if test $compat -eq 0; then
VER=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib-ng.h)
VER3=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib-ng.h)
VER2=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\.[0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib-ng.h)
VER1=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib-ng.h)
VER=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
VER3=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
VER2=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\.[0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
VER1=$(sed -n -e '/ZLIBNG_VERSION "/s/.*"\([0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib-ng.h.in)
else
VER=$(sed -n -e '/ZLIB_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib.h)
VER3=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib.h)
VER2=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\.[0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib.h)
VER1=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib.h)
VER=$(sed -n -e '/ZLIB_VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}/zlib.h.in)
VER3=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' < ${SRCDIR}/zlib.h.in)
VER2=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\.[0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib.h.in)
VER1=$(sed -n -e '/ZLIB_VERSION "/s/.*"\([0-9]*\)\..*/\1/p' < ${SRCDIR}/zlib.h.in)
fi

show $cc -c $test.c
Expand Down Expand Up @@ -790,9 +794,21 @@ else
echo "Checking for strerror... No." | tee -a configure.log
fi

# We need to remove zconf.h from source directory if building outside of it
# We need to remove consigured files (zconf.h etc) from source directory if building outside of it
if [ "$SRCDIR" != "$BUILDDIR" ]; then
rm -f $SRCDIR/zconf${SUFFIX}.h
rm -f $SRCDIR/zlib${SUFFIX}.h
rm -f $SRCDIR/zlib_name_mangling${SUFFIX}.h
fi

# Rename @ZLIB_SYMBOL_PREFIX@ to $symbol_prefix in gzread.c, zlib.h and zlib_name_mangling.h
sed < $SRCDIR/gzread.c.in "s/@ZLIB_SYMBOL_PREFIX@/$symbol_prefix/g" > gzread.c
sed < $SRCDIR/zlib${SUFFIX}.h.in "s/@ZLIB_SYMBOL_PREFIX@/$symbol_prefix/g" > zlib${SUFFIX}.h
if [[ ! -z $symbol_prefix ]]; then
sed < $SRCDIR/zlib_name_mangling${SUFFIX}.h.in "s/@ZLIB_SYMBOL_PREFIX@/$symbol_prefix/g" > zlib_name_mangling${SUFFIX}.h
else
# symbol_prefix is not set, copy the empty mangling header
cp -p $SRCDIR/zlib_name_mangling.h.empty zlib_name_mangling${SUFFIX}.h
fi

# copy clean zconf.h for subsequent edits
Expand Down Expand Up @@ -1755,6 +1771,7 @@ echo bindir = $bindir >> configure.log
echo libdir = $libdir >> configure.log
echo mandir = $mandir >> configure.log
echo prefix = $prefix >> configure.log
echo symbol_prefix = $symbol_prefix >> configure.log
echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log
echo sse2flag = $sse2flag >> configure.log
Expand Down Expand Up @@ -1814,6 +1831,7 @@ sed < $SRCDIR/Makefile.in "
/^prefix *=/s#=.*#= $prefix#
/^exec_prefix *=/s#=.*#= $exec_prefix#
/^bindir *=/s#=.*#= $bindir#
/^symbol_prefix *=/s#=.*#= $symbol_prefix#
/^libdir *=/s#=.*#= $libdir#
/^sharedlibdir *=/s#=.*#= $sharedlibdir#
/^includedir *=/s#=.*#= $includedir#
Expand Down Expand Up @@ -1887,7 +1905,7 @@ sed < $SRCDIR/$ARCHDIR/Makefile.in "
/^SUFFIX *=/s#=.*#=$SUFFIX#
/^SRCDIR *=/s#=.*#=$SRCDIR/$ARCHDIR#
/^SRCTOP *=/s#=.*#=$SRCDIR#
/^TOPDIR *=/s#=.*#=$BUILDDIR#
/^BUILDDIR *=/s#=.*#=$BUILDDIR#
/^AVX2FLAG *=/s#=.*#=$avx2flag#
/^SSE2FLAG *=/s#=.*#=$sse2flag#
/^SSSE3FLAG *=/s#=.*#=$ssse3flag#
Expand Down Expand Up @@ -1971,6 +1989,7 @@ sed < $SRCDIR/zlib.pc.in "
/^prefix *=/s#=.*#=$prefix#
/^exec_prefix *=/s#=.*#=$exec_prefix#
/^bindir *=/s#=.*#=$bindir#
/^symbol_prefix *=/s#=.*#=$symbol_prefix#
/^libdir *=/s#=.*#=$libdir#
/^sharedlibdir *=/s#=.*#=$sharedlibdir#
/^includedir *=/s#=.*#=$includedir#
Expand Down
4 changes: 2 additions & 2 deletions gzread.c → gzread.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ size_t Z_EXPORT PREFIX(gzfread)(void *buf, size_t size, size_t nitems, gzFile fi
}

/* -- see zlib.h -- */
#undef gzgetc
#undef zng_gzgetc
#undef @ZLIB_SYMBOL_PREFIX@gzgetc
#undef @ZLIB_SYMBOL_PREFIX@zng_gzgetc
int Z_EXPORT PREFIX(gzgetc)(gzFile file) {
unsigned char buf[1];
gz_state *state;
Expand Down
28 changes: 26 additions & 2 deletions win32/Makefile.a64
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOC =
STATICLIB = zlib.lib
SHAREDLIB = zlib1.dll
IMPLIB = zdll.lib
SYMBOL_PREFIX =

CC = cl
LD = link
Expand Down Expand Up @@ -103,8 +104,25 @@ OBJS = $(OBJS) crc32_acle.obj insert_string_acle.obj adler32_neon.obj chunkset_n
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
example.exe minigzip.exe example_d.exe minigzip_d.exe

zconf: $(TOP)/zconf$(SUFFIX).h.in
$(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h
!if "$(SYMBOL_PREFIX)" != ""
zlib_name_mangling$(SUFFIX).h: zlib_name_mangling$(SUFFIX).h.in
cscript $(TOP)\win32\replace.vbs $(TOP)\zlib_name_mangling$(SUFFIX).h.in zlib_name_mangling$(SUFFIX).h "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"
!else
zlib_name_mangling$(SUFFIX).h: zlib_name_mangling.h.empty
$(CP) $(TOP)\zlib_name_mangling.h.empty zlib_name_mangling$(SUFFIX).h
!endif

zlib$(SUFFIX).h: zlib$(SUFFIX).h.in
cscript $(TOP)\win32\replace.vbs $(TOP)\zlib$(SUFFIX).h.in zlib$(SUFFIX).h "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"

gzread.c: gzread.c.in
cscript $(TOP)\win32\replace.vbs $(TOP)\gzread.c.in gzread.c "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"

zconf: $(TOP)/zconf$(SUFFIX).h.in $(TOP)/zlib$(SUFFIX).h $(TOP)/zlib_name_mangling$(SUFFIX).h
$(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h

$(TOP)/win32/$(DEFFILE): $(TOP)/win32/$(DEFFILE).in
cscript $(TOP)\win32\replace.vbs $(TOP)/win32/$(DEFFILE).in $(TOP)/win32/$(DEFFILE) "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"

$(STATICLIB): zconf $(OBJS)
$(AR) $(ARFLAGS) -out:$@ $(OBJS)
Expand Down Expand Up @@ -218,3 +236,9 @@ clean:

distclean: clean
-del zconf$(SUFFIX).h
-del zlib$(SUFFIX).h
-del zlib_name_mangling$(SUFFIX).h
-del $(TOP)\win32\zlib.def
-del $(TOP)\win32\zlibcompat.def
-del $(TOP)\win32\zlib-ng.def
-del gzread.c
28 changes: 26 additions & 2 deletions win32/Makefile.arm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOC =
STATICLIB = zlib.lib
SHAREDLIB = zlib1.dll
IMPLIB = zdll.lib
SYMBOL_PREFIX =

CC = cl
LD = link
Expand Down Expand Up @@ -115,8 +116,25 @@ OBJS = $(OBJS) adler32_neon.obj chunkset_neon.obj slide_hash_neon.obj
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
example.exe minigzip.exe example_d.exe minigzip_d.exe

zconf: $(TOP)/zconf$(SUFFIX).h.in
$(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h
!if "$(SYMBOL_PREFIX)" != ""
zlib_name_mangling$(SUFFIX).h: zlib_name_mangling$(SUFFIX).h.in
cscript $(TOP)\win32\replace.vbs $(TOP)\zlib_name_mangling$(SUFFIX).h.in zlib_name_mangling$(SUFFIX).h "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"
!else
zlib_name_mangling$(SUFFIX).h: zlib_name_mangling.h.empty
$(CP) $(TOP)\zlib_name_mangling.h.empty zlib_name_mangling$(SUFFIX).h
!endif

zlib$(SUFFIX).h: zlib$(SUFFIX).h.in
cscript $(TOP)\win32\replace.vbs $(TOP)\zlib$(SUFFIX).h.in zlib$(SUFFIX).h "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"

gzread.c: gzread.c.in
cscript $(TOP)\win32\replace.vbs $(TOP)\gzread.c.in gzread.c "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"

zconf: $(TOP)/zconf$(SUFFIX).h.in $(TOP)/zlib$(SUFFIX).h $(TOP)/zlib_name_mangling$(SUFFIX).h
$(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h

$(TOP)/win32/$(DEFFILE): $(TOP)/win32/$(DEFFILE).in
cscript $(TOP)\win32\replace.vbs $(TOP)/win32/$(DEFFILE).in $(TOP)/win32/$(DEFFILE) "@ZLIB_SYMBOL_PREFIX@" "$(SYMBOL_PREFIX)"

$(STATICLIB): zconf $(OBJS)
$(AR) $(ARFLAGS) -out:$@ $(OBJS)
Expand Down Expand Up @@ -229,3 +247,9 @@ clean:

distclean: clean
-del zconf$(SUFFIX).h
-del zlib$(SUFFIX).h
-del zlib_name_mangling$(SUFFIX).h
-del $(TOP)\win32\zlib.def
-del $(TOP)\win32\zlibcompat.def
-del $(TOP)\win32\zlib-ng.def
-del gzread.c
Loading

0 comments on commit 714f624

Please sign in to comment.