public inbox for bzip2-devel@sourceware.org
 help / color / mirror / Atom feed
* [PATCH bzip2 1/6] install relative symlinks
@ 2022-06-03  3:45 ~eschwartz
  2022-06-03  4:20 ` [PATCH bzip2 2/6] port the build configuration to autoconf ~eschwartz
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: ~eschwartz @ 2022-06-03  3:45 UTC (permalink / raw)
  To: bzip2-devel; +Cc: eschwartz93

From: Eli Schwartz <eschwartz93@gmail.com>

During `make install`, symlinks for command aliases are created which
embed an absolute path to the installed location of the real file. This
causes issues with relocation, for example when packaging for distros.

Use symlinks that search for a file in the same directory as the
symlink, instead. This is guaranteed to have the same results, except
more accurate.
---
 Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index b0fef95..009463a 100644
--- a/Makefile
+++ b/Makefile
@@ -90,14 +90,14 @@ install: bzip2 bzip2recover
 	cp -f libbz2.a $(PREFIX)/lib
 	chmod a+r $(PREFIX)/lib/libbz2.a
 	cp -f bzgrep $(PREFIX)/bin/bzgrep
-	ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
-	ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
+	ln -s -f bzgrep $(PREFIX)/bin/bzegrep
+	ln -s -f bzgrep $(PREFIX)/bin/bzfgrep
 	chmod a+x $(PREFIX)/bin/bzgrep
 	cp -f bzmore $(PREFIX)/bin/bzmore
-	ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
+	ln -s -f bzmore $(PREFIX)/bin/bzless
 	chmod a+x $(PREFIX)/bin/bzmore
 	cp -f bzdiff $(PREFIX)/bin/bzdiff
-	ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
+	ln -s -f bzdiff $(PREFIX)/bin/bzcmp
 	chmod a+x $(PREFIX)/bin/bzdiff
 	cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
 	chmod a+r $(PREFIX)/man/man1/bzgrep.1
-- 
2.34.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH bzip2 2/6] port the build configuration to autoconf
  2022-06-03  3:45 [PATCH bzip2 1/6] install relative symlinks ~eschwartz
@ 2022-06-03  4:20 ` ~eschwartz
  2022-06-09  5:56   ` Eli Schwartz
  2022-06-03  4:48 ` [PATCH bzip2 4/6] make a couple program aliases symlinks instead of copies ~eschwartz
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: ~eschwartz @ 2022-06-03  4:20 UTC (permalink / raw)
  To: bzip2-devel; +Cc: eschwartz93

From: Eli Schwartz <eschwartz93@gmail.com>

This doesn't investigate the topic of fully autotools'ing the build,
with automake and libtool, as there are libtool compatibility
considerations to take into account.

All we do for now is make the standard ./configure script that formats
the Makefile in order to respect some low-level standards:

- GNU directory variables to control output locations.
  - respect $DESTDIR if given.
- check for $CC, $CFLAGS, etc
  - including cross-compile support
---
 Makefile-libbz2_so => Makefile-libbz2_so.in |  14 +--
 Makefile => Makefile.in                     | 104 +++++++++++---------
 configure.ac                                |  10 ++
 prepare-release.sh                          |  10 +-
 4 files changed, 77 insertions(+), 61 deletions(-)
 rename Makefile-libbz2_so => Makefile-libbz2_so.in (80%)
 rename Makefile => Makefile.in (67%)
 create mode 100644 configure.ac

diff --git a/Makefile-libbz2_so b/Makefile-libbz2_so.in
similarity index 80%
rename from Makefile-libbz2_so
rename to Makefile-libbz2_so.in
index fb0f230..0d2cf8d 100644
--- a/Makefile-libbz2_so
+++ b/Makefile-libbz2_so.in
@@ -22,9 +22,9 @@
 
 
 SHELL=/bin/sh
-CC=gcc
+CC=@CC@
 BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS=-fpic -fPIC -Wall -Winline @CFLAGS@ $(BIGFILES)
 
 OBJS= blocksort.o  \
       huffman.o    \
