### -*-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. srcdir ?= . PACKAGE = preload-hacks VERSION := $(shell cd $(srcdir) && ./auto-version) VPATH = $(srcdir) .SECONDEXPANSION: #sorry ###-------------------------------------------------------------------------- ### 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 -MD REAL_LDFLAGS = $(LDFLAGS) -shared ## Allow user overrides for this stuff. -include config.mk ###-------------------------------------------------------------------------- ### Quiet building. ## Verbosity. V = 0 v_tag = $(call v_tag_$V,$1) v_tag_0 = @printf " %-8s %s\n" "$1" "$@"; V_AT = $(V_AT_$V) V_AT_0 = @ ###-------------------------------------------------------------------------- ### Main targets. ## noip HACKS += noip noip_SOURCES = noip.c ## uopen HACKS += uopen uopen_SOURCES = uopen.c ## Sources. ALL_SOURCES = $(foreach h,$(HACKS),$($h_SOURCES)) DISTFILES += $(ALL_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 += Make.rules DISTFILES += configure 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 += $(TARGETS) CLEAN += *.o *.d clean:: rm -f $(CLEAN) .PHONY: clean ## Building sources. %.o: %.c $(call v_tag,CC)$(CC) -c $(REAL_CFLAGS) $< -o $@ ## Constructing preload hacks. $(addsuffix .so,$(HACKS)): %.so: $$(patsubst %.c,%.o,$$($$*_SOURCES)) $(call v_tag,LD)$(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@ ## Constructing the scripts. $(SCRIPTS): %: withlib.in $(call v_tag,GEN)sed "s/@lib@/$@/" $(srcdir)/withlib.in >$@.new && \ chmod +x $@.new && mv $@.new $@ -include $(patsubst %.c,%d,$(ALL_SOURCES)) ###-------------------------------------------------------------------------- ### Installation. install: all $(MKDIRS) $(DESTDIR)$(bindir) $(INST_BIN) $(SCRIPTS) $(DESTDIR)$(bindir) $(MKDIRS) $(DESTDIR)$(libdir) $(INST_BIN) $(LIBS) $(DESTDIR)$(libdir) $(MKDIRS) $(DESTDIR)$(man1dir) $(INST_MAN) $(addprefix $(srcdir)/,$(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; \ cp $(srcdir)/$$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) && \ mkdir _build && cd _build && \ ../$(distdir)/configure && \ make && \ make install DESTDIR=../_install && \ make dist rm -rf _distcheck ###----- That's all, folks --------------------------------------------------