Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix building with z_ prefix #936

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})

if (Z_PREFIX)
set(Z_PREFIX_STR "z_")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib.map.in
${CMAKE_CURRENT_BINARY_DIR}/zlib.map @ONLY)

#============================================================================
# zlib
Expand Down Expand Up @@ -174,10 +179,10 @@ endif()

if(UNIX)
# On unix-like platforms the library is almost always called libz
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
endif()
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_BINARY_DIR}/zlib.map\"")
endif()
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
Expand Down
2 changes: 1 addition & 1 deletion INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ zconf.h.cmakein zconf.h template for cmake
zconf.h.in zconf.h template for configure
zlib.3 Man page for zlib
zlib.3.pdf Man page in PDF format
zlib.map Linux symbol information
zlib.map.in Template for Linux symbol information
zlib.pc.in Template for pkg-config descriptor
zlib.pc.cmakein zlib.pc template for cmake
zlib2ansi perl script to convert source files for C++ compilation
Expand Down
16 changes: 14 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ else
SRCDIR="$SRCDIR/"
fi

# get build directory
BUILDDIR="`pwd`/"

# set command prefix for cross-compilation
if [ -n "${CHOST}" ]; then
uname=${CHOST}
Expand Down Expand Up @@ -167,6 +170,15 @@ show()
echo $* >> configure.log
}

# generate zlib.map and modify its content according to the value of the z_ prefix
cp -p ${SRCDIR}zlib.map.in zlib.map
if test $zprefix -eq 1; then
sed < zlib.map "s/\@Z_PREFIX_STR\@/z_/" > zlib.temp.map
else
sed < zlib.map "s/\@Z_PREFIX_STR\@//" > zlib.temp.map
fi
mv zlib.temp.map zlib.map

# check for gcc vs. cc and set compile and link flags based on the system identified by uname
cat > $test.c <<EOF
extern int getchar();
Expand Down Expand Up @@ -233,9 +245,9 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
*sparc*)
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
esac
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;;
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${BUILDDIR}zlib.map"} ;;
*BSD | *bsd* | DragonFly)
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"}
LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${BUILDDIR}zlib.map"}
LDCONFIG="ldconfig -m" ;;
CYGWIN* | Cygwin* | cygwin* | *-cygwin* | OS/2*)
EXE='.exe' ;;
Expand Down
Loading