@@ -35,13 +35,13 @@ OBJS= blocksort.o  \
       bzlib.o
 
 all: $(OBJS)
-	$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.8 $(OBJS)
-	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.8
+	$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.@PACKAGE_VERSION@ $(OBJS)
+	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.@PACKAGE_VERSION@
 	rm -f libbz2.so.1.0
-	ln -s libbz2.so.1.0.8 libbz2.so.1.0
+	ln -s libbz2.so.@PACKAGE_VERSION@ libbz2.so.1.0
 
-clean: 
-	rm -f $(OBJS) bzip2.o libbz2.so.1.0.8 libbz2.so.1.0 bzip2-shared
+clean:
+	rm -f $(OBJS) bzip2.o libbz2.so.@PACKAGE_VERSION@ libbz2.so.1.0 bzip2-shared
 
 blocksort.o: blocksort.c
 	$(CC) $(CFLAGS) -c blocksort.c
diff --git a/Makefile b/Makefile.in
similarity index 67%
rename from Makefile
rename to Makefile.in
index 009463a..6631733 100644
--- a/Makefile
+++ b/Makefile.in
@@ -15,16 +15,22 @@
 SHELL=/bin/sh
 
 # To assist in cross-compiling
-CC=gcc
-AR=ar
-RANLIB=ranlib
-LDFLAGS=
+CC=@CC@
+AR=@AR@
+RANLIB=@RANLIB@
+LDFLAGS=@LDFLAGS@
 
 BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS=-Wall -Winline @CFLAGS@ $(BIGFILES)
 
 # Where you want it installed when you do 'make install'
-PREFIX=/usr/local
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+includedir = @includedir@
+libdir = @libdir@
+datarootdir = @datarootdir@
+mandir = @mandir@
 
 
 OBJS= blocksort.o  \
@@ -70,45 +76,45 @@ test: bzip2
 	@cat words3
 
 install: bzip2 bzip2recover
