chiark / gitweb /
Makefile (distcheck): Propagate jobserver parameters to the test build.
[preload-hacks] / Makefile
1 ### -*-makefile-*-
2 ###
3 ### Makefile for preload-hacks
4 ###
5 ### (c) 2008 Straylight/Edgeware
6 ###
7
8 ###----- Licensing notice ---------------------------------------------------
9 ###
10 ### This file is part of the preload-hacks package.
11 ###
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.
16 ###
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.
21 ###
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.
25
26 PACKAGE                  = preload-hacks
27 VERSION                 := $(shell ./auto-version)
28
29 .SECONDEXPANSION: #sorry
30
31 ###--------------------------------------------------------------------------
32 ### Configuration.
33
34 ## Where to install things.
35 prefix                   = /usr/local
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
42
43 ## Private installation tree for packagers.
44 DESTDIR                  =
45
46 ###--------------------------------------------------------------------------
47 ### Build parameters.
48
49 ## Mess with these if you like.
50 CC                       = gcc
51 LD                       = gcc
52 CFLAGS                   = -O2 -g -Wall
53 LDFLAGS                  =
54 LDLIBS                   = -ldl
55 INSTALL                  = install
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
61
62 ## Probably best if you leave these alone.
63 REAL_CFLAGS              = $(CFLAGS) -fPIC -MD
64 REAL_LDFLAGS             = $(LDFLAGS) -shared
65
66 ###--------------------------------------------------------------------------
67 ### Quiet building.
68
69 ## Verbosity.
70 V                        = 0
71 v_tag                    = $(call v_tag_$V,$1)
72 v_tag_0                  = @printf "  %-8s %s\n" "$1" "$@";
73 V_AT                     = $(V_AT_$V)
74 V_AT_0                   = @
75
76 ###--------------------------------------------------------------------------
77 ### Main targets.
78
79 ## noip
80 HACKS                   += noip
81 noip_SOURCES             = noip.c
82
83 ## uopen
84 HACKS                   += uopen
85 uopen_SOURCES            = uopen.c
86
87 ## Sources.
88 ALL_SOURCES              = $(foreach h,$(HACKS),$($h_SOURCES))
89 DISTFILES               += $(ALL_SOURCES)
90
91 ## Libraries.
92 LIBS                    += $(addsuffix .so, $(HACKS))
93 TARGETS                 += $(LIBS)
94
95 ## Scripts.
96 SCRIPTS                  = $(HACKS)
97 TARGETS                 += $(SCRIPTS)
98 DISTFILES               += withlib.in
99
100 ## Manual pages.
101 MAN1                    += $(addsuffix .1, $(HACKS))
102 DISTFILES               += $(MAN1)
103
104 ###--------------------------------------------------------------------------
105 ### Distribution arrangements.
106
107 ## Names.
108 distdir                  = $(PACKAGE)-$(VERSION)
109 DISTTAR                  = $(distdir).tar.gz
110
111 ## Distribute the build utilities.
112 DISTFILES               += Makefile
113 DISTFILES               += auto-version
114
115 ## Documentation.
116 DISTFILES               += README
117
118 ## Licensing.
119 DISTFILES               += COPYING
120
121 ## Debian.
122 debpkg                   = noip uopen
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, \
128                                 $(debpkg))
129
130 ###--------------------------------------------------------------------------
131 ### Building.
132
133 all:: $(TARGETS)
134 .PHONY: ALL
135
136 CLEAN                   += $(TARGETS)
137 CLEAN                   += *.o *.d
138 clean::
139         rm -f $(CLEAN)
140 .PHONY: clean
141
142 ## Building sources.
143 %.o: %.c
144         $(call v_tag,CC)$(CC) -c $(REAL_CFLAGS) $< -o $@
145
146 ## Constructing preload hacks.
147 $(addsuffix .so,$(HACKS)): %.so: $$(patsubst %.c,%.o,$$($$*_SOURCES))
148         $(call v_tag,LD)$(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
149
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 $@
154
155 -include $(patsubst %.c,%d,$(ALL_SOURCES))
156
157 ###--------------------------------------------------------------------------
158 ### Installation.
159
160 install: all
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)
167 .PHONY: install
168
169 uninstall:
170         rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIBS))
171         rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
172         rm -f $(addprefix $(DESTDIR)$(man1dir)/, $(MAN1))
173 .PHONY: uninstall
174
175 ###--------------------------------------------------------------------------
176 ### Distribution.
177
178 distdir:
179         rm -rf $(distdir)
180         mkdir $(distdir)
181         echo $(VERSION) >$(distdir)/RELEASE
182         for i in $(DISTFILES); do \
183           case "$$i" in \
184             */*) \
185               d=$${i%/*} && $(MKDIRS) $(distdir)/$$d || exit 1 \
186               ;; \
187           esac; \
188           cp $$i $(distdir)/$$i || exit 1; \
189         done
190 .PHONY: distdir
191
192 dist: distdir
193         tar chozf $(DISTTAR) $(distdir)
194         rm -rf $(distdir)
195 .PHONY: dist
196
197 distcheck: dist
198         rm -rf _distcheck
199         mkdir _distcheck
200         +cd _distcheck && \
201         tar xvfz ../$(DISTTAR) && \
202         cd $(distdir) && \
203         make && \
204         make install DESTDIR=../_install && \
205         make dist
206         rm -rf _distcheck
207
208 ###----- That's all, folks --------------------------------------------------