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 | 25 | |
ba98b375 | 26 | srcdir = . |
bfa74564 | 27 | PACKAGE = preload-hacks |
ba98b375 | 28 | VERSION := $(shell cd $(srcdir) && ./auto-version) |
bfa74564 | 29 | |
ba98b375 | 30 | VPATH = $(srcdir) |
bc432a48 MW |
31 | .SECONDEXPANSION: #sorry |
32 | ||
bfa74564 MW |
33 | ###-------------------------------------------------------------------------- |
34 | ### Configuration. | |
35 | ||
36 | ## Where to install things. | |
37 | prefix = /usr/local | |
38 | exec_prefix = ${prefix} | |
39 | bindir = ${exec_prefix}/bin | |
40 | libdir = ${exec_prefix}/lib | |
41 | datadir = ${prefix}/share | |
42 | mandir = ${datadir}/man | |
43 | man1dir = ${mandir}/man1 | |
44 | ||
45 | ## Private installation tree for packagers. | |
46 | DESTDIR = | |
47 | ||
48 | ###-------------------------------------------------------------------------- | |
49 | ### Build parameters. | |
50 | ||
51 | ## Mess with these if you like. | |
52 | CC = gcc | |
53 | LD = gcc | |
54 | CFLAGS = -O2 -g -Wall | |
55 | LDFLAGS = | |
56 | LDLIBS = -ldl | |
57 | INSTALL = install | |
58 | INST_BIN = $(INSTALL) -c -m755 | |
59 | INST_LIB = $(INSTALL) -c -m644 | |
60 | INST_MAN = $(INSTALL) -c -m644 | |
61 | INST_BIN = $(INSTALL) -c -m755 | |
62 | MKDIRS = $(INSTALL) -d -m755 | |
63 | ||
64 | ## Probably best if you leave these alone. | |
da261a68 | 65 | REAL_CFLAGS = $(CFLAGS) -fPIC -MD |
bfa74564 MW |
66 | REAL_LDFLAGS = $(LDFLAGS) -shared |
67 | ||
ba98b375 MW |
68 | ## Allow user overrides for this stuff. |
69 | -include config.mk | |
70 | ||
bfa74564 | 71 | ###-------------------------------------------------------------------------- |
9555bb4b MW |
72 | ### Quiet building. |
73 | ||
74 | ## Verbosity. | |
75 | V = 0 | |
76 | v_tag = $(call v_tag_$V,$1) | |
77 | v_tag_0 = @printf " %-8s %s\n" "$1" "$@"; | |
78 | V_AT = $(V_AT_$V) | |
79 | V_AT_0 = @ | |
80 | ||
81 | ###-------------------------------------------------------------------------- | |
bfa74564 MW |
82 | ### Main targets. |
83 | ||
84 | ## noip | |
85 | HACKS += noip | |
bc432a48 | 86 | noip_SOURCES = noip.c |
bfa74564 MW |
87 | |
88 | ## uopen | |
89 | HACKS += uopen | |
bc432a48 MW |
90 | uopen_SOURCES = uopen.c |
91 | ||
92 | ## Sources. | |
93 | ALL_SOURCES = $(foreach h,$(HACKS),$($h_SOURCES)) | |
94 | DISTFILES += $(ALL_SOURCES) | |
bfa74564 MW |
95 | |
96 | ## Libraries. | |
97 | LIBS += $(addsuffix .so, $(HACKS)) | |
98 | TARGETS += $(LIBS) | |
99 | ||
100 | ## Scripts. | |
101 | SCRIPTS = $(HACKS) | |
102 | TARGETS += $(SCRIPTS) | |
103 | DISTFILES += withlib.in | |
104 | ||
105 | ## Manual pages. | |
106 | MAN1 += $(addsuffix .1, $(HACKS)) | |
107 | DISTFILES += $(MAN1) | |
108 | ||
109 | ###-------------------------------------------------------------------------- | |
110 | ### Distribution arrangements. | |
111 | ||
112 | ## Names. | |
113 | distdir = $(PACKAGE)-$(VERSION) | |
114 | DISTTAR = $(distdir).tar.gz | |
115 | ||
116 | ## Distribute the build utilities. | |
117 | DISTFILES += Makefile | |
118 | DISTFILES += auto-version | |
119 | ||
120 | ## Documentation. | |
121 | DISTFILES += README | |
122 | ||
123 | ## Licensing. | |
124 | DISTFILES += COPYING | |
125 | ||
126 | ## Debian. | |
127 | debpkg = noip uopen | |
128 | DISTFILES += debian/changelog debian/copyright | |
c2ca886a | 129 | DISTFILES += debian/control debian/rules debian/compat |
fd87e398 | 130 | DISTFILES += debian/source/format |
bfa74564 MW |
131 | DISTFILES += $(patsubst %, debian/%.install, $(debpkg)) |
132 | DISTFILES += $(patsubst %, debian/%.lintian-overrides, \ | |
133 | $(debpkg)) | |
134 | ||
135 | ###-------------------------------------------------------------------------- | |
136 | ### Building. | |
137 | ||
6e66bf29 | 138 | all:: $(TARGETS) |
bfa74564 MW |
139 | .PHONY: ALL |
140 | ||
c71a0b56 | 141 | CLEAN += $(TARGETS) |
da261a68 | 142 | CLEAN += *.o *.d |
6e66bf29 | 143 | clean:: |
c71a0b56 | 144 | rm -f $(CLEAN) |
bfa74564 MW |
145 | .PHONY: clean |
146 | ||
147 | ## Building sources. | |
e4976bb0 | 148 | %.o: %.c |
3c098848 | 149 | $(call v_tag,CC)$(CC) -c $(REAL_CFLAGS) $< -o $@ |
bfa74564 MW |
150 | |
151 | ## Constructing preload hacks. | |
bc432a48 | 152 | $(addsuffix .so,$(HACKS)): %.so: $$(patsubst %.c,%.o,$$($$*_SOURCES)) |
3c098848 | 153 | $(call v_tag,LD)$(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@ |
bfa74564 MW |
154 | |
155 | ## Constructing the scripts. | |
7a863a39 | 156 | $(SCRIPTS): %: withlib.in |
ba98b375 | 157 | $(call v_tag,GEN)sed "s/@lib@/$@/" $(srcdir)/withlib.in >$@.new && \ |
7a863a39 | 158 | chmod +x $@.new && mv $@.new $@ |
bfa74564 | 159 | |
da261a68 MW |
160 | -include $(patsubst %.c,%d,$(ALL_SOURCES)) |
161 | ||
bfa74564 MW |
162 | ###-------------------------------------------------------------------------- |
163 | ### Installation. | |
164 | ||
2906706d | 165 | install: all |
bfa74564 | 166 | $(MKDIRS) $(DESTDIR)$(bindir) |
2906706d | 167 | $(INST_BIN) $(SCRIPTS) $(DESTDIR)$(bindir) |
bfa74564 MW |
168 | $(MKDIRS) $(DESTDIR)$(libdir) |
169 | $(INST_BIN) $(LIBS) $(DESTDIR)$(libdir) | |
170 | $(MKDIRS) $(DESTDIR)$(man1dir) | |
ba98b375 | 171 | $(INST_MAN) $(addprefix $(srcdir)/,$(MAN1)) $(DESTDIR)$(man1dir) |
bfa74564 MW |
172 | .PHONY: install |
173 | ||
2906706d | 174 | uninstall: |
175 | rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIBS)) | |
176 | rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS)) | |
177 | rm -f $(addprefix $(DESTDIR)$(man1dir)/, $(MAN1)) | |
bfa74564 MW |
178 | .PHONY: uninstall |
179 | ||
180 | ###-------------------------------------------------------------------------- | |
181 | ### Distribution. | |
182 | ||
2906706d | 183 | distdir: |
bfa74564 MW |
184 | rm -rf $(distdir) |
185 | mkdir $(distdir) | |
186 | echo $(VERSION) >$(distdir)/RELEASE | |
187 | for i in $(DISTFILES); do \ | |
188 | case "$$i" in \ | |
189 | */*) \ | |
190 | d=$${i%/*} && $(MKDIRS) $(distdir)/$$d || exit 1 \ | |
191 | ;; \ | |
192 | esac; \ | |
ba98b375 | 193 | cp $(srcdir)/$$i $(distdir)/$$i || exit 1; \ |
bfa74564 MW |
194 | done |
195 | .PHONY: distdir | |
196 | ||
2906706d | 197 | dist: distdir |
bfa74564 MW |
198 | tar chozf $(DISTTAR) $(distdir) |
199 | rm -rf $(distdir) | |
200 | .PHONY: dist | |
201 | ||
202 | distcheck: dist | |
203 | rm -rf _distcheck | |
204 | mkdir _distcheck | |
12545e3d | 205 | +cd _distcheck && \ |
bfa74564 | 206 | tar xvfz ../$(DISTTAR) && \ |
ba98b375 MW |
207 | mkdir _build && cd _build && \ |
208 | make -f../$(distdir)/Makefile srcdir=../$(distdir) && \ | |
209 | make -f../$(distdir)/Makefile srcdir=../$(distdir) \ | |
210 | install DESTDIR=../_install && \ | |
211 | make -f../$(distdir)/Makefile srcdir=../$(distdir) dist | |
bfa74564 MW |
212 | rm -rf _distcheck |
213 | ||
214 | ###----- That's all, folks -------------------------------------------------- |