-	if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
-	if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
-	if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi
-	if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi
-	if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
-	cp -f bzip2 $(PREFIX)/bin/bzip2
-	cp -f bzip2 $(PREFIX)/bin/bunzip2
-	cp -f bzip2 $(PREFIX)/bin/bzcat
-	cp -f bzip2recover $(PREFIX)/bin/bzip2recover
-	chmod a+x $(PREFIX)/bin/bzip2
-	chmod a+x $(PREFIX)/bin/bunzip2
-	chmod a+x $(PREFIX)/bin/bzcat
-	chmod a+x $(PREFIX)/bin/bzip2recover
-	cp -f bzip2.1 $(PREFIX)/man/man1
-	chmod a+r $(PREFIX)/man/man1/bzip2.1
-	cp -f bzlib.h $(PREFIX)/include
-	chmod a+r $(PREFIX)/include/bzlib.h
-	cp -f libbz2.a $(PREFIX)/lib
-	chmod a+r $(PREFIX)/lib/libbz2.a
-	cp -f bzgrep $(PREFIX)/bin/bzgrep
-	ln -s -f bzgrep $(PREFIX)/bin/bzegrep
-	ln -s -f bzgrep $(PREFIX)/bin/bzfgrep
-	chmod a+x $(PREFIX)/bin/bzgrep
-	cp -f bzmore $(PREFIX)/bin/bzmore
-	ln -s -f bzmore $(PREFIX)/bin/bzless
-	chmod a+x $(PREFIX)/bin/bzmore
-	cp -f bzdiff $(PREFIX)/bin/bzdiff
-	ln -s -f bzdiff $(PREFIX)/bin/bzcmp
-	chmod a+x $(PREFIX)/bin/bzdiff
-	cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
-	chmod a+r $(PREFIX)/man/man1/bzgrep.1
-	chmod a+r $(PREFIX)/man/man1/bzmore.1
-	chmod a+r $(PREFIX)/man/man1/bzdiff.1
-	echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1
-	echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1
-	echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1
-	echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1
-
-clean: 
+	if ( test ! -d $(DESTDIR)$(bindir) ) ; then mkdir -p $(DESTDIR)$(bindir) ; fi
+	if ( test ! -d $(DESTDIR)$(libdir) ) ; then mkdir -p $(DESTDIR)$(libdir) ; fi
+	if ( test ! -d $(DESTDIR)$(mandir) ) ; then mkdir -p $(DESTDIR)$(mandir) ; fi
+	if ( test ! -d $(DESTDIR)$(mandir)/man1 ) ; then mkdir -p $(DESTDIR)$(mandir)/man1 ; fi
+	if ( test ! -d $(DESTDIR)$(includedir) ) ; then mkdir -p $(DESTDIR)$(includedir) ; fi
+	cp -f bzip2 $(DESTDIR)$(bindir)/bzip2
+	cp -f bzip2 $(DESTDIR)$(bindir)/bunzip2
+	cp -f bzip2 $(DESTDIR)$(bindir)/bzcat
+	cp -f bzip2recover $(DESTDIR)$(bindir)/bzip2recover
+	chmod a+x $(DESTDIR)$(bindir)/bzip2
+	chmod a+x $(DESTDIR)$(bindir)/bunzip2
+	chmod a+x $(DESTDIR)$(bindir)/bzcat
+	chmod a+x $(DESTDIR)$(bindir)/bzip2recover
+	cp -f bzip2.1 $(DESTDIR)$(mandir)/man1
+	chmod a+r $(DESTDIR)$(mandir)/man1/bzip2.1
+	cp -f bzlib.h $(DESTDIR)$(includedir)
+	chmod a+r $(DESTDIR)$(includedir)/bzlib.h
+	cp -f libbz2.a $(DESTDIR)$(libdir)
+	chmod a+r $(DESTDIR)$(libdir)/libbz2.a
+	cp -f bzgrep $(DESTDIR)$(bindir)/bzgrep
+	ln -s -f bzgrep $(DESTDIR)$(bindir)/bzegrep
+	ln -s -f bzgrep $(DESTDIR)$(bindir)/bzfgrep
+	chmod a+x $(DESTDIR)$(bindir)/bzgrep
+	cp -f bzmore $(DESTDIR)$(bindir)/bzmore
+	ln -s -f bzmore $(DESTDIR)$(bindir)/bzless
+	chmod a+x $(DESTDIR)$(bindir)/bzmore
+	cp -f bzdiff $(DESTDIR)$(bindir)/bzdiff
+	ln -s -f bzdiff $(DESTDIR)$(bindir)/bzcmp
+	chmod a+x $(DESTDIR)$(bindir)/bzdiff
+	cp -f bzgrep.1 bzmore.1 bzdiff.1 $(DESTDIR)$(mandir)/man1
+	chmod a+r $(DESTDIR)$(mandir)/man1/bzgrep.1
+	chmod a+r $(DESTDIR)$(mandir)/man1/bzmore.1
+	chmod a+r $(DESTDIR)$(mandir)/man1/bzdiff.1
+	echo ".so man1/bzgrep.1" > $(DESTDIR)$(mandir)/man1/bzegrep.1
+	echo ".so man1/bzgrep.1" > $(DESTDIR)$(mandir)/man1/bzfgrep.1
+	echo ".so man1/bzmore.1" > $(DESTDIR)$(mandir)/man1/bzless.1
+	echo ".so man1/bzdiff.1" > $(DESTDIR)$(mandir)/man1/bzcmp.1
+
+clean:
 	rm -f *.o libbz2.a bzip2 bzip2recover \
 	sample1.rb2 sample2.rb2 sample3.rb2 \
 	sample1.tst sample2.tst sample3.tst
@@ -137,7 +143,7 @@ bzip2recover.o: bzip2recover.c
 distclean: clean
 	rm -f manual.ps manual.html manual.pdf bzip2.txt bzip2.1.preformatted
 
