From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-b.sr.ht (mail-b.sr.ht [173.195.146.151]) by sourceware.org (Postfix) with ESMTPS id 7BA59385AE5C for ; Thu, 9 Jun 2022 05:50:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7BA59385AE5C Received: from git.sr.ht (unknown [173.195.146.142]) by mail-b.sr.ht (Postfix) with ESMTPSA id AE31911EEC2; Thu, 9 Jun 2022 05:50:48 +0000 (UTC) From: ~eschwartz Date: Fri, 03 Jun 2022 00:20:10 -0400 Subject: [PATCH bzip2 2/6] port the build configuration to autoconf MIME-Version: 1.0 Message-ID: <165475384722.17277.18269615533597437835-1@git.sr.ht> X-Mailer: git.sr.ht Reply-to: ~eschwartz In-Reply-To: <165475384722.17277.18269615533597437835-0@git.sr.ht> To: bzip2-devel@sourceware.org Cc: eschwartz93@gmail.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DATE_IN_PAST_96_XX, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: bzip2-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bzip2-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2022 05:50:58 -0000 From: Eli Schwartz 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 =3D> Makefile-libbz2_so.in | 14 +-- Makefile =3D> Makefile.in | 104 +++++++++++--------- configure.ac | 10 ++ prepare-release.sh | 10 +- 4 files changed, 77 insertions(+), 61 deletions(-) rename Makefile-libbz2_so =3D> Makefile-libbz2_so.in (80%) rename Makefile =3D> 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 @@ =20 =20 SHELL=3D/bin/sh -CC=3Dgcc +CC=3D@CC@ BIGFILES=3D-D_FILE_OFFSET_BITS=3D64 -CFLAGS=3D-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES) +CFLAGS=3D-fpic -fPIC -Wall -Winline @CFLAGS@ $(BIGFILES) =20 OBJS=3D blocksort.o \ huffman.o \ @@ -35,13 +35,13 @@ OBJS=3D blocksort.o \ bzlib.o =20 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 =20 -clean:=20 - 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 =20 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=3D/bin/sh =20 # To assist in cross-compiling -CC=3Dgcc -AR=3Dar -RANLIB=3Dranlib -LDFLAGS=3D +CC=3D@CC@ +AR=3D@AR@ +RANLIB=3D@RANLIB@ +LDFLAGS=3D@LDFLAGS@ =20 BIGFILES=3D-D_FILE_OFFSET_BITS=3D64 -CFLAGS=3D-Wall -Winline -O2 -g $(BIGFILES) +CFLAGS=3D-Wall -Winline @CFLAGS@ $(BIGFILES) =20 # Where you want it installed when you do 'make install' -PREFIX=3D/usr/local +prefix =3D @prefix@ +exec_prefix =3D @exec_prefix@ +bindir =3D @bindir@ +includedir =3D @includedir@ +libdir =3D @libdir@ +datarootdir =3D @datarootdir@ +mandir =3D @mandir@ =20 =20 OBJS=3D blocksort.o \ @@ -70,45 +76,45 @@ test: bzip2 @cat words3 =20 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:=20 + 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)$(mandi= r)/man1 ; fi + if ( test ! -d $(DESTDIR)$(includedir) ) ; then mkdir -p $(DESTDIR)$(includ= edir) ; 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 =20 -DISTNAME=3Dbzip2-1.0.8 +DISTNAME=3Dbzip2-@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_VERSIO= N \"${VERSION}, ${DAY sed -i -e "s@\"bzip2recover .*: extracts blocks from damaged@\"bzip2recover = ${VERSION}: extracts blocks from damaged@" \ bzip2recover.c =20 -# And finally update the version/dist/so_name in the Makefiles. -sed -i -e "s@^DISTNAME=3Dbzip2-.*@DISTNAME=3Dbzip2-${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 =20 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 --=20 2.34.2