forked from pool/libzio
This commit is contained in:
parent
ad776485c5
commit
a7a6bf2e84
133
Makefile
Normal file
133
Makefile
Normal file
@ -0,0 +1,133 @@
|
||||
#
|
||||
# Makefile for compiling libzio
|
||||
#
|
||||
# Author: Werner Fink, <werner@suse.de>
|
||||
#
|
||||
|
||||
LARGE = $(shell getconf LFS_CFLAGS)
|
||||
CFLAGS = $(RPM_OPT_FLAGS) -pipe -Wall -D_GNU_SOURCE -D_REENTRANT $(LARGE)
|
||||
CC = gcc
|
||||
MAJOR = 0
|
||||
MINOR = 93
|
||||
VERSION = $(MAJOR).$(MINOR)
|
||||
SONAME = libzio.so.$(MAJOR)
|
||||
LDMAP = -Wl,--version-script=zio.map
|
||||
|
||||
prefix = /usr
|
||||
libdir = $(prefix)/lib
|
||||
datadir = $(prefix)/share
|
||||
mandir = $(datadir)/man
|
||||
incdir = $(prefix)/include
|
||||
|
||||
FILES = README \
|
||||
COPYING \
|
||||
Makefile \
|
||||
zio.c \
|
||||
zioP.h \
|
||||
zio.h.in \
|
||||
testt.c \
|
||||
tests.c \
|
||||
lzw.h \
|
||||
unlzw.c \
|
||||
zio.map \
|
||||
fzopen.3.in
|
||||
|
||||
### Includes and Defines (add further entries here):
|
||||
|
||||
cc-include = $(shell $(CC) $(INCLUDES) -include $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1 && echo "-D$(2)")
|
||||
cc-library = $(shell echo 'int main () { return 0; }' |$(CC) -l$(1:lib%=%) -o /dev/null -xc - > /dev/null 2>&1 && echo yes)
|
||||
cc-function = $(shell echo 'extern void $(1)(void); int main () { $(1)(); return 0; }' |$(CC) -o /dev/null -xc - > /dev/null 2>&1 && echo "-D$(2)")
|
||||
|
||||
CFLAGS += $(call cc-include,libio.h,HAVE_LIBIO_H)
|
||||
CFLAGS += $(call cc-function,fopencookie,HAVE_FOPENCOOKIE)
|
||||
CFLAGS += $(call cc-function,funopen,HAVE_FUNOPEN)
|
||||
|
||||
CFLAGS += $(call cc-include,zlib.h,HAS_ZLIB_H)
|
||||
CFLAGS += $(call cc-include,bzlib.h,HAS_BZLIB_H)
|
||||
CFLAGS += $(call cc-include,lzmadec.h,HAS_LZMADEC_H)
|
||||
CFLAGS += $(call cc-include,lzma.h,HAS_LZMA_H)
|
||||
|
||||
LIBS = -lz
|
||||
ifeq ($(call cc-library,libbz2),yes)
|
||||
LIBS += -lbz2
|
||||
endif
|
||||
ifeq ($(call cc-library,liblzma),yes)
|
||||
LIBS += -llzma
|
||||
else
|
||||
ifeq ($(call cc-library,lzmadec),yes)
|
||||
LIBS += -llzmadec
|
||||
endif
|
||||
endif
|
||||
|
||||
all: shared static
|
||||
noweak: CFLAGS += -DNO_WEAK
|
||||
noweak: LINK += $(LIBS)
|
||||
noweak: all
|
||||
shared: libzio.so.$(VERSION) zio.map
|
||||
static: libzio.a
|
||||
|
||||
obj/zio.o: zio.c zioP.h zio.h
|
||||
test -d obj/ || mkdir obj/
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
obs/zio.o: zio.c zioP.h zio.h
|
||||
test -d obs/ || mkdir obs/
|
||||
$(CC) $(CFLAGS) -fPIC -o $@ -c $<
|
||||
|
||||
obj/unlzw.o: unlzw.c lzw.h
|
||||
test -d obj/ || mkdir obj/
|
||||
$(CC) $(CFLAGS) -funroll-loops -o $@ -c $<
|
||||
|
||||
obs/unlzw.o: unlzw.c lzw.h
|
||||
test -d obs/ || mkdir obs/
|
||||
$(CC) $(CFLAGS) -fPIC -o $@ -c $<
|
||||
|
||||
libzio.a: obj/zio.o obj/unlzw.o
|
||||
ar -rv $@ $^
|
||||
ranlib $@
|
||||
|
||||
libzio.so.$(VERSION): obs/zio.o obs/unlzw.o
|
||||
gcc -shared -Wl,-soname,$(SONAME),-stats $(LDMAP) -o $@ $^ $(LINK)
|
||||
|
||||
zioP.h: /usr/include/bzlib.h /usr/include/zlib.h
|
||||
zio.h: zio.h.in /usr/include/stdio.h
|
||||
sed 's/@@VERSION@@/$(VERSION)/' < $< > $@
|
||||
fzopen.3: fzopen.3.in
|
||||
sed 's/@@VERSION@@/$(VERSION)/' < $< > $@
|
||||
|
||||
unlzw.c: lzw.h
|
||||
|
||||
install: install-shared install-static install-data
|
||||
|
||||
install-shared: libzio.so.$(VERSION)
|
||||
mkdir -p $(DESTDIR)$(libdir)
|
||||
install -m 0755 libzio.so.$(VERSION) $(DESTDIR)$(libdir)/
|
||||
ln -sf libzio.so.$(VERSION) $(DESTDIR)$(libdir)/libzio.so.$(MAJOR)
|
||||
ln -sf libzio.so.$(MAJOR) $(DESTDIR)$(libdir)/libzio.so
|
||||
|
||||
install-static: libzio.a
|
||||
mkdir -p $(DESTDIR)$(libdir)
|
||||
install -m 0644 libzio.a $(DESTDIR)$(libdir)/
|
||||
|
||||
install-data: zio.h fzopen.3
|
||||
mkdir -p $(DESTDIR)$(incdir)
|
||||
mkdir -p $(DESTDIR)$(mandir)/man3
|
||||
install -m 0644 zio.h $(DESTDIR)$(incdir)/
|
||||
install -m 0644 fzopen.3 $(DESTDIR)$(mandir)/man3/
|
||||
|
||||
clean:
|
||||
rm -f *.a *.so* testt tests zio.h
|
||||
rm -rf obj/ obs/
|
||||
rm -f libzio-$(VERSION).tar.gz
|
||||
|
||||
dest: clean
|
||||
mkdir libzio-$(VERSION)
|
||||
cp -p $(FILES) libzio-$(VERSION)/
|
||||
tar czf libzio-$(VERSION).tar.gz libzio-$(VERSION)/
|
||||
rm -rf libzio-$(VERSION)/
|
||||
|
||||
testt: testt.c libzio.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||
|
||||
tests: tests.c libzio.a
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
|
127
libzio-0.9.dif
127
libzio-0.9.dif
@ -1,127 +0,0 @@
|
||||
--- fzopen.3.in
|
||||
+++ fzopen.3.in 2008-10-16 14:48:34.823680248 +0200
|
||||
@@ -1,6 +1,8 @@
|
||||
+'\" t -*- coding: UTF-8 -*-
|
||||
.\"
|
||||
.\" Copyright 2004 Werner Fink, 2004 SuSE LINUX AG, Germany.
|
||||
.\" Copyright 2006 Werner Fink, 2006 SuSE Products GmbH, Germany.
|
||||
+.\" Copyright 2008 Werner Fink, 2008 SuSE Products GmbH, Germany.
|
||||
.\"
|
||||
.\" This program is free software; you can redistribute it and/or modify
|
||||
.\" it under the terms of the GNU General Public License as published by
|
||||
@@ -100,12 +102,75 @@ only supports the suffixes
|
||||
.IR .z " and ".gz
|
||||
for gzipped files and
|
||||
.I .bz2
|
||||
-for bzip2ed files.
|
||||
+for bzip2ed files. All supported formats can be found in
|
||||
+the following table:
|
||||
+.IP
|
||||
+.TS H
|
||||
+allbox;
|
||||
+c l l l l l
|
||||
+rb l l l l l.
|
||||
+ fread fwrite fseek suffix library
|
||||
+gzip yes yes yes .gz -lz
|
||||
+ bzip2 yes yes no .bz2 -lbz2
|
||||
+LZW yes no no .Z builtin
|
||||
+lzma yes no yes .lzma -llzmadec
|
||||
+.TE
|
||||
+.PP
|
||||
.PP
|
||||
On reading first the appropriate suffixes are checked
|
||||
if not provided. If no file is found the magic
|
||||
byte sequence at the beginning of the file is checked
|
||||
to detect a gzip or bzip2 file.
|
||||
+.PP
|
||||
+.\"
|
||||
+.SH CONFIGURATION
|
||||
+With the help of
|
||||
+.BR autoconf (1)
|
||||
+and a few lines in the common file
|
||||
+.B configure.in
|
||||
+found in many source packages a programmer or maintainer
|
||||
+can extend the automatic configuration to find the
|
||||
+appropriate libraries together with the libzio:
|
||||
+.PP
|
||||
+.IP
|
||||
+.nf
|
||||
+AC_CHECK_HEADER(zlib.h,[
|
||||
+ for lib in z gz; do
|
||||
+ AC_CHECK_LIB($lib, gzopen, [LIBS="$LIBS -l$lib"; break])
|
||||
+ done])
|
||||
+AC_CHECK_HEADER(bzlib.h,[
|
||||
+ for lib in bz2 bzip2; do
|
||||
+ AC_CHECK_LIB($lib, BZ2_bzopen, [LIBS="$LIBS -l$lib"; break])
|
||||
+ done])
|
||||
+AC_CHECK_HEADER(lzmadec.h,[
|
||||
+ AC_CHECK_LIB(lzmadec, lzmadec_read, [LIBS="$LIBS -l$lib"])
|
||||
+ ])
|
||||
+AC_CHECK_HEADER(zio.h,[
|
||||
+ AC_CHECK_LIB(zio, fzopen, [LIBS="$LIBS -lzio"
|
||||
+ AC_DEFINE(HAVE_ZIO)])
|
||||
+ ])
|
||||
+.fi
|
||||
+.PP
|
||||
+combined with two lines in the common file
|
||||
+.B config.h.in
|
||||
+like
|
||||
+.PP
|
||||
+.RS 1c
|
||||
+.nf
|
||||
+/* Define to 1 if you have libzio for opening compressed files */
|
||||
+#undef HAVE_ZIO
|
||||
+.fi
|
||||
+.RE
|
||||
+.PP
|
||||
+it is easy to use the
|
||||
+.BR cpp (1)
|
||||
+macro
|
||||
+.I HAVE_ZIO
|
||||
+for the usage of
|
||||
+.B fzopen
|
||||
+instead of
|
||||
+.BR fopen (3).
|
||||
+.PP
|
||||
.\"
|
||||
.SH RETURN VALUES
|
||||
Upon successful completion
|
||||
@@ -215,7 +280,7 @@ functions of the e.g.
|
||||
.\"
|
||||
.BR /usr/include/zio.h
|
||||
.SH SEE ALSO
|
||||
-.BR fopen (8),
|
||||
+.BR fopen (3),
|
||||
.br
|
||||
.BR gzip (1),
|
||||
.br
|
||||
@@ -229,7 +294,8 @@ functions of the e.g.
|
||||
.br
|
||||
.BR /usr/include/lzmadec.h .
|
||||
.PP
|
||||
-Further informations about Programming Custom Streams
|
||||
+Further informations about
|
||||
+.B Programming Custom Streams
|
||||
can be found by using the command
|
||||
.IP
|
||||
.B info libc 'Custom streams'
|
||||
@@ -243,5 +309,8 @@ does not exist (yet).
|
||||
.br
|
||||
2006 Werner Fink,
|
||||
2006 SuSE Products GmbH, Germany.
|
||||
+.br
|
||||
+2008 Werner Fink,
|
||||
+2008 SuSE Products GmbH, Germany.
|
||||
.SH AUTHOR
|
||||
Werner Fink <werner@suse.de>
|
||||
--- zio.c
|
||||
+++ zio.c 2008-09-24 17:50:43.000000000 +0200
|
||||
@@ -189,7 +189,7 @@ FILE * fzopen(const char * path, const c
|
||||
what = 'Z';
|
||||
else if (strcmp(path + len - 4, ".bz2" ) == 0)
|
||||
what = 'b';
|
||||
- else if (strcmp(path + len - 4, ".lzma") == 0)
|
||||
+ else if (strcmp(path + len - 5, ".lzma") == 0)
|
||||
what = 'l';
|
||||
|
||||
if (what == 'n' && *check == 'r') {
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:c80e4ab5f128e549bedad7519a2482ed83438e0179ec2a37d4af3ecd464044ab
|
||||
size 17813
|
3
libzio-0.93.tar.bz2
Normal file
3
libzio-0.93.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:95ae2ba76dbfc9c03caa70cc52b5b1a522e41f811336bf7e6c5e16b2fc7e1b78
|
||||
size 20596
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 13 14:05:11 CET 2009 - werner@suse.de
|
||||
|
||||
- Use liblzma from xz package if available
|
||||
- Detect if funopen(3) can be used if no fopencookie(3) found
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jan 7 12:34:56 CET 2009 - olh@suse.de
|
||||
|
||||
|
32
libzio.spec
32
libzio.spec
@ -1,5 +1,5 @@
|
||||
#
|
||||
# spec file for package libzio (Version 0.9)
|
||||
# spec file for package libzio (Version 0.93)
|
||||
#
|
||||
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
@ -19,12 +19,11 @@
|
||||
|
||||
|
||||
Name: libzio
|
||||
BuildRequires: zlib-devel
|
||||
%if %suse_version > 1020
|
||||
BuildRequires: libbz2-devel
|
||||
%endif
|
||||
%if %suse_version > 1030
|
||||
BuildRequires: libbz2-devel zlib-devel
|
||||
%if %suse_version <= 1110
|
||||
BuildRequires: lzma lzma-devel
|
||||
%else
|
||||
BuildRequires: xz xz-devel
|
||||
%endif
|
||||
License: GPL v2 or later
|
||||
Group: System/Libraries
|
||||
@ -34,12 +33,11 @@ AutoReqProv: on
|
||||
Obsoletes: libzio-64bit
|
||||
%endif
|
||||
#
|
||||
Version: 0.9
|
||||
Release: 5
|
||||
Version: 0.93
|
||||
Release: 1
|
||||
Summary: A Library for Accessing Compressed Text Files
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
Source: libzio-%{version}.tar.bz2
|
||||
Patch: libzio-%{version}.dif
|
||||
|
||||
%description
|
||||
Libzio provides a wrapper function for reading or writing gzip or bzip2
|
||||
@ -54,7 +52,7 @@ Authors:
|
||||
%package devel
|
||||
License: GPL v2 or later
|
||||
Summary: Libzio development files
|
||||
Group: System/Libraries
|
||||
Group: Development/Libraries/C and C++
|
||||
Requires: libzio = %{version}
|
||||
AutoReqProv: on
|
||||
# bug437293
|
||||
@ -75,7 +73,6 @@ Authors:
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch
|
||||
|
||||
%build
|
||||
make
|
||||
@ -83,10 +80,10 @@ make
|
||||
%check
|
||||
make testt
|
||||
make tests
|
||||
%if %suse_version > 1030
|
||||
%if %suse_version <= 1110
|
||||
for comp in gzip bzip2 lzma
|
||||
%else
|
||||
for comp in gzip bzip2
|
||||
for comp in gzip bzip2 lzma xz
|
||||
%endif
|
||||
do
|
||||
$comp -c < fzopen.3.in > fzopen.test
|
||||
@ -97,11 +94,9 @@ done
|
||||
%install
|
||||
make DESTDIR=$RPM_BUILD_ROOT install libdir=%{_libdir} mandir=%{_mandir}
|
||||
|
||||
%post
|
||||
%run_ldconfig
|
||||
%post -p /sbin/ldconfig
|
||||
|
||||
%postun
|
||||
%run_ldconfig
|
||||
%postun -p /sbin/ldconfig
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
@ -117,6 +112,9 @@ make DESTDIR=$RPM_BUILD_ROOT install libdir=%{_libdir} mandir=%{_mandir}
|
||||
/usr/include/zio.h
|
||||
|
||||
%changelog
|
||||
* Fri Feb 13 2009 werner@suse.de
|
||||
- Use liblzma from xz package if available
|
||||
- Detect if funopen(3) can be used if no fopencookie(3) found
|
||||
* Wed Jan 07 2009 olh@suse.de
|
||||
- obsolete old -XXbit packages (bnc#437293)
|
||||
* Tue Nov 11 2008 ro@suse.de
|
||||
|
Loading…
x
Reference in New Issue
Block a user