X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/preload-hacks/blobdiff_plain/e4976bb0731d14a7d8bfa53067ec1d99e94617cb..dc3956b3f2f9b13bbf93df2ed7295407cc90ab86:/Makefile diff --git a/Makefile b/Makefile index dcf4b74..5cd1144 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,210 @@ -CC = gcc -LD = gcc -CFLAGS = -O2 -g -fPIC -Wall -LDFLAGS = -shared -LIBS = -ldl - -SOURCES = noip.c uopen.c -TARGETS = noip.so uopen.so +### -*-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 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. + +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 = + +###-------------------------------------------------------------------------- +### Quiet building. + +## Verbosity. +V = 0 + +## Compilation. +V_CC = $(V_CC_$(V))$(CC) +V_CC_0 = @echo " CC $@"; + +## Linking. +V_LD = $(V_LD_$(V))$(LD) +V_LD_0 = @echo " LD $@"; + +## Generation. +V_GEN = $(V_GEN_$(V)) +V_GEN_0 = @echo " GEN $@"; + +###-------------------------------------------------------------------------- +### 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 debian/compat +DISTFILES += debian/source/format +DISTFILES += $(patsubst %, debian/%.install, $(debpkg)) +DISTFILES += $(patsubst %, debian/%.lintian-overrides, \ + $(debpkg)) + +###-------------------------------------------------------------------------- +### Building. + all: $(TARGETS) -%.o: %.c - $(CC) -c $(CFLAGS) $< -o $@ -noip.so: $(patsubst %.c, %.o, noip.c) - $(LD) $(LDFLAGS) $< $(LIBS) -o $@ -uopen.so: $(patsubst %.c, %.o, uopen.c) - $(LD) $(LDFLAGS) $< $(LIBS) -o $@ +.PHONY: ALL + clean: - rm -f $(OBJECTS) $(TARGETS) \ No newline at end of file + rm -f *.o $(TARGETS) +.PHONY: clean + +## Building sources. +%.o: %.c + $(V_CC) -c $(REAL_CFLAGS) $< -o $@ + +## Constructing preload hacks. +noip.so: $(patsubst %.c, %.o, $(NOIP_SOURCES)) + $(V_LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@ +uopen.so: $(patsubst %.c, %.o, $(UOPEN_SOURCES)) + $(V_LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@ + +## Constructing the scripts. +$(SCRIPTS): %: withlib.in + $(V_GEN)sed "s/@lib@/$@/" withlib.in >$@.new && \ + chmod +x $@.new && mv $@.new $@ + +###-------------------------------------------------------------------------- +### Installation. + +install: all + $(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)) +.PHONY: uninstall + +###-------------------------------------------------------------------------- +### Distribution. + +distdir: + 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) +.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 --------------------------------------------------