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