-DISTNAME=bzip2-1.0.8
+DISTNAME=bzip2-@PACKAGE_VERSION@
 dist: check manual
 	rm -f $(DISTNAME)
 	ln -s -f . $(DISTNAME)
@@ -153,7 +159,9 @@ dist: check manual
 	   $(DISTNAME)/bzip2recover.c \
 	   $(DISTNAME)/bzlib.h \
 	   $(DISTNAME)/bzlib_private.h \
-	   $(DISTNAME)/Makefile \
+	   $(DISTNAME)/configure.ac \
+	   $(DISTNAME)/configure \
+	   $(DISTNAME)/Makefile.in \
 	   $(DISTNAME)/LICENSE \
 	   $(DISTNAME)/bzip2.1 \
 	   $(DISTNAME)/bzip2.1.preformatted \
@@ -189,7 +197,7 @@ dist: check manual
 	   $(DISTNAME)/bzmore.1 \
 	   $(DISTNAME)/bzgrep \
 	   $(DISTNAME)/bzgrep.1 \
-	   $(DISTNAME)/Makefile-libbz2_so \
+	   $(DISTNAME)/Makefile-libbz2_so.in \
 	   $(DISTNAME)/bz-common.xsl \
 	   $(DISTNAME)/bz-fo.xsl \
 	   $(DISTNAME)/bz-html.xsl \
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..8f26062
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,10 @@
+AC_INIT([bzip2], [1.0.8])
+
+# standard compiler variables
+AC_PROG_CC
+AC_CHECK_TOOL([AR], [ar])
+AC_CHECK_TOOL([RANLIB], [ranlib])
+
+AC_CONFIG_FILES([Makefile Makefile-libbz2_so])
+
+AC_OUTPUT
diff --git a/prepare-release.sh b/prepare-release.sh
index 1bc8474..06430a9 100755
--- a/prepare-release.sh
+++ b/prepare-release.sh
@@ -54,11 +54,9 @@ sed -i -e "s@^#define BZ_VERSION  \".*\"@#define BZ_VERSION  \"${VERSION}, ${DAY
 sed -i -e "s@\"bzip2recover .*: extracts blocks from damaged@\"bzip2recover ${VERSION}: extracts blocks from damaged@" \
   bzip2recover.c
 
-# And finally update the version/dist/so_name in the Makefiles.
-sed -i -e "s@^DISTNAME=bzip2-.*@DISTNAME=bzip2-${VERSION}@" \
-  Makefile
-sed -i -e "s@libbz2\.so\.[0-9]\.[0-9]\.[0-9]*@libbz2\.so\.${VERSION}@" \
-  Makefile-libbz2_so
+# And finally update the version/dist/so_name in the configure script.
+sed -i -e "/AC_INIT/{s@[0-9]\.[0-9]\.[0-9]@${VERSION}@}" \
+    configure.ac
 
 echo "Now make sure the diff looks correct:"
 echo "  git diff"
@@ -66,7 +64,7 @@ echo
 echo "And make sure there is a $VERSION section in the CHANGES file."
 echo
 echo "Double check:"
-echo "  make clean && make dist && make clean && make -f Makefile-libbz2_so"
+echo "  autoconf && ./configure && make clean && make dist && make clean && make -f Makefile-libbz2_so"
 echo
 echo "Does everything look fine?"
 echo
