Commit | Line | Data |
---|---|---|
bfa74564 MW |
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 | ### | |
de6df72d MW |
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. | |
bfa74564 MW |
21 | ### |
22 | ### You should have received a copy of the GNU General Public License along | |
de6df72d MW |
23 | ### with preload-hacks; if not, write to the Free Software Foundation, Inc., |
24 | ### 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
bfa74564 MW |
25 | |
26 | PACKAGE = preload-hacks | |
27 | VERSION := $(shell ./auto-version) | |
28 | ||
bc432a48 MW |
29 | .SECONDEXPANSION: #sorry |
30 | ||
bfa74564 MW |
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 | ||
7a863a39 MW |
46 | ###-------------------------------------------------------------------------- |
47 | ### Quiet building. | |
48 | ||
49 | ## Verbosity. | |
3c098848 MW |
50 | V ?= 0 |
51 | v_tag = $(call v_tag_$V,$1) | |
52 | v_tag_0 = @printf " %-8s %s\n" "$1" "$@"; | |
53 | V_AT = $(V_AT_$V) | |
54 | V_AT_0 = @ | |
7a863a39 | 55 | |
bfa74564 MW |
56 | ###-------------------------------------------------------------------------- |
57 | ### Build parameters. | |
58 | ||
59 | ## Mess with these if you like. | |
60 | CC = gcc | |
61 | LD = gcc | |
62 | CFLAGS = -O2 -g -Wall | |
63 | LDFLAGS = | |
64 | LDLIBS = -ldl | |
65 | INSTALL = install | |
66 | INST_BIN = $(INSTALL) -c -m755 | |
67 | INST_LIB = $(INSTALL) -c -m644 | |
68 | INST_MAN = $(INSTALL) -c -m644 | |
69 | INST_BIN = $(INSTALL) -c -m755 | |
70 | MKDIRS = $(INSTALL) -d -m755 | |
71 | ||
72 | ## Probably best if you leave these alone. | |
da261a68 | 73 | REAL_CFLAGS = $(CFLAGS) -fPIC -MD |
bfa74564 MW |
74 | REAL_LDFLAGS = $(LDFLAGS) -shared |
75 | ||
76 | ###-------------------------------------------------------------------------- | |
77 | ### Main targets. | |
78 | ||
79 | ## noip | |
80 | HACKS += noip | |
bc432a48 | 81 | noip_SOURCES = noip.c |
bfa74564 MW |
82 | |
83 | ## uopen | |
84 | HACKS += uopen | |
bc432a48 MW |
85 | uopen_SOURCES = uopen.c |
86 | ||
87 | ## Sources. | |
88 | ALL_SOURCES = $(foreach h,$(HACKS),$($h_SOURCES)) | |
89 | DISTFILES += $(ALL_SOURCES) | |
bfa74564 MW |
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 | |
c2ca886a | 124 | DISTFILES += debian/control debian/rules debian/compat |
fd87e398 | 125 | DISTFILES += debian/source/format |
bfa74564 MW |
126 | DISTFILES += $(patsubst %, debian/%.install, $(debpkg)) |
127 | DISTFILES += $(patsubst %, debian/%.lintian-overrides, \ | |
128 | $(debpkg)) | |
129 | ||
130 | ###-------------------------------------------------------------------------- | |
131 | ### Building. | |
132 | ||
6e66bf29 | 133 | all:: $(TARGETS) |
bfa74564 MW |
134 | .PHONY: ALL |
135 | ||
c71a0b56 | 136 | CLEAN += $(TARGETS) |
da261a68 | 137 | CLEAN += *.o *.d |
6e66bf29 | 138 | clean:: |
c71a0b56 | 139 | rm -f $(CLEAN) |
bfa74564 MW |
140 | .PHONY: clean |
141 | ||
142 | ## Building sources. | |
e4976bb0 | 143 | %.o: %.c |
3c098848 | 144 | $(call v_tag,CC)$(CC) -c $(REAL_CFLAGS) $< -o $@ |
bfa74564 MW |
145 | |
146 | ## Constructing preload hacks. | |
bc432a48 | 147 | $(addsuffix .so,$(HACKS)): %.so: $$(patsubst %.c,%.o,$$($$*_SOURCES)) |
3c098848 | 148 | $(call v_tag,LD)$(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@ |
bfa74564 MW |
149 | |
150 | ## Constructing the scripts. | |
7a863a39 | 151 | $(SCRIPTS): %: withlib.in |
3c098848 | 152 | $(call v_tag,GEN)sed "s/@lib@/$@/" withlib.in >$@.new && \ |
7a863a39 | 153 | chmod +x $@.new && mv $@.new $@ |
bfa74564 | 154 | |
da261a68 MW |
155 | -include $(patsubst %.c,%d,$(ALL_SOURCES)) |
156 | ||
bfa74564 MW |
157 | ###-------------------------------------------------------------------------- |
158 | ### Installation. | |
159 | ||
2906706d | 160 | install: all |
bfa74564 | 161 | $(MKDIRS) $(DESTDIR)$(bindir) |
2906706d | 162 | $(INST_BIN) $(SCRIPTS) $(DESTDIR)$(bindir) |
bfa74564 MW |
163 | $(MKDIRS) $(DESTDIR)$(libdir) |
164 | $(INST_BIN) $(LIBS) $(DESTDIR)$(libdir) | |
165 | $(MKDIRS) $(DESTDIR)$(man1dir) | |
2906706d | 166 | $(INST_MAN) $(MAN1) $(DESTDIR)$(man1dir) |
bfa74564 MW |
167 | .PHONY: install |
168 | ||
2906706d | 169 | uninstall: |
170 | rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIBS)) | |
171 | rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS)) | |
172 | rm -f $(addprefix $(DESTDIR)$(man1dir)/, $(MAN1)) | |
bfa74564 MW |
173 | .PHONY: uninstall |
174 | ||
175 | ###-------------------------------------------------------------------------- | |
176 | ### Distribution. | |
177 | ||
2906706d | 178 | distdir: |
bfa74564 MW |
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 | ln $$i $(distdir)/$$i || exit 1; \ | |
189 | done | |
190 | .PHONY: distdir | |
191 | ||
2906706d | 192 | dist: distdir |
bfa74564 MW |
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 -------------------------------------------------- |