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