build, debian/: Add a `configure' script to make things easier.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 6 Jun 2018 23:37:22 +0000 (00:37 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 6 Jun 2018 23:55:08 +0000 (00:55 +0100)
Amazingly, this is good enough to work with Debhelper, so throw out the
earlier fiddling.

.gitignore
Make.rules [moved from Makefile with 95% similarity]
configure [new file with mode: 0755]
debian/.gitignore
debian/rules

index aa06ea3..5263fce 100644 (file)
@@ -3,6 +3,8 @@
 *.o
 *.d
 /COPYING
+/Makefile
 /auto-version
+/config.mk
 /noip
 /uopen
similarity index 95%
rename from Makefile
rename to Make.rules
index b77af1d..4129928 100644 (file)
--- a/Makefile
@@ -23,7 +23,7 @@
 ### with preload-hacks; if not, write to the Free Software Foundation, Inc.,
 ### 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-srcdir                  = .
+srcdir                 ?= .
 PACKAGE                         = preload-hacks
 VERSION                        := $(shell cd $(srcdir) && ./auto-version)
 
@@ -114,7 +114,8 @@ distdir                      = $(PACKAGE)-$(VERSION)
 DISTTAR                         = $(distdir).tar.gz
 
 ## Distribute the build utilities.
-DISTFILES              += Makefile
+DISTFILES              += Make.rules
+DISTFILES              += configure
 DISTFILES              += auto-version
 
 ## Documentation.
@@ -205,10 +206,10 @@ distcheck: dist
        +cd _distcheck && \
        tar xvfz ../$(DISTTAR) && \
        mkdir _build && cd _build && \
-       make -f../$(distdir)/Makefile srcdir=../$(distdir) && \
-       make -f../$(distdir)/Makefile srcdir=../$(distdir) \
-               install DESTDIR=../_install && \
-       make -f../$(distdir)/Makefile srcdir=../$(distdir) dist
+       ../$(distdir)/configure && \
+       make && \
+       make install DESTDIR=../_install && \
+       make dist
        rm -rf _distcheck
 
 ###----- That's all, folks --------------------------------------------------
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..635c9c0
--- /dev/null
+++ b/configure
@@ -0,0 +1,81 @@
+#! /bin/sh -e
+###
+### Cheesy configuration script.
+###
+### (c) 2018 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the preload-hacks package.
+###
+### Preload-hacks are free software; you can redistribute it and/or modify
+### them under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or (at
+### your option) any later version.
+###
+### Preload-hacks are distributed in the hope that it will be useful, but
+### WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+### Public License for more details.
+###
+### You should have received a copy of the GNU General Public License along
+### with preload-hacks; if not, write to the Free Software Foundation, Inc.,
+### 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+## Check for a `help' option.
+case $1,$# in
+  ,0) ;;
+  -h,* | --help,*)
+    echo "usage: $0 [--VAR=VAL ...] -- [VAR=VAL ...]"
+    exit 0
+    ;;
+esac
+
+## Find a relative path to the source directory.
+case $0 in */*) ;; *) echo >&2 "$0: invoke as PATH/configure"; exit 2 ;; esac
+srcdir=${0%/*}
+
+## Build the actual makefile.
+rm -f Makefile.new
+cat >Makefile.new <<EOF
+### -*-makefile-*-
+srcdir = $srcdir
+include \$(srcdir)/Make.rules
+EOF
+
+## Build a configuration fragment.
+rm -f config.mk.new
+exec 3>config.mk.new
+cat >&3 <<EOF
+### -*-makefile-*-
+
+## Settings from \`configure'.
+EOF
+
+## Parse the options.
+while :; do
+  case $1,$# in
+    ,0) break ;;
+    --,*) shift; break ;;
+    --*=*) o=${1#--}; k=${o%%=*} v=${o#*=}; echo >&3 "$k = $v" ;;
+    --*,*) k=${1#--}; echo >&3 "$k = t" ;;
+    *) break ;;
+  esac
+  shift
+done
+
+## Parse any remaining assignments.
+while :; do
+  case $1,$# in
+    ,0) break ;;
+    *=*) k=${1%%=*} v=${1#*=}; echo >&3 "$k = $v" ;;
+    *) echo >&2 "$0: unexpected argument $1"; exit 2 ;;
+  esac
+  shift
+done
+
+## All over.
+exec 3>&-
+mv config.mk.new config.mk
+mv Makefile.new Makefile
index 327f87d..c4af182 100644 (file)
@@ -1,4 +1,5 @@
 files
+build
 tmp
 substvars
 *.substvars
index 81d3e4b..22e825d 100755 (executable)
@@ -1,11 +1,9 @@
 #! /usr/bin/make -f
 
-arch = $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH)
+DH_OPTIONS              = --parallel -Bdebian/build
 
-%:; dh $@ --parallel
+%:; dh $@ $(DH_OPTIONS)
 
-override_dh_auto_install:
-       dh_auto_install --parallel -- \
-               prefix=/usr mandir=/usr/share/man \
-               libdir=/usr/lib/$(arch) \
-               DESTDIR=debian/tmp
+override_dh_auto_configure:
+       dh_auto_configure $(DH_OPTIONS) -- \
+               $(shell dpkg-buildflags --export=cmdline)