-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrules.mk
277 lines (237 loc) · 7.53 KB
/
rules.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#
#!make
# Copyright 2005-2016 AMS-IX B.V.; All rights reserved.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself. See perldoc
# perlartistic.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the "Copying" file that came with this package.
default : all
RM = /bin/rm -f
MV = /bin/mv
RELEASE := $(shell head -1 $(TOPDIR)/Changelog | perl -p -e 's/.*\((.*?)\).*/$$1/')
NAME = arpsponge
PACKAGE = $(NAME)-$(RELEASE)
TOOLDIR = $(TOPDIR)/tools
INSTALL_LOG = $(TOPDIR)/installed.log
INSTALLPROG = $(TOOLDIR)/bsdinst -c -l $(INSTALL_LOG)
INSTALL = $(INSTALLPROG) -o $(OWNER) -g $(GROUP) -m $(MODE)
BININSTALL = $(INSTALLPROG) -o $(OWNER) -g $(GROUP) -m $(BINMODE)
MKDIR = $(TOOLDIR)/mkinstalldirs
RMDIR = $(TOOLDIR)/rminstalldirs
#
# Substitute configuration variables in files.
#
perlit= $(PERL) -p -e \
"s!\@LIBDIR@!$(LIBDIR)!g; \
s!\@BINDIR@!$(BINDIR)!g; \
s!\@DFL_PATH@!$(DFL_PATH)!g; \
\
s!\@NAME@!$(NAME)!g; \
s!\@UNAME@!\U$(NAME)\E!g; \
s!\@Uname@!\u$(NAME)!g; \
\
s!\@OWNER@!$(OWNER)!g; \
s!\@GROUP@!$(GROUP)!g; \
\
s!\@SECTION@!\U$(SECTION)\E!g; \
s!\@USECTION@!\U$(SECTION)\E!g; \
s!\@FILESECTION@!$(FILESECTION)!g; \
s!\@UFILESECTION@!\U$(FILESECTION)\E!g; \
\
s!\@RELEASE@!$(RELEASE)!g; \
s!\@SHELL@!$(SHELL)!g; \
s!\@PERL@!$(PERL)!g; \
\
s!\@SPONGE_VAR@!$(SPONGE_VAR)!g; \
s!\@DFL_SOCK_PERMS@!$(DFL_SOCK_PERMS)!g; \
\
s!\@IFCONFIG@!$(IFCONFIG)!g; \
s!\@DFL_RATE@!$(DFL_RATE)!g; \
s!\@DFL_INIT@!$(DFL_INIT)!g; \
s!\@DFL_ARP_AGE@!$(DFL_ARP_AGE)!g; \
s!\@DFL_QUEUEDEPTH@!$(DFL_QUEUEDEPTH)!g; \
s!\@DFL_FLOOD_PROTECTION@!$(DFL_FLOOD_PROTECTION)!g; \
s!\@DFL_PENDING@!$(DFL_PENDING)!g; \
s!\@DFL_PROBERATE@!$(DFL_PROBERATE)!g; \
s!\@DFL_LEARN@!$(DFL_LEARN)!g; \
s!\@DFL_LOGLEVEL@!$(DFL_LOGLEVEL)!g; \
\
s!\@ETC_DEFAULT@!$(ETC_DEFAULT)!g; \
"
.SUFFIXES: .al .pm .pmrsc .pl \
.src \
.sample \
.sh \
.txt .ps \
.$(SECTION) .pod .man .txt
version:
@echo $(RELEASE)
% : %.sh Makefile
@echo building $@ from $<
@$(perlit) $< > $@
@chmod 755 $@
%.sample : %.sample.src Makefile
@echo building $@ from $<
@$(perlit) $< > $@
@chmod 644 $@
% : %.src Makefile
@echo building $@ from $<
@$(perlit) $< > $@
@chmod 644 $@
% : %.pl Makefile
@ echo building $@ from $<
@ $(perlit) $< > $@
@ chmod 755 $@
@ $(PERL) -wc $@ || $(RM) $@
%.$(SECTION) : %.pod
@echo building $@ from $<
@PERLLIB=$$PERLLIB:$(TOPDIR)/lib; export PERLLIB; \
pod2man \
--release="$(NAME)-$(RELEASE)" \
--date="`date`" \
--center="AMS-IX Management Utilities" \
--section=$(SECTION) \
--name="`echo $* | sed -e 's/\.\./::/g'`" \
$< > $@
%.html : %.pod
@echo building $@ from $<
@PERLLIB=$$PERLLIB:$(TOPDIR)/lib; export PERLLIB; \
$(TOOLDIR)/pod2html \
--name="`echo $* | sed -e 's/\.\./::/g'`" \
$< > $@
%.txt : %.$(SECTION)
@echo building $@ from $<
@$(perlit) $< | nroff -Tascii -man > $@
%.ps : %.$(SECTION)
@echo building $@ from $<
@$(perlit) $< | groff -Tps -man > $@
$(INITDIR)/% : %
@echo installing executable $< in $(INITDIR)
$(MKDIR) $(INITDIR) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
$(BININSTALL) $< $@
$(PERL) -pi -e 's|^(#!/.*) -I../lib|$$1|' $@
$(BINDIR)/% : %
@echo installing executable $< in $(BINDIR)
$(MKDIR) $(BINDIR) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
$(BININSTALL) $< $@
$(PERL) -pi -e 's|^(#!/.*) -I../lib|$$1|' $@
$(MANDIR)/man$(SECTION)/% : %
@echo installing $< in $(MANDIR)/man$(SECTION)
@$(MKDIR) $(MANDIR)/man$(SECTION) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
@$(INSTALL) $< $@
$(DOCDIR)/% : %
@if [ ! -n "$(SKIPDOCS)" ]; then \
echo installing $< in $(DOCDIR); \
$(MKDIR) $(DOCDIR) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG); \
$(INSTALL) $< $@; \
fi
$(INSTDIR1)/% : %
@echo installing $< in $(INSTDIR1)
@$(MKDIR) $(INSTDIR1) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
@$(INSTALL) $< $@
$(INSTDIR2)/% : %
@echo installing $< in $(INSTDIR2)
@$(MKDIR) $(INSTDIR2) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
@$(INSTALL) $< $@
$(INSTDIR3)/% : %
@echo installing $< in $(INSTDIR3)
@$(MKDIR) $(INSTDIR3) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
@$(INSTALL) $< $@
$(INSTALLDIR)/% : %
@echo installing $< in $(INSTALLDIR)
@$(MKDIR) $(INSTALLDIR) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
@$(INSTALL) $< $@
%.sample : %
@echo building $@ from $<
@$(perlit) $< > $@
@chmod 644 $@
auto/$(AUTO)/%/autosplit.ix : $(AUTO)/%.pm
@echo autosplit $<;
@PERLLIB=$$PERLLIB:$(TOPDIR)/lib; export PERLLIB; \
$(TOOLDIR)/autosplit ./auto $<
auto/$(AUTO1)/%/autosplit.ix : $(AUTO1)/%.pm
@echo autosplit $<;
@PERLLIB=$$PERLLIB:$(TOPDIR)/lib; export PERLLIB; \
$(TOOLDIR)/autosplit ./auto $<
%-all : ; cd $* ; $(MAKE) DISTRO=${DISTRO} all
%-install : ; cd $* ; $(MAKE) DISTRO=${DISTRO} install
%-uninstall : ; cd $* ; $(MAKE) DISTRO=${DISTRO} uninstall
%-autosplit : ; cd $* ; $(MAKE) DISTRO=${DISTRO} autosplit
%-clean : ; cd $* ; $(MAKE) DISTRO=${DISTRO} clean
all : $(TARGETS)
install : all installdirs $(INSTALLFILES) install-links post-install
installdirs :
@echo "Checking/creating installation directories..."
@echo $(INSTALLDIRS)
@$(MKDIR) $(INSTALLDIRS) 2>&1 | sed -e 's/^mkdir //' >> $(INSTALL_LOG)
post-install :
@$(RM) $(INSTALL_LOG).tmp; \
sort -ru $(INSTALL_LOG) > $(INSTALL_LOG).tmp; \
$(MV) $(INSTALL_LOG).tmp $(INSTALL_LOG)
uninstall :
echo "Removing installed files:" ; \
files=$(INSTALLFILES); \
if [ -f $(INSTALL_LOG) ]; then \
files="$$files `cat $(INSTALL_LOG)`"; \
fi; \
echo '** Warning: will remove the following files:'; \
echo $$files | $(PERL) -n -e \
'print map { qq{ $$_\n} } split(" ", $$_);'; \
if [ `echo "\c" | wc -c` -gt 0 ]; then \
echo -n "Are you sure [yn] y"; \
else \
echo "Are you sure [ny] n\c"; \
fi; \
read ans; \
case "$$ans" in \
y*|Y*) echo "Removing ..."; \
$(RM) $$files >/dev/null 2>&1; \
$(RMDIR) $$files >/dev/null 2>&1; \
$(RM) $(INSTALL_LOG); \
echo "Done"; \
true;; \
*) false;; \
esac
x-uninstall : ; $(RM) $(INSTALLFILES)
clean : ; @echo cleaning up
@$(RM) $(TARGETS) core 2>/dev/null \
$(NAME)_*.deb; \
true
install-links:
@for link in ._no $(INSTALLLINKS) $(INSTALLINKS); do \
[ $$link = ._no ] && continue; \
linkname=`echo $$link | cut -f1 -d:`; \
fname=`echo $$link | cut -f2 -d:`; \
if [ ! -f $$linkname ] || [ -h $$linkname ]; then \
target=`/bin/ls -l $$linkname 2>/dev/null | sed -e 's|^.*-> ||'`; \
if [ X$$target != X$$fname ]; then \
$(RM) $$linkname; \
ln -s $$fname $$linkname; \
echo $$linkname; \
fi; \
fi; \
done
veryclean : clean
@if [ -d ./SCCS ]; then sccs clean; fi
_debtemp := /tmp/deb.$(NAME).$(shell echo $$RANDOM)
dpkg:
mkdir -p $(_debtemp)
cp -rp . $(_debtemp)/$(NAME)-$(RELEASE)
cd $(_debtemp)/$(NAME)-$(RELEASE); \
(fakeroot dpkg-buildpackage -b -uc -us || true)
ls $(_debtemp)/$(NAME)_*.deb >/dev/null 2>&1; \
[ $$? = 0 ] && mv $(_debtemp)/$(NAME)_*.deb .
$(RM) -rf $(_debtemp)
#
# %: define.h %.c
# $@: target (wonkie)
# $^: dependencies (define.h wonkie.c)
# $<: primary source file (define.h)
# $?: out of date dependency (wonkie.c)
# $*: portion that matched the "%" (wonkie)