diff --git a/Makefile b/Makefile index f196637..d308984 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,8 @@ # in the file LICENSE. # ------------------------------------------------------------------ -include config.in +top_sourcedir=. +include $(top_sourcedir)/config.in # define libdir name lib ?= lib @@ -51,54 +52,59 @@ mandir=$(prefix)/share/man includedir=$(prefix)/include DESTDIR= -all: $(LIB) bzip2 bzip2recover test +all: $(LIB) bzip2 bzip2recover -install: all test +install: all install-bin install-dev install-lib + +install-bin: bzip2 bzip2recover mkdir -p $(DESTDIR)$(bindir) - libtool --mode=install install -s -m 0755 bzip2 $(DESTDIR)$(bindir)/ - libtool --mode=install install -s -m 0755 bzip2recover $(DESTDIR)$(bindir)/ - libtool --mode=install install -m 0755 bzdiff $(DESTDIR)$(bindir)/ - libtool --mode=install install -m 0755 bzmore $(DESTDIR)$(bindir)/ + libtool --mode=install install -m 0755 bzip2 $(DESTDIR)$(bindir)/ + libtool --mode=install install -m 0755 bzip2recover $(DESTDIR)$(bindir)/ + libtool --mode=install install -m 0755 $(top_sourcedir)/bzdiff $(DESTDIR)$(bindir)/ + libtool --mode=install install -m 0755 $(top_sourcedir)/bzmore $(DESTDIR)$(bindir)/ ln -sf bzip2 $(DESTDIR)$(bindir)/bunzip2 ln -sf bzip2 $(DESTDIR)$(bindir)/bzcat mkdir -p $(DESTDIR)$(mandir)/man1 - install -c -m 0644 bzip2.1 $(DESTDIR)$(mandir)/man1/ - install -c -m 0644 bzdiff.1 $(DESTDIR)$(mandir)/man1/ - install -c -m 0644 bzmore.1 $(DESTDIR)$(mandir)/man1/ + install -c -m 0644 $(top_sourcedir)/bzip2.1 $(DESTDIR)$(mandir)/man1/ + install -c -m 0644 $(top_sourcedir)/bzdiff.1 $(DESTDIR)$(mandir)/man1/ + install -c -m 0644 $(top_sourcedir)/bzmore.1 $(DESTDIR)$(mandir)/man1/ ln -sf bzip2.1 $(DESTDIR)$(mandir)/man1/bunzip2.1 ln -sf bzip2.1 $(DESTDIR)$(mandir)/man1/bzcat.1 ln -sf bzip2.1 $(DESTDIR)$(mandir)/man1/bzip2recover.1 + +install-dev: + mkdir -p $(DESTDIR)$(includedir) + install -c -m 0644 $(top_sourcedir)/bzlib.h $(DESTDIR)$(includedir) + +install-lib: $(LIB) mkdir -p $(DESTDIR)$(libdir) libtool --mode=install install $(LIB) $(DESTDIR)$(libdir) - mkdir -p $(DESTDIR)$(includedir) - install -c -m 0644 bzlib.h $(DESTDIR)$(includedir) -bzip2: bzip2.c $(LIB) - libtool --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ bzip2.c $(LIB) +bzip2: $(top_sourcedir)/bzip2.c $(LIB) + libtool --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(top_sourcedir)/bzip2.c $(LIB) -bzip2recover: bzip2recover.c - libtool --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ bzip2recover.c +bzip2recover: $(top_sourcedir)/bzip2recover.c + libtool --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(top_sourcedir)/bzip2recover.c $(LIB): $(OBJS) - libtool --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) -rpath $(libdir) \ - -version-info 1:0:0 + libtool --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) -version-info 1:0:6 check: test test: bzip2 - @cat words1 - ./bzip2 -1 < sample1.ref > sample1.rb2 - ./bzip2 -2 < sample2.ref > sample2.rb2 - ./bzip2 -3 < sample3.ref > sample3.rb2 - ./bzip2 -d < sample1.bz2 > sample1.tst - ./bzip2 -d < sample2.bz2 > sample2.tst - ./bzip2 -ds < sample3.bz2 > sample3.tst - cmp sample1.bz2 sample1.rb2 - cmp sample2.bz2 sample2.rb2 - cmp sample3.bz2 sample3.rb2 - cmp sample1.tst sample1.ref - cmp sample2.tst sample2.ref - cmp sample3.tst sample3.ref - @cat words3 + @cat $(top_sourcedir)/words1 + ./bzip2 -1 < $(top_sourcedir)/sample1.ref > sample1.rb2 + ./bzip2 -2 < $(top_sourcedir)/sample2.ref > sample2.rb2 + ./bzip2 -3 < $(top_sourcedir)/sample3.ref > sample3.rb2 + ./bzip2 -d < $(top_sourcedir)/sample1.bz2 > sample1.tst + ./bzip2 -d < $(top_sourcedir)/sample2.bz2 > sample2.tst + ./bzip2 -ds < $(top_sourcedir)/sample3.bz2 > sample3.tst + cmp $(top_sourcedir)/sample1.bz2 sample1.rb2 + cmp $(top_sourcedir)/sample2.bz2 sample2.rb2 + cmp $(top_sourcedir)/sample3.bz2 sample3.rb2 + cmp sample1.tst $(top_sourcedir)/sample1.ref + cmp sample2.tst $(top_sourcedir)/sample2.ref + cmp sample3.tst $(top_sourcedir)/sample3.ref + @cat $(top_sourcedir)/words3 clean: rm -f *.o *.lo *.a $(LIB) bzip2 bzip2recover \ @@ -107,10 +113,10 @@ clean: .SUFFIXES: .c .o .lo -%.o: %.c bzlib.h bzlib_private.h +%.o: $(top_sourcedir)/%.c $(top_sourcedir)/bzlib.h $(top_sourcedir)/bzlib_private.h $(CC) $(CFLAGS) -c $< -%.lo: %.c bzlib.h bzlib_private.h +%.lo: $(top_sourcedir)/%.c $(top_sourcedir)/bzlib.h $(top_sourcedir)/bzlib_private.h libtool --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< distclean: clean @@ -187,10 +193,10 @@ MANUAL_SRCS= bz-common.xsl bz-fo.xsl bz-html.xsl bzip.css \ manual: manual.html manual.ps manual.pdf manual.ps: $(MANUAL_SRCS) - ./xmlproc.sh -ps manual.xml + $(top_sourcedir)/xmlproc.sh -ps $(top_sourcedir)/manual.xml manual.pdf: $(MANUAL_SRCS) - ./xmlproc.sh -pdf manual.xml + $(top_sourcedir)/xmlproc.sh -pdf $(top_sourcedir)/manual.xml manual.html: $(MANUAL_SRCS) - ./xmlproc.sh -html manual.xml + $(top_sourcedir)/xmlproc.sh -html $(top_sourcedir)/manual.xml diff --git a/Makefile-libbz2_so b/Makefile-libbz2_so index e4f06b9..4c81c90 100644 --- a/Makefile-libbz2_so +++ b/Makefile-libbz2_so @@ -1,9 +1,9 @@ -# This Makefile builds a shared version of the library, +# This Makefile builds a shared version of the library, # libbz2.so.1.0.8, with soname libbz2.so.1.0, -# at least on x86-Linux (RedHat 7.2), -# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). -# Please see the README file for some important info +# at least on x86-Linux (RedHat 7.2), +# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). +# Please see the README file for some important info # about building the library like this. # ------------------------------------------------------------------ @@ -13,14 +13,20 @@ # bzip2/libbzip2 version 1.0.8 of 13 July 2019 # Copyright (C) 1996-2019 Julian Seward # -# Please read the WARNING, DISCLAIMER and PATENTS sections in the +# Please read the WARNING, DISCLAIMER and PATENTS sections in the # README file. # # This program is released under the terms of the license contained # in the file LICENSE. # ------------------------------------------------------------------ -include config.in +top_sourcedir = . +include $(top_sourcedir)/config.in + +prefix = /usr +root_libdir= /$(lib) +libdir = $(lib) + SHELL=/bin/sh CC=gcc @@ -36,26 +42,29 @@ OBJS= blocksort.o \ decompress.o \ bzlib.o -all: $(OBJS) - $(CC) $(CFLAGS) -shared -Wl,-soname -Wl,libbz2.so.1.0 $(LDFLAGS) -o libbz2.so.1.0.8 $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.8 +LIBRARY = libbz2.so.1.0.8 + +all: $(LIBRARY) + + +$(LIBRARY): $(OBJS) + $(CC) $(CFLAGS) -shared -Wl,-soname -Wl,libbz2.so.1 $(LDFLAGS) -o $(LIBRARY) $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2-shared $(top_sourcedir)/bzip2.c $(LIBRARY) rm -f libbz2.so.1.0 - ln -s libbz2.so.1.0.8 libbz2.so.1.0 - -clean: - rm -f $(OBJS) bzip2.o libbz2.so.1.0.8 libbz2.so.1.0 bzip2-shared - -blocksort.o: blocksort.c - $(CC) $(CFLAGS) -c blocksort.c -huffman.o: huffman.c - $(CC) $(CFLAGS) -c huffman.c -crctable.o: crctable.c - $(CC) $(CFLAGS) -c crctable.c -randtable.o: randtable.c - $(CC) $(CFLAGS) -c randtable.c -compress.o: compress.c - $(CC) $(CFLAGS) -c compress.c -decompress.o: decompress.c - $(CC) $(CFLAGS) -c decompress.c -bzlib.o: bzlib.c - $(CC) $(CFLAGS) -c bzlib.c + ln -s $(LIBRARY) libbz2.so.1.0 + ln -s $(LIBRARY) libbz2.so.1 + +install: all + mkdir -p $(DESTDIR)$(root_libdir) + install -m755 $(LIBRARY) $(DESTDIR)$(root_libdir) + ln -sf $(LIBRARY) $(DESTDIR)$(root_libdir)/libbz2.so.1.0 + ln -sf $(LIBRARY) $(DESTDIR)$(root_libdir)/libbz2.so.1 + mkdir -p $(DESTDIR)$(libdir) + rm -f $(DESTDIR)$(libdir)/libbz2.so + ln -sr $(DESTDIR)$(root_libdir)/$(LIBRARY) $(DESTDIR)$(libdir)/libbz2.so + +clean: + rm -f $(OBJS) bzip2.o $(LIBRARY) libbz2.so.1.0 bzip2-shared + +%.o: $(top_sourcedir)/%.c $(top_sourcedir)/bzlib.h $(top_sourcedir)/bzlib_private.h + $(CC) $(CFLAGS) -c $<