chiark / gitweb /
Merge branch 'master' of metalzone:public-git/preload-hacks
[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###
17### Preload-hacks distributed in the hope that it will be useful, but WITHOUT
18### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
20### more details.
21###
22### You should have received a copy of the GNU General Public License along
23### with mLib; if not, write to the Free Software Foundation, Inc., 59 Temple
24### Place - Suite 330, Boston, MA 02111-1307, USA.
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
44###--------------------------------------------------------------------------
45### Build parameters.
46
47## Mess with these if you like.
48CC = gcc
49LD = gcc
50CFLAGS = -O2 -g -Wall
51LDFLAGS =
52LDLIBS = -ldl
53INSTALL = install
54INST_BIN = $(INSTALL) -c -m755
55INST_LIB = $(INSTALL) -c -m644
56INST_MAN = $(INSTALL) -c -m644
57INST_BIN = $(INSTALL) -c -m755
58MKDIRS = $(INSTALL) -d -m755
59
60## Probably best if you leave these alone.
61REAL_CFLAGS = $(CFLAGS) -fPIC
62REAL_LDFLAGS = $(LDFLAGS) -shared
63
64###--------------------------------------------------------------------------
65### Main targets.
66
67## noip
68HACKS += noip
69NOIP_SOURCES = noip.c
70DISTFILES += $(NOIP_SOURCES)
71
72## uopen
73HACKS += uopen
74UOPEN_SOURCES = uopen.c
75DISTFILES += $(UOPEN_SOURCES)
76
77## Libraries.
78LIBS += $(addsuffix .so, $(HACKS))
79TARGETS += $(LIBS)
80
81## Scripts.
82SCRIPTS = $(HACKS)
83TARGETS += $(SCRIPTS)
84DISTFILES += withlib.in
85
86## Manual pages.
87MAN1 += $(addsuffix .1, $(HACKS))
88DISTFILES += $(MAN1)
89
90###--------------------------------------------------------------------------
91### Distribution arrangements.
92
93## Names.
94distdir = $(PACKAGE)-$(VERSION)
95DISTTAR = $(distdir).tar.gz
96
97## Distribute the build utilities.
98DISTFILES += Makefile
99DISTFILES += auto-version
100
101## Documentation.
102DISTFILES += README
103
104## Licensing.
105DISTFILES += COPYING
106
107## Debian.
108debpkg = noip uopen
109DISTFILES += debian/changelog debian/copyright
110DISTFILES += debian/control debian/rules
111DISTFILES += $(patsubst %, debian/%.install, $(debpkg))
112DISTFILES += $(patsubst %, debian/%.lintian-overrides, \
113 $(debpkg))
114
115###--------------------------------------------------------------------------
116### Building.
117
e4976bb0 118all: $(TARGETS)
bfa74564
MW
119.PHONY: ALL
120
121clean:
122 rm -f *.o $(TARGETS)
123.PHONY: clean
124
125## Building sources.
e4976bb0 126%.o: %.c
9496e743 127 $(CC) -c $(REAL_CFLAGS) $< -o $@
bfa74564
MW
128
129## Constructing preload hacks.
130noip.so: $(patsubst %.c, %.o, $(NOIP_SOURCES))
9496e743 131 $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
bfa74564 132uopen.so: $(patsubst %.c, %.o, $(UOPEN_SOURCES))
9496e743 133 $(LD) $(REAL_LDFLAGS) $< $(LDLIBS) -o $@
bfa74564
MW
134
135## Constructing the scripts.
2906706d 136$(SCRIPTS): withlib.in
137 for i in $(SCRIPTS); do \
138 sed "s/@lib@/$$i/" withlib.in >$$i.new || exit 1; \
53390eff 139 chmod +x $$i.new || exit 1; \
2906706d 140 mv $$i.new $$i || exit 1; \
141 done
bfa74564
MW
142
143###--------------------------------------------------------------------------
144### Installation.
145
2906706d 146install: all
bfa74564 147 $(MKDIRS) $(DESTDIR)$(bindir)
2906706d 148 $(INST_BIN) $(SCRIPTS) $(DESTDIR)$(bindir)
bfa74564
MW
149 $(MKDIRS) $(DESTDIR)$(libdir)
150 $(INST_BIN) $(LIBS) $(DESTDIR)$(libdir)
151 $(MKDIRS) $(DESTDIR)$(man1dir)
2906706d 152 $(INST_MAN) $(MAN1) $(DESTDIR)$(man1dir)
bfa74564
MW
153.PHONY: install
154
2906706d 155uninstall:
156 rm -f $(addprefix $(DESTDIR)$(libdir)/, $(LIBS))
157 rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
158 rm -f $(addprefix $(DESTDIR)$(man1dir)/, $(MAN1))
bfa74564
MW
159.PHONY: uninstall
160
161###--------------------------------------------------------------------------
162### Distribution.
163
2906706d 164distdir:
bfa74564
MW
165 rm -rf $(distdir)
166 mkdir $(distdir)
167 echo $(VERSION) >$(distdir)/RELEASE
168 for i in $(DISTFILES); do \
169 case "$$i" in \
170 */*) \
171 d=$${i%/*} && $(MKDIRS) $(distdir)/$$d || exit 1 \
172 ;; \
173 esac; \
174 ln $$i $(distdir)/$$i || exit 1; \
175 done
176.PHONY: distdir
177
2906706d 178dist: distdir
bfa74564
MW
179 tar chozf $(DISTTAR) $(distdir)
180 rm -rf $(distdir)
181.PHONY: dist
182
183distcheck: dist
184 rm -rf _distcheck
185 mkdir _distcheck
186 cd _distcheck && \
187 tar xvfz ../$(DISTTAR) && \
188 cd $(distdir) && \
189 make && \
190 make install DESTDIR=../_install && \
191 make dist
192 rm -rf _distcheck
193
194###----- That's all, folks --------------------------------------------------