From bfa7456484b46f5c52a88c10c72a866b072faaf4 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Mon, 22 Dec 2008 01:23:10 +0000 Subject: [PATCH] Makefile: Spruce up considerably. Organization: Straylight/Edgeware From: Mark Wooding It's now more maintainable, and much easier to read. --- Makefile | 221 ++++++++++++++++++++++++++++++++++++++----------- debian/control | 2 +- 2 files changed, 175 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index c8424a3..b3360da 100644 --- a/Makefile +++ b/Makefile @@ -1,67 +1,194 @@ -PACKAGE = preload-hacks -VERSION := $(shell ./auto-version) - -prefix = /usr/local -exec_prefix = ${prefix} -bindir = ${exec_prefix}/bin -libdir = ${exec_prefix}/lib -mandir = ${prefix}/man -man1dir = ${mandir}/man1 - -CC = gcc -LD = gcc -CFLAGS = -O2 -g -Wall -LDFLAGS = -REAL_CFLAGS = $(CFLAGS) -fPIC -REAL_LDFLAGS = $(LDFLAGS) -shared -LDLIBS = -ldl -INST_BIN = install -c -m755 -INST_LIB = install -c -m644 -INST_MAN = install -c -m644 -INST_BIN = install -c -m755 -MKDIRS = install -d -m755 -DESTDIR = - -LIBS = noip.so uopen.so -MAN1 = $(patsubst %.so, %.1, $(LIBS)) -SCRIPTS = $(patsubst %.so, %, $(LIBS)) -TARGETS = $(LIBS) $(SCRIPTS) -SOURCES = noip.c uopen.c withlib.in +### -*-makefile-*- +### +### Makefile for preload-hacks +### +### (c) 2008 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 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 mLib; if not, write to the Free Software Foundation, Inc., 59 Temple +### Place - Suite 330, Boston, MA 02111-1307, USA. + +PACKAGE = preload-hacks +VERSION := $(shell ./auto-version) + +###-------------------------------------------------------------------------- +### Configuration. + +## Where to install things. +prefix = /usr/local +exec_prefix = ${prefix} +bindir = ${exec_prefix}/bin +libdir = ${exec_prefix}/lib +datadir = ${prefix}/share +mandir = ${datadir}/man +man1dir = ${mandir}/man1 + +## Private installation tree for packagers. +DESTDIR = + +###-------------------------------------------------------------------------- +### Build parameters. + +## Mess with these if you like. +CC = gcc +LD = gcc +CFLAGS = -O2 -g -Wall +LDFLAGS = +LDLIBS = -ldl +INSTALL = install +INST_BIN = $(INSTALL) -c -m755 +INST_LIB = $(INSTALL) -c -m644 +INST_MAN = $(INSTALL) -c -m644 +INST_BIN = $(INSTALL) -c -m755 +MKDIRS = $(INSTALL) -d -m755 + +## Probably best if you leave these alone. +REAL_CFLAGS = $(CFLAGS) -fPIC +REAL_LDFLAGS = $(LDFLAGS) -shared + +###-------------------------------------------------------------------------- +### Main targets. + +## noip +HACKS += noip +NOIP_SOURCES = noip.c +DISTFILES += $(NOIP_SOURCES) + +## uopen +HACKS += uopen +UOPEN_SOURCES = uopen.c +DISTFILES += $(UOPEN_SOURCES) + +## Libraries. +LIBS += $(addsuffix .so, $(HACKS)) +TARGETS += $(LIBS) + +## Scripts. +SCRIPTS = $(HACKS) +TARGETS += $(SCRIPTS) +DISTFILES += withlib.in + +## Manual pages. +MAN1 += $(addsuffix .1, $(HACKS)) +DISTFILES += $(MAN1) + +###-------------------------------------------------------------------------- +### Distribution arrangements. + +## Names. +distdir = $(PACKAGE)-$(VERSION) +DISTTAR = $(distdir).tar.gz + +## Distribute the build utilities. +DISTFILES += Makefile +DISTFILES += auto-version + +## Documentation. +DISTFILES += README + +## Licensing. +DISTFILES += COPYING + +## Debian. +debpkg = noip uopen +DISTFILES += debian/changelog debian/copyright +DISTFILES += debian/control debian/rules +DISTFILES += $(patsubst %, debian/%.install, $(debpkg)) +DISTFILES += $(patsubst %, debian/%.lintian-overrides, \ + $(debpkg)) + +###-------------------------------------------------------------------------- +### Building. + all: $(TARGETS) +.PHONY: ALL + +clean: + rm -f *.o $(TARGETS) +.PHONY: clean + +## Building sources. %.o: %.c $(CC) -c $(REAL_CFLAGS) $< -o $@ -noip.so: $(patsubst %.c, %.o, noip.c) + +## Constructing preload hacks. +noip.so: $(patsubst %.c, %.o, $(NOIP_SOURCES)) $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@ -uopen.so: $(patsubst %.c, %.o, uopen.c) +uopen.so: $(patsubst %.c, %.o, $(UOPEN_SOURCES)) $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@ + +## Constructing the scripts. $(SCRIPTS): withlib.in for i in $(SCRIPTS); do \ sed "s/@lib@/$$i/" withlib.in >$$i.new || exit 1; \ chmod +x $$i.new || exit 1; \ mv $$i.new $$i || exit 1; \ done + +###-------------------------------------------------------------------------- +### Installation. + install: all - $(MKDIRS) $(addprefix $(DESTDIR), \ - $(bindir) $(libdir) $(bindir) $(man1dir)) - $(INST_LIB) $(LIBS) $(DESTDIR)$(libdir) + $(MKDIRS) $(DESTDIR)$(bindir) $(INST_BIN) $(SCRIPTS) $(DESTDIR)$(bindir) + $(MKDIRS) $(DESTDIR)$(libdir) + $(INST_BIN) $(LIBS) $(DESTDIR)$(libdir) + $(MKDIRS) $(DESTDIR)$(man1dir) $(INST_MAN) $(MAN1) $(DESTDIR)$(man1dir) +.PHONY: install + uninstall: rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIBS)) rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS)) rm -f $(addprefix $(DESTDIR)$(man1dir)/, $(MAN1)) -DISTDIR = $(PACKAGE)-$(VERSION) -DISTTAR = $(DISTDIR).tar.gz +.PHONY: uninstall + +###-------------------------------------------------------------------------- +### Distribution. + distdir: - rm -rf $(DISTDIR) - mkdir $(DISTDIR) - ln $(SOURCES) $(MAN1) Makefile COPYING README auto-version $(DISTDIR) - echo $(VERSION) >$(DISTDIR)/RELEASE - mkdir $(DISTDIR)/debian - ln debian/rules debian/copyright debian/changelog debian/control \ - debian/*.install $(DISTDIR)/debian + rm -rf $(distdir) + mkdir $(distdir) + echo $(VERSION) >$(distdir)/RELEASE + for i in $(DISTFILES); do \ + case "$$i" in \ + */*) \ + d=$${i%/*} && $(MKDIRS) $(distdir)/$$d || exit 1 \ + ;; \ + esac; \ + ln $$i $(distdir)/$$i || exit 1; \ + done +.PHONY: distdir + dist: distdir - tar chozf $(DISTTAR) $(DISTDIR) - rm -rf $(DISTDIR) -clean: - rm -f *.o $(OBJECTS) $(TARGETS) + tar chozf $(DISTTAR) $(distdir) + rm -rf $(distdir) +.PHONY: dist + +distcheck: dist + rm -rf _distcheck + mkdir _distcheck + cd _distcheck && \ + tar xvfz ../$(DISTTAR) && \ + cd $(distdir) && \ + make && \ + make install DESTDIR=../_install && \ + make dist + rm -rf _distcheck + +###----- That's all, folks -------------------------------------------------- diff --git a/debian/control b/debian/control index b8c3e15..adedc67 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: preload-hacks Section: utils Priority: extra Maintainer: Mark Wooding -Standards-Version: 3.1.1 +Standards-Version: 3.8.0 Package: uopen Architecture: any -- [mdw]