[PATCH bzip2 2/6] port the build configuration to autoconf
~eschwartz
eschwartz@git.sr.ht
Fri Jun 3 04:20:10 GMT 2022
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
More information about the Bzip2-devel
mailing list