Commit | Line | Data |
---|---|---|
09169146 GW |
1 | # WARNING: |
2 | # CONTENTS UNDER PRESSURE. | |
3 | # HIGHLY FLAMMABLE. | |
4 | # RISK OF SHOCK. | |
5 | # DO NOT ATTEMPT TO OPEN COVER. | |
6 | # NO USER SERVICEABLE PARTS INSIDE. | |
7 | # REFER SERVICING TO QUALIFIED PERSONNEL. | |
8 | # | |
9 | # The vendor hits you... | |
10 | # You try to hit the vendor... | |
11 | # You die. | |
12 | # | |
13 | # Unfortunately the above is no fun... | |
14 | # | |
15 | # During testing/porting we have found a long list | |
16 | # of "make" and "sh" and "awk" features in different implementations. | |
17 | # Some goodies (make good horror stories for your kids 8-(): | |
18 | # gmake 3.62 | |
19 | # non standard target construction | |
20 | # | |
21 | # pmake (e. g. NetBSD on MAC, possible other BNR2+pmake systems) | |
22 | # skips '' (empty string positional) args to sh | |
23 | # (this leads to following stupid constructions | |
24 | # sh -c "./scripts/makeconfig.sh '$(OS)' '$(COMP)'") | |
25 | # | |
26 | # Following Makefile construction fails for no | |
27 | # apparent reason (at least to me) | |
28 | # doit: | |
29 | # $(MAKE) MAKE=\"$(MAKE)\" all | |
30 | # | |
31 | # all: | |
32 | # @echo all done. | |
33 | # | |
34 | # for the "make MAKE=make" call not for "make" or | |
35 | # "make -e MAKE=make". Use the last form if you suffer | |
36 | # from that kind of make problems. (Easily detected | |
37 | # by failure to build with the message: | |
38 | # "don't know how to make make". | |
39 | # | |
40 | # sh (Ultrix 4.2 MIPS) | |
41 | # shell broken (reversed pipe construction "false | true" | |
42 | # returns false - major bummer) | |
43 | # | |
44 | # awk (EP/IX 2.?) | |
45 | # unable to do regexp matches | |
46 | # (aka awk '/..*/ { print; }' fails on match) | |
47 | # | |
48 | # Usually the vendor should fix these bugs in vital utilities. | |
49 | # We try to circumvent these bugs in a hopefully portable way. | |
50 | # If you can reproduce these bugs on your system please bug your | |
51 | # vendor to fix them. We are not trying anything fancy in here and | |
52 | # we are shocked that even the most common tools fail so miserably. | |
53 | # By the time you get this code the above utilities may already | |
54 | # have been fixed. Hopefully one day we do not have to cope with | |
55 | # this kind of broken utilities. | |
56 | # | |
57 | # Sorry about the situation, | |
58 | # Frank Kardel | |
59 | # | |
60 | SHELL=/bin/sh | |
61 | CONF = Config | |
62 | CONFL = $(CONF).local | |
63 | CONFLD= $(CONFL).dist | |
64 | TARGETS = xntpd/xntpd xntpdc/xntpdc ntpq/ntpq ntpdate/ntpdate \ | |
65 | ntptrace/ntptrace xntpres/xntpres authstuff/authspeed util/tickadj | |
66 | OPTTARG = adjtime/adjtimed util/ntptime util/precision | |
67 | REFCONF= | |
68 | COMPRESSOR=compress | |
69 | # Base distribution name (will be extended by <VERSION>.tar.<comperssorsuffix>) | |
70 | DISTNAME=xntp- | |
71 | MAKE= make | |
72 | ||
73 | all: version $(TARGETS) kernel_modules | |
74 | ||
75 | $(TARGETS): VERSION $(CONF) | |
76 | ||
77 | version: | |
78 | @echo '### Building XNTP:' "`egrep '^.*=.*$$' VERSION | tr '\012' ';'`" | |
79 | ||
80 | makeconfig: | |
81 | sh -c "./scripts/makeconfig.sh '$(OS)' '$(COMP)'" | |
82 | ||
83 | $(CONFL).NO.clock: | |
84 | @echo '###' creating $(CONFL) for absolutely '*NO*' clocks '*AT ALL*' | |
85 | rm -f $(CONFL)-t $(CONFL) | |
86 | cat < $(CONFLD) > $(CONFL)-t && mv $(CONFL)-t $(CONFL) | |
87 | ||
88 | $(CONFL).green: | |
89 | @echo '###' creating $(CONFL) for greenhorns '(local refclock only)' | |
90 | rm -f $(CONFL)-t $(CONFL) | |
91 | sed 's/#GREEN//' < $(CONFLD) > $(CONFL)-t && mv $(CONFL)-t $(CONFL) | |
92 | ||
93 | $(CONFL): | |
94 | @echo '' | |
95 | @echo '### creating a $(CONFL) file as none existed.' | |
96 | @echo '### Use "make refconf" if you have a radio clock' | |
97 | @echo '' | |
98 | @$(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" $(CONFL).green | |
99 | ||
100 | $(CONF): $(CONFL) | |
101 | @echo | |
102 | @echo '###' creating new configuration | |
103 | @sh -c "./scripts/makeconfig.sh '$(OS)' '$(COMP)'" | |
104 | ||
105 | refconf: $(CONF) | |
106 | -@sh refclocks/rconfig '$(REFCONF)' | |
107 | @sh -c "./scripts/makeconfig.sh '$(OS)' '$(COMP)'" | |
108 | ||
109 | kernel_modules: kernel/Makefile | |
110 | @cd kernel && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
111 | ||
112 | xntpd/xntpd: lib/libntp.a parse/libparse.a xntpd/Makefile FRC | |
113 | @echo | |
114 | @echo '###' creating NTP daemon | |
115 | @cd xntpd && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
116 | ||
117 | xntpdc/xntpdc: lib/libntp.a xntpdc/Makefile FRC | |
118 | @echo | |
119 | @echo '###' creating XNTPDC utility | |
120 | @cd xntpdc && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
121 | ||
122 | ntpq/ntpq: lib/libntp.a ntpq/Makefile FRC | |
123 | @echo | |
124 | @echo '###' creating NTPQ utility | |
125 | @cd ntpq && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
126 | ||
127 | ntptrace/ntptrace: lib/libntp.a ntptrace/Makefile FRC | |
128 | @echo | |
129 | @echo '###' creating NTPTRACE utility | |
130 | @cd ntptrace && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
131 | ||
132 | ntpdate/ntpdate: lib/libntp.a ntpdate/Makefile FRC | |
133 | @echo | |
134 | @echo '###' creating NTPDATE utility | |
135 | @cd ntpdate && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
136 | ||
137 | authstuff/authspeed: lib/libntp.a authstuff/Makefile FRC | |
138 | @echo | |
139 | @echo '###' creating AUTH utilities | |
140 | @cd authstuff && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
141 | ||
142 | xntpres/xntpres: lib/libntp.a xntpres/Makefile FRC | |
143 | @echo | |
144 | @echo '###' creating XNTPRES utility | |
145 | @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
146 | ||
147 | util/tickadj: util/Makefile FRC | |
148 | @echo | |
149 | @echo '###' creating TICKADJ utility | |
150 | @cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
151 | ||
152 | lib/libntp.a: lib/*.c lib/Makefile adjtime/Makefile | |
153 | @echo | |
154 | @echo '###' creating NTP library | |
155 | @cd lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
156 | ||
157 | parse/libparse.a: parse/*.c parse/Makefile parse/util/Makefile lib/libntp.a | |
158 | @echo | |
159 | @echo '### creating PARSE subsystem (if configured)' | |
160 | @cd parse && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" | |
161 | ||
162 | FRC: | |
163 | ||
164 | savebin: | |
165 | @test -d bin || mkdir bin | |
166 | @echo | |
167 | @echo '### saving $(TARGETS) $(OPTTARG) in bin' | |
168 | -@for f in $(TARGETS) $(OPTTARG); \ | |
169 | do test -f $$f && mv $$f bin/. && echo "### saved $$f in bin/"; \ | |
170 | done; \ | |
171 | true | |
172 | ||
173 | neatneat: | |
174 | @echo '###' cleaning derived config files | |
175 | -@rm -f $(CONF).sed $(CONF) | |
176 | ||
177 | neat: | |
178 | @echo '###' cleaning top level left overs | |
179 | -@rm -f eddep makedep Makefile.bak make.log make.out | |
180 | ||
181 | distclean: neatneat clean | |
182 | @echo '###' cleaning configuration dependent Makefiles | |
183 | -@find . -name Makefile -print | \ | |
184 | while read X; do \ | |
185 | if [ -f "$$X.tmpl" ]; then \ | |
186 | rm -f "$$X"; \ | |
187 | else \ | |
188 | :; \ | |
189 | fi \ | |
190 | done | |
191 | @echo '###' cleaning old scratch files | |
192 | -@find . \( -name '*.rej' -o -name '*.orig' -o -name '*~' -o \ | |
193 | -name '.version' -o -name '#*' -o -name '.#*' -o \ | |
194 | -name core -o -name version.c \) -print | xargs rm -f | |
195 | @echo '###' cleaning saved binaries | |
196 | -@rm -fr bin | |
197 | ||
198 | clean: neat | |
199 | @echo '###' cleaning adjtime | |
200 | @cd adjtime && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" -f Makefile.tmpl $@ | |
201 | @echo '###' cleaning authstuff | |
202 | @cd authstuff && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
203 | @echo '###' cleaning clockstuff | |
204 | @cd clockstuff && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
205 | @echo '###' cleaning lib | |
206 | @cd lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
207 | @echo '###' cleaning ntpdate | |
208 | @cd ntpdate && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
209 | @echo '###' cleaning ntpq | |
210 | @cd ntpq && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
211 | @echo '###' cleaning ntptrace | |
212 | @cd ntptrace && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
213 | @echo '###' cleaning util | |
214 | @cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
215 | @echo '###' cleaning xntpd | |
216 | @cd xntpd && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
217 | @echo '###' cleaning xntpdc | |
218 | @cd xntpdc && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
219 | @echo '###' cleaning xntpres | |
220 | @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
221 | @echo '###' cleaning parse | |
222 | @cd parse && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" $@ | |
223 | ||
224 | install: all | |
225 | @echo installing from xntpd | |
226 | @cd xntpd && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
227 | @echo installing from xntpdc | |
228 | @cd xntpdc && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
229 | @echo installing from ntpq | |
230 | @cd ntpq && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
231 | @echo installing from ntptrace | |
232 | @cd ntptrace && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
233 | @echo installing from ntpdate | |
234 | @cd ntpdate && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
235 | @echo installing from xntpres | |
236 | @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
237 | @echo installing from util | |
238 | @cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
239 | @echo installing from parse | |
240 | @cd parse && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install | |
241 | ||
242 | dist: | |
243 | @echo '### building distribution ...' | |
244 | @$(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" distclean | |
245 | @DISTVERSION="`sed -e 's/^[ ]*[Vv][Ee][Rr][Ss][Ii][Oo][Nn][ ]*=\(.*\)$$/\1/' VERSION | \ | |
246 | sed -e 's/[^0-9a-zA-Z\.]/_/g; s/__*/_/g; s/_*$$//'`" && \ | |
247 | echo "### creating distribution file $(DISTNAME)$${DISTVERSION}.tar" && \ | |
248 | rm -f $(DISTNAME)$${DISTVERSION}.tar $(DISTNAME)$${DISTVERSION}.tar.* && \ | |
249 | tar cfv $(DISTNAME)$${DISTVERSION}.tar `ls | egrep -v "^$(CONFL)$$|^$(DISTNAME)$${DISTVERSION}.tar$$"` && \ | |
250 | $(COMPRESSOR) -v $(DISTNAME)$${DISTVERSION}.tar | |
251 | ||
252 | $(CONF).sed: $(CONF) Makefile | |
253 | @sed -n -e 's:^\([^ ]*\)=[ ]*\(.*\):s~^\1=.*~&~:p' < $(CONF) > $@ | |
254 | ||
255 | depend: | |
256 | find . -name Makefile.tmpl -print > eddep | |
257 | echo >> makedep | |
258 | sed -e 's:^\./::' -e '/^Makefile/d' \ | |
259 | -e h \ | |
260 | -e 's/^\(.*\)\.tmpl$$/\1: \1.tmpl $${CONF}.sed/' -e p -e g \ | |
261 | -e 's/.*/ @echo/' -e p -e g \ | |
262 | -e 's:^\(.*\)/Makefile\.tmpl$$: @echo '"'###'"' updating Makefile in \1:' -e p -e g \ | |
263 | -e 's/.*/ @sed -f $${CONF}.sed < $$@.tmpl > $$@/' -e p -e g \ | |
264 | -e 's:^\(.*\)/Makefile\.tmpl$$: @echo '"'###'"' cleaning in \1:' -e p -e g \ | |
265 | -e 's:^\(.*\)/Makefile\.tmpl$$: @cd \1 \&\& $$(MAKE) $$(MFLAGS) MFLAGS="$$(MFLAGS)" -f Makefile.tmpl MAKE="$$(MAKE)" clean:p' \ | |
266 | < eddep >> makedep | |
267 | echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep | |
268 | echo '$$r makedep' >>eddep | |
269 | echo 'w' >>eddep | |
270 | cp Makefile Makefile.bak | |
271 | /bin/ed - Makefile < eddep | |
272 | rm eddep makedep | |
273 | ||
274 | # DO NOT DELETE THIS LINE -- It is used by 'make depend' to update this file | |
275 | ||
276 | adjtime/Makefile: adjtime/Makefile.tmpl ${CONF}.sed | |
277 | @echo | |
278 | @echo '###' updating Makefile in adjtime | |
279 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
280 | @echo '###' cleaning in adjtime | |
281 | @cd adjtime && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
282 | authstuff/Makefile: authstuff/Makefile.tmpl ${CONF}.sed | |
283 | @echo | |
284 | @echo '###' updating Makefile in authstuff | |
285 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
286 | @echo '###' cleaning in authstuff | |
287 | @cd authstuff && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
288 | clockstuff/Makefile: clockstuff/Makefile.tmpl ${CONF}.sed | |
289 | @echo | |
290 | @echo '###' updating Makefile in clockstuff | |
291 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
292 | @echo '###' cleaning in clockstuff | |
293 | @cd clockstuff && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
294 | kernel/Makefile: kernel/Makefile.tmpl ${CONF}.sed | |
295 | @echo | |
296 | @echo '###' updating Makefile in kernel | |
297 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
298 | @echo '###' cleaning in kernel | |
299 | @cd kernel && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
300 | lib/Makefile: lib/Makefile.tmpl ${CONF}.sed | |
301 | @echo | |
302 | @echo '###' updating Makefile in lib | |
303 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
304 | @echo '###' cleaning in lib | |
305 | @cd lib && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
306 | ntpdate/Makefile: ntpdate/Makefile.tmpl ${CONF}.sed | |
307 | @echo | |
308 | @echo '###' updating Makefile in ntpdate | |
309 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
310 | @echo '###' cleaning in ntpdate | |
311 | @cd ntpdate && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
312 | ntpq/Makefile: ntpq/Makefile.tmpl ${CONF}.sed | |
313 | @echo | |
314 | @echo '###' updating Makefile in ntpq | |
315 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
316 | @echo '###' cleaning in ntpq | |
317 | @cd ntpq && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
318 | ntptrace/Makefile: ntptrace/Makefile.tmpl ${CONF}.sed | |
319 | @echo | |
320 | @echo '###' updating Makefile in ntptrace | |
321 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
322 | @echo '###' cleaning in ntptrace | |
323 | @cd ntptrace && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
324 | util/Makefile: util/Makefile.tmpl ${CONF}.sed | |
325 | @echo | |
326 | @echo '###' updating Makefile in util | |
327 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
328 | @echo '###' cleaning in util | |
329 | @cd util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
330 | xntpd/Makefile: xntpd/Makefile.tmpl ${CONF}.sed | |
331 | @echo | |
332 | @echo '###' updating Makefile in xntpd | |
333 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
334 | @echo '###' cleaning in xntpd | |
335 | @cd xntpd && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
336 | xntpdc/Makefile: xntpdc/Makefile.tmpl ${CONF}.sed | |
337 | @echo | |
338 | @echo '###' updating Makefile in xntpdc | |
339 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
340 | @echo '###' cleaning in xntpdc | |
341 | @cd xntpdc && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
342 | xntpres/Makefile: xntpres/Makefile.tmpl ${CONF}.sed | |
343 | @echo | |
344 | @echo '###' updating Makefile in xntpres | |
345 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
346 | @echo '###' cleaning in xntpres | |
347 | @cd xntpres && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
348 | parse/util/Makefile: parse/util/Makefile.tmpl ${CONF}.sed | |
349 | @echo | |
350 | @echo '###' updating Makefile in parse/util | |
351 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
352 | @echo '###' cleaning in parse/util | |
353 | @cd parse/util && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean | |
354 | parse/Makefile: parse/Makefile.tmpl ${CONF}.sed | |
355 | @echo | |
356 | @echo '###' updating Makefile in parse | |
357 | @sed -f ${CONF}.sed < $@.tmpl > $@ | |
358 | @echo '###' cleaning in parse | |
359 | @cd parse && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" -f Makefile.tmpl MAKE="$(MAKE)" clean |