From 574825cf1bd8bd4f942e12de888396d43953d268 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 8 Apr 2004 15:04:40 +0000 Subject: [PATCH] Add a horrid md5sum manifest mechanism similar to the one I used in the Unix PuTTY archive, to automatically generate version numbers for Halibut release builds. git-svn-id: svn://svn.tartarus.org/sgt/halibut@4044 cda61777-01e9-0310-a592-d414129be87e --- INSTALL | 15 +++++++++++++++ Makefile | 60 +++++++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/INSTALL b/INSTALL index cb0259e..aa88766 100644 --- a/INSTALL +++ b/INSTALL @@ -14,6 +14,21 @@ If you have GNU make and gcc, you should simply be able to type `make'. The Makefile will generate a `build' subdirectory, and will put all the object files and binaries in there. +In a release archive, the Makefile will also check the source files +against a list of MD5 checksums, and if they match it will +automatically add the correct version number to the build. This is +_not_ a secure measure intended to enforce that only approved +Halibut sources are ever built into a binary with a given version +number; it is merely a sanity check against heavily modified copies +_accidentally_ confusing users expecting standard versions of +Halibut. Distribution maintainers are entirely at liberty, if they +choose, to modify Halibut source files as appropriate for their +distribution and then have the resulting binary call itself by the +original version number. If you run `make VERSION=x.y', the +resulting Halibut binary will call itself version x.y irrespective +of the md5sum manifest. (You may also need to do this if your build +system does not have the md5sum program.) + Halibut unfortunately does not yet come with an autoconf-generated makefile, so if you do not have these utilities then you will have to do the build manually. Look in the master `Makefile' to find the diff --git a/Makefile b/Makefile index ae1a5c9..3264a70 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,20 @@ # - the Makefile uses GNU ifdef / ifndef commands and GNU make `%' # pattern rules +ifdef RELEASE +ifndef VERSION +VERSION := $(RELEASE) +endif +else +CFLAGS += -g +endif + +ifeq (x$(VERSION)y,xy) +RELDIR := halibut +else +RELDIR := halibut-$(VERSION) +endif + # `make' from top level will build in directory `build' # `make BUILDDIR=foo' from top level will build in directory foo ifndef REALBUILD @@ -20,20 +34,46 @@ else BUILDDIR := build endif endif + all: @test -d $(BUILDDIR) || mkdir $(BUILDDIR) @make -C $(BUILDDIR) -f ../Makefile REALBUILD=yes + spotless: topclean @test -d $(BUILDDIR) || mkdir $(BUILDDIR) @make -C $(BUILDDIR) -f ../Makefile spotless REALBUILD=yes + clean: topclean @test -d $(BUILDDIR) || mkdir $(BUILDDIR) @make -C $(BUILDDIR) -f ../Makefile clean REALBUILD=yes + +# Remove Halibut output files in the source directory (may +# have been created by running, for example, `build/halibut +# inputs/test.but'). topclean: - # Remove Halibut output files in the source directory (may - # have been created by running, for example, `build/halibut - # inputs/test.but'). - rm -f *.html output.* + rm -f *.html output.* *.tar.gz + +# Make a release archive. If $(VERSION) is specified, this will +# also contain a `manifest' file which will be used to decide the +# version number automatically. +release: + find . -name CVS -prune -o -name build -prune -o -name reltmp -prune \ + -o -type d -exec mkdir -p reltmp/$(RELDIR)/{} \; + find . -name CVS -prune -o -name build -prune -o -name reltmp -prune \ + -o -name '*.orig' -prune -o -name '*.rej' -prune \ + -o -name '*.txt' -prune -o -name '*.html' -prune \ + -o -name '*.1' -prune -o -name '.cvsignore' -prune \ + -o -name '*.gz' -prune -o -name '.[^.]*' -prune \ + -o -type f -exec ln -s $(PWD)/{} reltmp/$(RELDIR)/{} \; + if test "x$(VERSION)y" != "xy"; then \ + (cd reltmp/$(RELDIR); \ + find . -name '*.[ch]' -exec md5sum {} \; \ + ) > reltmp/$(RELDIR)/manifest; \ + echo "-DVERSION=\"$(VERSION)\"" > reltmp/$(RELDIR)/version; \ + fi + tar chzvCf reltmp - $(RELDIR) > $(RELDIR).tar.gz + rm -rf reltmp + else # The `real' makefile part. @@ -45,21 +85,15 @@ CFLAGS += -DLOGALLOC LIBS += -lefence endif -ifdef RELEASE -ifndef VERSION -VERSION := $(RELEASE) -endif -else -CFLAGS += -g -endif - ifndef VER ifdef VERSION VER := $(VERSION) endif endif ifdef VER -VDEF := -DVERSION=\"$(VER)\" +VDEF = -DVERSION=\"$(VER)\" +else +VDEF = `(cd $(SRC); md5sum -c manifest && cat version)` endif SRC := ../ -- 2.11.0