3 ### Makefile for preload-hacks
5 ### (c) 2008 Straylight/Edgeware
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of the preload-hacks package.
12 ### Preload-hacks are free software; you can redistribute it and/or modify
13 ### them under the terms of the GNU General Public License as published by
14 ### the Free Software Foundation; either version 2 of the License, or (at
15 ### your option) any later version.
17 ### Preload-hacks are distributed in the hope that it will be useful, but
18 ### WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
20 ### Public License for more details.
22 ### You should have received a copy of the GNU General Public License along
23 ### with preload-hacks; if not, write to the Free Software Foundation, Inc.,
24 ### 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 PACKAGE = preload-hacks
27 VERSION := $(shell ./auto-version)
29 .SECONDEXPANSION: #sorry
31 ###--------------------------------------------------------------------------
34 ## Where to install things.
36 exec_prefix = ${prefix}
37 bindir = ${exec_prefix}/bin
38 libdir = ${exec_prefix}/lib
39 datadir = ${prefix}/share
40 mandir = ${datadir}/man
41 man1dir = ${mandir}/man1
43 ## Private installation tree for packagers.
46 ###--------------------------------------------------------------------------
49 ## Mess with these if you like.
56 INST_BIN = $(INSTALL) -c -m755
57 INST_LIB = $(INSTALL) -c -m644
58 INST_MAN = $(INSTALL) -c -m644
59 INST_BIN = $(INSTALL) -c -m755
60 MKDIRS = $(INSTALL) -d -m755
62 ## Probably best if you leave these alone.
63 REAL_CFLAGS = $(CFLAGS) -fPIC -MD
64 REAL_LDFLAGS = $(LDFLAGS) -shared
66 ###--------------------------------------------------------------------------
71 v_tag = $(call v_tag_$V,$1)
72 v_tag_0 = @printf " %-8s %s\n" "$1" "$@";
76 ###--------------------------------------------------------------------------
85 uopen_SOURCES = uopen.c
88 ALL_SOURCES = $(foreach h,$(HACKS),$($h_SOURCES))
89 DISTFILES += $(ALL_SOURCES)
92 LIBS += $(addsuffix .so, $(HACKS))
98 DISTFILES += withlib.in
101 MAN1 += $(addsuffix .1, $(HACKS))
104 ###--------------------------------------------------------------------------
105 ### Distribution arrangements.
108 distdir = $(PACKAGE)-$(VERSION)
109 DISTTAR = $(distdir).tar.gz
111 ## Distribute the build utilities.
112 DISTFILES += Makefile
113 DISTFILES += auto-version
123 DISTFILES += debian/changelog debian/copyright
124 DISTFILES += debian/control debian/rules debian/compat
125 DISTFILES += debian/source/format
126 DISTFILES += $(patsubst %, debian/%.install, $(debpkg))
127 DISTFILES += $(patsubst %, debian/%.lintian-overrides, \
130 ###--------------------------------------------------------------------------
144 $(call v_tag,CC)$(CC) -c $(REAL_CFLAGS) $< -o $@
146 ## Constructing preload hacks.
147 $(addsuffix .so,$(HACKS)): %.so: $$(patsubst %.c,%.o,$$($$*_SOURCES))
148 $(call v_tag,LD)$(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
150 ## Constructing the scripts.
151 $(SCRIPTS): %: withlib.in
152 $(call v_tag,GEN)sed "s/@lib@/$@/" withlib.in >$@.new && \
153 chmod +x $@.new && mv $@.new $@
155 -include $(patsubst %.c,%d,$(ALL_SOURCES))
157 ###--------------------------------------------------------------------------
161 $(MKDIRS) $(DESTDIR)$(bindir)
162 $(INST_BIN) $(SCRIPTS) $(DESTDIR)$(bindir)
163 $(MKDIRS) $(DESTDIR)$(libdir)
164 $(INST_BIN) $(LIBS) $(DESTDIR)$(libdir)
165 $(MKDIRS) $(DESTDIR)$(man1dir)
166 $(INST_MAN) $(MAN1) $(DESTDIR)$(man1dir)
170 rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIBS))
171 rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
172 rm -f $(addprefix $(DESTDIR)$(man1dir)/, $(MAN1))
175 ###--------------------------------------------------------------------------
181 echo $(VERSION) >$(distdir)/RELEASE
182 for i in $(DISTFILES); do \
185 d=$${i%/*} && $(MKDIRS) $(distdir)/$$d || exit 1 \
188 ln $$i $(distdir)/$$i || exit 1; \
193 tar chozf $(DISTTAR) $(distdir)
201 tar xvfz ../$(DISTTAR) && \
204 make install DESTDIR=../_install && \
208 ###----- That's all, folks --------------------------------------------------