From: ~eschwartz <eschwartz@git.sr.ht>
To: bzip2-devel@sourceware.org
Cc: eschwartz93@gmail.com
Subject: [PATCH bzip2 2/6] port the build configuration to autoconf
Date: Fri, 03 Jun 2022 00:20:10 -0400 [thread overview]
Message-ID: <165475384722.17277.18269615533597437835-1@git.sr.ht> (raw)
In-Reply-To: <165475384722.17277.18269615533597437835-0@git.sr.ht>
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
next prev parent reply other threads:[~2022-06-09 5:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-03 3:45 [PATCH bzip2 1/6] install relative symlinks ~eschwartz
2022-06-03 4:20 ` ~eschwartz [this message]
2022-06-09 5:56 ` [PATCH bzip2 2/6] port the build configuration to autoconf 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=165475384722.17277.18269615533597437835-1@git.sr.ht \
--to=eschwartz@git.sr.ht \
--cc=bzip2-devel@sourceware.org \
--cc=eschwartz93@gmail.com \
--cc=eschwartz@archlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).