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