-- 
2.34.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH bzip2 4/6] make a couple program aliases symlinks instead of copies
  2022-06-03  3:45 [PATCH bzip2 1/6] install relative symlinks ~eschwartz
  2022-06-03  4:20 ` [PATCH bzip2 2/6] port the build configuration to autoconf ~eschwartz
@ 2022-06-03  4:48 ` ~eschwartz
  2022-06-03  4:54 ` [PATCH bzip2 5/6] install man page symlinks for a couple more symlinked commands ~eschwartz
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: ~eschwartz @ 2022-06-03  4:48 UTC (permalink / raw)
  To: bzip2-devel; +Cc: eschwartz93

From: Eli Schwartz <eschwartz93@gmail.com>

Some programs are installed one way, some are installed the other way.
Be consistent and always use symlinks.
---
 Makefile.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 6631733..76dfe9a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -82,8 +82,8 @@ install: bzip2 bzip2recover
 	if ( test ! -d $(DESTDIR)$(mandir)/man1 ) ; then mkdir -p $(DESTDIR)$(mandir)/man1 ; fi
 	if ( test ! -d $(DESTDIR)$(includedir) ) ; then mkdir -p $(DESTDIR)$(includedir) ; fi
 	cp -f bzip2 $(DESTDIR)$(bindir)/bzip2
-	cp -f bzip2 $(DESTDIR)$(bindir)/bunzip2
-	cp -f bzip2 $(DESTDIR)$(bindir)/bzcat
+	ln -s -f bzip2 $(DESTDIR)$(bindir)/bunzip2
+	ln -s -f bzip2 $(DESTDIR)$(bindir)/bzcat
 	cp -f bzip2recover $(DESTDIR)$(bindir)/bzip2recover
 	chmod a+x $(DESTDIR)$(bindir)/bzip2
 	chmod a+x $(DESTDIR)$(bindir)/bunzip2
-- 
2.34.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH bzip2 5/6] install man page symlinks for a couple more symlinked commands
  2022-06-03  3:45 [PATCH bzip2 1/6] install relative symlinks ~eschwartz
  2022-06-03  4:20 ` [PATCH bzip2 2/6] port the build configuration to autoconf ~eschwartz
  2022-06-03  4:48 ` [PATCH bzip2 4/6] make a couple program aliases symlinks instead of copies ~eschwartz
@ 2022-06-03  4:54 ` ~eschwartz
  2022-06-03  5:09 ` [PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2 ~eschwartz
  2022-06-09  4:50 ` [PATCH bzip2 3/6] shared Makefile: add install rule ~eschwartz
  4 siblings, 0 replies; 9+ messages in thread
From: ~eschwartz @ 2022-06-03  4:54 UTC (permalink / raw)
  To: bzip2-devel; +Cc: eschwartz93

From: Eli Schwartz <eschwartz93@gmail.com>

---
 Makefile.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile.in b/Makefile.in
index 76dfe9a..dff9422 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -91,6 +91,9 @@ install: bzip2 bzip2recover
 	chmod a+x $(DESTDIR)$(bindir)/bzip2recover
 	cp -f bzip2.1 $(DESTDIR)$(mandir)/man1
 	chmod a+r $(DESTDIR)$(mandir)/man1/bzip2.1
+	echo ".so man1/bzip2.1" > $(DESTDIR)$(mandir)/man1/bunzip2.1
+	echo ".so man1/bzip2.1" > $(DESTDIR)$(mandir)/man1/bzcat.1
+	echo ".so man1/bzip2.1" > $(DESTDIR)$(mandir)/man1/bzip2recover.1
 	cp -f bzlib.h $(DESTDIR)$(includedir)
 	chmod a+r $(DESTDIR)$(includedir)/bzlib.h
 	cp -f libbz2.a $(DESTDIR)$(libdir)
-- 
2.34.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2
  2022-06-03  3:45 [PATCH bzip2 1/6] install relative symlinks ~eschwartz
                   ` (2 preceding siblings ...)
  2022-06-03  4:54 ` [PATCH bzip2 5/6] install man page symlinks for a couple more symlinked commands ~eschwartz
