summaryrefslogtreecommitdiffstats
path: root/l/zlib
diff options
context:
space:
mode:
authorAdrien Nader <adrien@notk.org>2012-07-08 14:50:08 +0200
committerAdrien Nader <adrien@notk.org>2012-07-08 14:50:08 +0200
commitc548954ec38da102bffab56ba5e15332e3ed0c7c (patch)
tree78ec1501d8c7c1fcebabf119faa50d04ba559923 /l/zlib
parentc177d96ea276c8703a9a5dc55647837d3eaaf15c (diff)
zlib: initial port. Wrote a new makefile since its non-BS sucks.
Diffstat (limited to 'l/zlib')
-rw-r--r--l/zlib/Makefile.yypkg183
-rwxr-xr-xl/zlib/zlib.SlackBuild105
-rw-r--r--l/zlib/zlib.yypkg.meta5
3 files changed, 236 insertions, 57 deletions
diff --git a/l/zlib/Makefile.yypkg b/l/zlib/Makefile.yypkg
new file mode 100644
index 0000000..25ffe8c
--- /dev/null
+++ b/l/zlib/Makefile.yypkg
@@ -0,0 +1,183 @@
+# Makefile for zlib, derived from Makefile.dj2.
+# Modified for mingw32 by C. Spieler, 6/16/98.
+# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003.
+# Last updated: 1-Aug-2003.
+# Tested under Cygwin and MinGW.
+# Modified for {i686,x86_64}-w64-mingw32 and cross-compilation by Adrien Nader,
+# Sun Jul 8 2012; partially based on a patch from Vincent Torri
+
+# Copyright (C) 1995-2003 Jean-loup Gailly.
+# For conditions of distribution and use, see copyright notice in zlib.h
+
+# To compile, or to compile and test, type:
+#
+# make -fmakefile.gcc; make test testdll -fmakefile.gcc
+#
+# To use the asm code, type:
+# cp contrib/asm?86/match.S ./match.S
+# make LOC=-DASMV OBJA=match.o -fmakefile.gcc
+#
+# To install libz.a, zconf.h and zlib.h in the system directories, type:
+#
+# make install -fmakefile.gcc
+
+# Note:
+# If the platform is *not* MinGW (e.g. it is Cygwin or UWIN),
+# the DLL name should be changed from "zlib1.dll".
+
+STATICLIB = libz.a
+SHAREDLIB = libz-1.dll
+IMPLIB = libz.dll.a
+
+#
+# Set to 1 if shared object needs to be installed
+#
+SHARED_MODE=1
+
+#LOC = -DASMV
+#LOC = -DDEBUG -g
+
+PREFIX ?=
+CC ?= $(PREFIX)gcc
+CFLAGS ?= $(LOC) -O3 -Wall
+EXTRA_CFLAGS = -DNO_VIZ
+
+AS ?= $(CC)
+ASFLAGS ?= $(LOC) -Wall
+
+LD ?= $(CC)
+LDFLAGS ?= $(LOC)
+
+AR ?= $(PREFIX)ar
+ARFLAGS ?= rcs
+
+RC ?= $(PREFIX)windres
+RCFLAGS ?= --define GCC_WINDRES
+
+STRIP ?= $(PREFIX)strip
+
+CP = cp -fp
+# If GNU install is available, replace $(CP) with install.
+INSTALL = $(CP)
+RM = rm -f
+
+prefix ?= /usr/local
+exec_prefix = $(prefix)
+
+OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \
+ gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o \
+ zutil.o
+OBJA =
+
+all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe
+
+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
+
+.c.o:
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
+
+.S.o:
+ $(AS) $(ASFLAGS) -c -o $@ $<
+
+$(STATICLIB): $(OBJS) $(OBJA)
+ $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA)
+
+$(IMPLIB): $(SHAREDLIB)
+
+$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
+ $(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \
+ -o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o
+ $(STRIP) $@
+
+example.exe: example.o $(STATICLIB)
+ $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB)
+ $(STRIP) $@
+
+minigzip.exe: minigzip.o $(STATICLIB)
+ $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB)
+ $(STRIP) $@
+
+example_d.exe: example.o $(IMPLIB)
+ $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB)
+ $(STRIP) $@
+
+minigzip_d.exe: minigzip.o $(IMPLIB)
+ $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB)
+ $(STRIP) $@
+
+example.o: test/example.c zlib.h zconf.h
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I. -c -o $@ test/example.c
+
+minigzip.o: test/minigzip.c zlib.h zconf.h
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I. -c -o $@ test/minigzip.c
+
+zlibrc.o: win32/zlib1.rc
+ $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc
+
+
+# BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set.
+
+.PHONY: install uninstall clean
+
+install: zlib.h zconf.h $(STATICLIB) $(IMPLIB)
+ @if test -z "$(INCLUDE_PATH)" -o -z "$(LIBRARY_PATH)" -o -z "$(BINARY_PATH)"; then \
+ echo INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH must be specified; \
+ exit 1; \
+ fi
+ -@mkdir -p $(INCLUDE_PATH)
+ -@mkdir -p $(LIBRARY_PATH) $(LIBRARY_PATH)/pkgconfig
+ -if [ "$(SHARED_MODE)" = "1" ]; then \
+ mkdir -p $(BINARY_PATH); \
+ $(INSTALL) $(SHAREDLIB) $(BINARY_PATH); \
+ $(INSTALL) $(IMPLIB) $(LIBRARY_PATH); \
+ fi
+ -$(INSTALL) zlib.h $(INCLUDE_PATH)
+ -$(INSTALL) zconf.h $(INCLUDE_PATH)
+ -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH)
+ sed \
+ -e 's|@prefix@|${prefix}|g' \
+ -e 's|@exec_prefix@|${exec_prefix}|g' \
+ -e 's|@libdir@|$(LIBRARY_PATH)|g' \
+ -e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \
+ -e 's|@includedir@|$(INCLUDE_PATH)|g' \
+ -e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \
+ zlib.pc.in > $(LIBRARY_PATH)/pkgconfig/zlib.pc
+
+uninstall:
+ -if [ "$(SHARED_MODE)" = "1" ]; then \
+ $(RM) $(BINARY_PATH)/$(SHAREDLIB); \
+ $(RM) $(LIBRARY_PATH)/$(IMPLIB); \
+ fi
+ -$(RM) $(INCLUDE_PATH)/zlib.h
+ -$(RM) $(INCLUDE_PATH)/zconf.h
+ -$(RM) $(LIBRARY_PATH)/$(STATICLIB)
+
+clean:
+ -$(RM) $(STATICLIB)
+ -$(RM) $(SHAREDLIB)
+ -$(RM) $(IMPLIB)
+ -$(RM) *.o
+ -$(RM) *.exe
+ -$(RM) foo.gz
+
+adler32.o: zlib.h zconf.h
+compress.o: zlib.h zconf.h
+crc32.o: crc32.h zlib.h zconf.h
+deflate.o: deflate.h zutil.h zlib.h zconf.h
+gzclose.o: zlib.h zconf.h gzguts.h
+gzlib.o: zlib.h zconf.h gzguts.h
+gzread.o: zlib.h zconf.h gzguts.h
+gzwrite.o: zlib.h zconf.h gzguts.h
+inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
+inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
+infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h
+inftrees.o: zutil.h zlib.h zconf.h inftrees.h
+trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
+uncompr.o: zlib.h zconf.h
+zutil.o: zutil.h zlib.h zconf.h
diff --git a/l/zlib/zlib.SlackBuild b/l/zlib/zlib.SlackBuild
index eb28428..0f71420 100755
--- a/l/zlib/zlib.SlackBuild
+++ b/l/zlib/zlib.SlackBuild
@@ -39,22 +39,16 @@ CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-zlib
-if [ "$ARCH" = "i386" ]; then
- SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
- LIBDIRSUFFIX=""
-elif [ "$ARCH" = "i486" ]; then
- SLKCFLAGS="-O2 -march=i486 -mtune=i686"
- LIBDIRSUFFIX=""
-elif [ "$ARCH" = "s390" ]; then
- SLKCFLAGS="-O2"
- LIBDIRSUFFIX=""
-elif [ "$ARCH" = "x86_64" ]; then
- SLKCFLAGS="-O2 -fPIC"
- LIBDIRSUFFIX="64"
-else
- SLKCFLAGS="-O2"
- LIBDIRSUFFIX=""
-fi
+case "${HOST_TRIPLET}" in
+ i686-w64-mingw32)
+ SLKCFLAGS="-O3 -march=i686"
+ LIBDIRSUFFIX=""
+ ;;
+ x86_64-w64-mingw32)
+ SLKCFLAGS="-O3"
+ LIBDIRSUFFIX="64"
+ ;;
+esac
rm -rf $PKG
mkdir -p $TMP $PKG
@@ -71,65 +65,62 @@ find . \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
+# We only call configure so that it creates "zlib.pc" from "zlib.pc.in". zlib's
+# build system is pretty crappy and doesn't handle cross-compilation: we have to
+# call a makefile directly instead.
CFLAGS="$SLKCFLAGS" \
./configure \
- --prefix=/usr
-make clean
-make || exit 1
-CFLAGS="$SLKCFLAGS" \
-./configure \
- --prefix=/usr \
- --libdir=/usr/lib${LIBDIRSUFFIX} \
+ --prefix=/${PREFIX} \
+ --libdir=/${PREFIX}/lib${LIBDIRSUFFIX} \
--shared
-make || exit 1
-
-mkdir -p $PKG/usr/include
-cp -a zlib.h zconf.h $PKG/usr/include
-chmod 644 $PKG/usr/include/*
-mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
-cp -a libz.a libz.so* $PKG/usr/lib${LIBDIRSUFFIX}
-chmod 755 $PKG/usr/lib${LIBDIRSUFFIX}/*
-chmod 644 $PKG/usr/lib${LIBDIRSUFFIX}/libz.a
-mkdir -p $PKG/usr/man/man3
-cat zlib.3 | gzip -9c > $PKG/usr/man/man3/zlib.3.gz
+
+CC=${HOST_TRIPLET}-gcc \
+ CFLAGS="$SLKCFLAGS -Wall" \
+ LD=${HOST_TRIPLET}-gcc \
+ AS=${HOST_TRIPLET}-gcc \
+ AR="${HOST_TRIPLET}-ar" \
+ RC="${HOST_TRIPLET}-windres" \
+ STRIP="${HOST_STRIP}" \
+ make -j 2 -f $CWD/Makefile.yypkg || exit 1
+
+mkdir -p $PKG/${PREFIX}/include
+cp -a zlib.h zconf.h $PKG/${PREFIX}/include
+chmod 644 $PKG/${PREFIX}/include/*
+mkdir -p $PKG/${PREFIX}/lib${LIBDIRSUFFIX}
+cp -a libz.a libz.so* libz*.dll* $PKG/${PREFIX}/lib${LIBDIRSUFFIX}
+chmod 755 $PKG/${PREFIX}/lib${LIBDIRSUFFIX}/*
+chmod 644 $PKG/${PREFIX}/lib${LIBDIRSUFFIX}/libz.a
+mkdir -p $PKG/${PREFIX}/man/man3
+cat zlib.3 | gzip -9c > $PKG/${PREFIX}/man/man3/zlib.3.gz
# Add pkgconfig file:
-mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig
-cat zlib.pc > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/zlib.pc
-
-# Now that libkmod requires libz, we had better move the shared library
-# up a level:
-mkdir $PKG/lib${LIBDIRSUFFIX}
-( cd $PKG/usr/lib${LIBDIRSUFFIX}
- for file in lib*.so.?.* ; do
- mv $file ../../lib${LIBDIRSUFFIX}
- ln -sf ../../lib${LIBDIRSUFFIX}/$file .
- done
- cp -a lib*.so.? ../../lib${LIBDIRSUFFIX}
-)
+mkdir -p $PKG/${PREFIX}/lib${LIBDIRSUFFIX}/pkgconfig
+cat zlib.pc > $PKG/${PREFIX}/lib${LIBDIRSUFFIX}/pkgconfig/zlib.pc
# Strip binaries:
( cd $PKG
- find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
- find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+ find . | xargs file | egrep "executable|shared object" | grep ${HOST_EXE_FORMAT} | cut -f 1 -d : | xargs ${HOST_STRIP} --strip-unneeded 2> /dev/null
)
-mkdir -p $PKG/usr/doc/zlib-$VERSION
+mkdir -p $PKG/${PREFIX}/doc/zlib-$VERSION
cp -a \
FAQ INDEX README* \
- $PKG/usr/doc/zlib-$VERSION
+ $PKG/${PREFIX}/doc/zlib-$VERSION
# If there's a ChangeLog, installing at least part of the recent history
# is useful, but don't let it get totally out of control:
if [ -r ChangeLog ]; then
- DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION)
+ DOCSDIR=$(echo $PKG/${PREFIX}/doc/${PKGNAM}-$VERSION)
cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog
touch -r ChangeLog $DOCSDIR/ChangeLog
fi
-mkdir -p $PKG/install
-cat $CWD/slack-desc > $PKG/install/slack-desc
-
-cd $PKG
-makepkg -l y -c n $TMP/zlib-$VERSION-$ARCH-$BUILD.txz
+cat ${CWD}/${PKGNAM}.yypkg.meta | sed \
+ -e "s/%{PKG}/${PKGNAM}/" \
+ -e "s/%{HST}/${HOST_TRIPLET}/" \
+ -e "s/%{TGT}//" \
+ -e "s/%{VER}/$(echo ${VERSION} | tr . ' ')/" \
+ -e "s/%{BUILD}/${BUILD}/" \
+ -e "s/%{DESCR}/${DESCR:-"No description"}/" \
+ | makeypkg -o ${YYOUTPUT} -meta - "${PKG}/${PREFIX}"
diff --git a/l/zlib/zlib.yypkg.meta b/l/zlib/zlib.yypkg.meta
new file mode 100644
index 0000000..a2d3c39
--- /dev/null
+++ b/l/zlib/zlib.yypkg.meta
@@ -0,0 +1,5 @@
+((name %{PKG}) (size_expanded (TB 42))
+ (version ((%{VER}) Stable %{BUILD}))
+ (packager_email adrien@notk.org) (packager_name "Adrien Nader")
+ (description "%{DESCR}") (host %{HST}) (target (%{TGT})) (predicates ())
+ (comments ()))