chiark / gitweb /
noip.c: Add debugging to most of the syscall wrappers.
[preload-hacks] / Makefile
index f69375a66ad6f0c145bb7cd3169cd1979addc16d..5cd11441aca588f13e75fd1a0984e83eebe970a4 100644 (file)
--- a/Makefile
+++ b/Makefile
-PACKAGE = preload-hacks
-VERSION = 1.0.1
-
-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 -fPIC -Wall
-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 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)
+.PHONY: ALL
+
+clean:
+       rm -f *.o $(TARGETS)
+.PHONY: clean
+
+## Building sources.
 %.o: %.c
-       $(CC) -c $(CFLAGS) $< -o $@
-noip.so: $(patsubst %.c, %.o, noip.c)
-       $(LD) $(LDFLAGS) $< $(LDLIBS) -o $@
-uopen.so: $(patsubst %.c, %.o, uopen.c)
-       $(LD) $(LDFLAGS) $< $(LDLIBS) -o $@
-$(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
+       $(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) $(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 $(DISTDIR)
-       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 --------------------------------------------------