@ 2022-06-03  5:09 ` ~eschwartz
  2022-06-09  5:52   ` Eli Schwartz
  2022-06-09  4:50 ` [PATCH bzip2 3/6] shared Makefile: add install rule ~eschwartz
  4 siblings, 1 reply; 9+ messages in thread
From: ~eschwartz @ 2022-06-03  5:09 UTC (permalink / raw)
  To: bzip2-devel; +Cc: eschwartz93

From: Eli Schwartz <eschwartz93@gmail.com>

A pkg-config file is necessary in order to robustly communicate across
build systems that bz2 is installed, *where* it is installed, and the
correct CFLAGS / LDFLAGS to use in order to compile and link against it.
---
 Makefile.in  |  3 +++
 bzip2.pc.in  | 11 +++++++++++
 configure.ac |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 bzip2.pc.in

diff --git a/Makefile.in b/Makefile.in
index dff9422..86f1bdc 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -78,6 +78,7 @@ test: bzip2
 install: bzip2 bzip2recover
 	if ( test ! -d $(DESTDIR)$(bindir) ) ; then mkdir -p $(DESTDIR)$(bindir) ; fi
 	if ( test ! -d $(DESTDIR)$(libdir) ) ; then mkdir -p $(DESTDIR)$(libdir) ; fi
+	if ( test ! -d $(DESTDIR)$(libdir)/pkgconfig ) ; then mkdir -p $(DESTDIR)$(libdir)/pkgconfig ; fi
 	if ( test ! -d $(DESTDIR)$(mandir) ) ; then mkdir -p $(DESTDIR)$(mandir) ; fi
 	if ( test ! -d $(DESTDIR)$(mandir)/man1 ) ; then mkdir -p $(DESTDIR)$(mandir)/man1 ; fi
 	if ( test ! -d $(DESTDIR)$(includedir) ) ; then mkdir -p $(DESTDIR)$(includedir) ; fi
@@ -116,6 +117,7 @@ install: bzip2 bzip2recover
 	echo ".so man1/bzgrep.1" > $(DESTDIR)$(mandir)/man1/bzfgrep.1
 	echo ".so man1/bzmore.1" > $(DESTDIR)$(mandir)/man1/bzless.1
 	echo ".so man1/bzdiff.1" > $(DESTDIR)$(mandir)/man1/bzcmp.1
+	cp -f bzip2.pc $(DESTDIR)$(libdir)/pkgconfig/bzip2.pc
 
 clean:
 	rm -f *.o libbz2.a bzip2 bzip2recover \
@@ -165,6 +167,7 @@ dist: check manual
 	   $(DISTNAME)/configure.ac \
 	   $(DISTNAME)/configure \
 	   $(DISTNAME)/Makefile.in \
+	   $(DISTNAME)/bzip2.pc.in \
 	   $(DISTNAME)/LICENSE \
 	   $(DISTNAME)/bzip2.1 \
 	   $(DISTNAME)/bzip2.1.preformatted \
diff --git a/bzip2.pc.in b/bzip2.pc.in
new file mode 100644
index 0000000..11c14e1
--- /dev/null
+++ b/bzip2.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+Name: bzip2
+URL: https://sourceware.org/bzip2/
+Description: A file compression library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lbz2
+Cflags: -I${includedir}
diff --git a/configure.ac b/configure.ac
index 8f26062..5936b5c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,6 +5,6 @@ AC_PROG_CC
 AC_CHECK_TOOL([AR], [ar])
 AC_CHECK_TOOL([RANLIB], [ranlib])
 
-AC_CONFIG_FILES([Makefile Makefile-libbz2_so])
+AC_CONFIG_FILES([Makefile Makefile-libbz2_so bzip2.pc])
 
 AC_OUTPUT
-- 
2.34.2

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH bzip2 3/6] shared Makefile: add install rule
  2022-06-03  3:45 [PATCH bzip2 1/6] install relative symlinks ~eschwartz
                   ` (3 preceding siblings ...)
  2022-06-03  5:09 ` [PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2 ~eschwartz
@ 2022-06-09  4:50 ` ~eschwartz
  4 siblings, 0 replies; 9+ messages in thread
From: ~eschwartz @ 2022-06-09  4:50 UTC (permalink / raw)
  To: bzip2-devel; +Cc: eschwartz93

From: Eli Schwartz <eschwartz93@gmail.com>

This will install the shared components (possibly overwriting these
components installed by the static Makefile).

As a prerequisite, the build rules must be refactored to use file-based
targets.
---
 Makefile-libbz2_so.in | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/Makefile-libbz2_so.in b/Makefile-libbz2_so.in
index 0d2cf8d..21fbe7c 100644
--- a/Makefile-libbz2_so.in
+++ b/Makefile-libbz2_so.in
@@ -26,6 +26,11 @@ CC=@CC@
 BIGFILES=-D_FILE_OFFSET_BITS=64
 CFLAGS=-fpic -fPIC -Wall -Winline @CFLAGS@ $(BIGFILES)
 
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+libdir = @libdir@
+
 OBJS= blocksort.o  \
       huffman.o    \
       crctable.o   \
@@ -34,12 +39,23 @@ OBJS= blocksort.o  \
       decompress.o \
       bzlib.o
 
-all: $(OBJS)
+all: libbz2.so.@PACKAGE_VERSION@ bzip2-shared
+
+libbz2.so.@PACKAGE_VERSION@: $(OBJS)
 	$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.@PACKAGE_VERSION@ $(OBJS)
-	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.@PACKAGE_VERSION@
 	rm -f libbz2.so.1.0
 	ln -s libbz2.so.@PACKAGE_VERSION@ libbz2.so.1.0
 
+bzip2-shared: libbz2.so.@PACKAGE_VERSION@
+	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.@PACKAGE_VERSION@
+
+install: all
+	if ( test ! -d $(DESTDIR)$(bindir) ) ; then mkdir -p $(DESTDIR)$(bindir) ; fi
+	if ( test ! -d $(DESTDIR)$(libdir) ) ; then mkdir -p $(DESTDIR)$(libdir) ; fi
+	cp -f bzip2-shared $(DESTDIR)$(bindir)/bzip2
+	cp -f libbz2.so.@PACKAGE_VERSION@ $(DESTDIR)$(libdir)
+	ln -s -f libbz2.so.@PACKAGE_VERSION@ $(DESTDIR)$(libdir)/libbz2.so.1.0
+
 clean:
 	rm -f $(OBJS) bzip2.o libbz2.so.@PACKAGE_VERSION@ libbz2.so.1.0 bzip2-shared
 
-- 
2.34.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2
  2022-06-03  5:09 ` [PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2 ~eschwartz
@ 2022-06-09  5:52   ` Eli Schwartz
  2022-10-23 16:03     ` Sam James
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Schwartz @ 2022-06-09  5:52 UTC (permalink / raw)
  To: bzip2-devel

On 6/3/22 1:09 AM, ~eschwartz wrote:
> From: Eli Schwartz <eschwartz93@gmail.com>
> 
> A pkg-config file is necessary in order to robustly communicate across
> build systems that bz2 is installed, *where* it is installed, and the
> correct CFLAGS / LDFLAGS to use in order to compile and link against it.


Some distros already provide one of these, so it's currently a bit
inconsistent how to look for the library. As a result, there is software
in the wild that probes for the library name, and fails if the library
is installed to a custom prefix, and other software that checks for
pkg-config, and fails on distros that don't provide their own bzip2.pc

In general it's good to have.

And particularly, it makes it much easier to detect bzip2 as "a
dependency" instead of "manual linker flags" from the Meson build
system, which can then toggle between multiple "dependency" providers
via e.g.
https://mesonbuild.com/Wrap-dependency-system-manual.html#provide-section

-- 
Eli Schwartz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bzip2 2/6] port the build configuration to autoconf
  2022-06-03  4:20 ` [PATCH bzip2 2/6] port the build configuration to autoconf ~eschwartz
@ 2022-06-09  5:56   ` Eli Schwartz
  0 siblings, 0 replies; 9+ messages in thread
From: Eli Schwartz @ 2022-06-09  5:56 UTC (permalink / raw)
  To: ~eschwartz, bzip2-devel

On 6/3/22 12:20 AM, ~eschwartz wrote:
> From: Eli Schwartz <eschwartz93@gmail.com>
> 
> This doesn't investigate the topic of fully autotools'ing the build,
> with automake and libtool, as there are libtool compatibility
> considerations to take into account.
> 
> All we do for now is make the standard ./configure script that formats
> the Makefile in order to respect some low-level standards:
> 
> - GNU directory variables to control output locations.
>   - respect $DESTDIR if given.
> - check for $CC, $CFLAGS, etc
>   - including cross-compile support
> ---


I was unable to actually test `make dist`, by the way, as it didn't seem
to want to play nicely with texlive on my system.


$ make manual.pdf
./xmlproc.sh -pdf manual.xml
Creating manual.pdf ...
Making portrait pages on USletter paper (8.5inx11in)
Cleaning up: output manual.fmt *.aux manual.fo manual.log texput.log *.out
  deleting output
  deleting manual.fmt
  deleting *.aux
rm: cannot remove '*.aux': No such file or directory
  deleting manual.fo
  deleting manual.log
  deleting texput.log
  deleting *.out
rm: cannot remove '*.out': No such file or directory
make: *** [Makefile:234: manual.pdf] Error 1



This shell script for creating the manual fails to create either the pdf
file, or the temporary files that it then fails to remove... but it
doesn't say why it failed so it's not clear whether I have a
misconfiguration or what.

-- 
Eli Schwartz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2
  2022-06-09  5:52   ` Eli Schwartz
@ 2022-10-23 16:03     ` Sam James
  0 siblings, 0 replies; 9+ messages in thread
From: Sam James @ 2022-10-23 16:03 UTC (permalink / raw)
  To: Eli Schwartz; +Cc: bzip2-devel, David Seifert

[-- Attachment #1: Type: text/plain, Size: 1205 bytes --]



> On 9 Jun 2022, at 06:52, Eli Schwartz via Bzip2-devel <bzip2-devel@sourceware.org> wrote:
> 
> On 6/3/22 1:09 AM, ~eschwartz wrote:
>> From: Eli Schwartz <eschwartz93@gmail.com>
>> 
>> A pkg-config file is necessary in order to robustly communicate across
>> build systems that bz2 is installed, *where* it is installed, and the
>> correct CFLAGS / LDFLAGS to use in order to compile and link against it.
> 
> 
> Some distros already provide one of these, so it's currently a bit
> inconsistent how to look for the library. As a result, there is software
> in the wild that probes for the library name, and fails if the library
> is installed to a custom prefix, and other software that checks for
> pkg-config, and fails on distros that don't provide their own bzip2.pc
> 
> In general it's good to have.
> 
> And particularly, it makes it much easier to detect bzip2 as "a
> dependency" instead of "manual linker flags" from the Meson build
> system, which can then toggle between multiple "dependency" providers
> via e.g.
> https://mesonbuild.com/Wrap-dependency-system-manual.html#provide-section
> 

The whole series looks great, thanks for doing this.

Best,
sam

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 358 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-10-23 16:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03  3:45 [PATCH bzip2 1/6] install relative symlinks ~eschwartz
2022-06-03  4:20 ` [PATCH bzip2 2/6] port the build configuration to autoconf ~eschwartz
2022-06-09  5:56   ` Eli Schwartz
2022-06-03  4:48 ` [PATCH bzip2 4/6] make a couple program aliases symlinks instead of copies ~eschwartz
2022-06-03  4:54 ` [PATCH bzip2 5/6] install man page symlinks for a couple more symlinked commands ~eschwartz
2022-06-03  5:09 ` [PATCH bzip2 6/6] install a pkg-config file with instructions for linking to libbz2 ~eschwartz
2022-06-09  5:52   ` Eli Schwartz
2022-10-23 16:03     ` Sam James
2022-06-09  4:50 ` [PATCH bzip2 3/6] shared Makefile: add install rule ~eschwartz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).