xref: /freebsd/contrib/tcpdump/Makefile.in (revision 87b759f0fa1f7554d50ce640c40138512bbded44)
1#  Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
2#	The Regents of the University of California.  All rights reserved.
3#
4#  Redistribution and use in source and binary forms, with or without
5#  modification, are permitted provided that: (1) source code distributions
6#  retain the above copyright notice and this paragraph in its entirety, (2)
7#  distributions including binary code include the above copyright notice and
8#  this paragraph in its entirety in the documentation or other materials
9#  provided with the distribution, and (3) all advertising materials mentioning
10#  features or use of this software display the following acknowledgement:
11#  ``This product includes software developed by the University of California,
12#  Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13#  the University nor the names of its contributors may be used to endorse
14#  or promote products derived from this software without specific prior
15#  written permission.
16#  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17#  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19
20#
21# Various configurable paths (remember to edit Makefile.in, not Makefile)
22#
23
24# Top level hierarchy
25prefix = @prefix@
26exec_prefix = @exec_prefix@
27datarootdir = @datarootdir@
28# Pathname of directory to install the binary
29bindir = @bindir@
30# Pathname of directory to install the man page
31mandir = @mandir@
32
33# VPATH
34srcdir = @srcdir@
35top_srcdir = @top_srcdir@
36VPATH = @srcdir@
37
38#
39# You shouldn't need to edit anything below here.
40#
41
42CC = @CC@
43AR = @AR@
44MKDEP = @MKDEP@
45PROG = tcpdump
46CCOPT = @V_CCOPT@
47INCLS = -I. @V_INCLS@
48DEFS = @DEFS@ @CPPFLAGS@ @V_DEFS@
49
50# Standard CFLAGS
51CFLAGS = @CFLAGS@
52FULL_CFLAGS = $(CCOPT) $(DEFS) $(INCLS) $(CFLAGS)
53
54# Standard LDFLAGS
55LDFLAGS = @LDFLAGS@
56
57# Standard LIBS
58LIBS = @LIBS@
59
60INSTALL = @INSTALL@
61INSTALL_PROGRAM = @INSTALL_PROGRAM@
62INSTALL_DATA = @INSTALL_DATA@
63RANLIB = @RANLIB@
64
65DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
66
67# Explicitly define compilation rule since SunOS 4's make doesn't like gcc.
68# Also, gcc does not remove the .o before forking 'as', which can be a
69# problem if you don't own the file but can write to the directory.
70.c.o:
71	@rm -f $@
72	$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
73
74CSRC =	fptype.c tcpdump.c
75
76LIBNETDISSECT_SRC=\
77	addrtoname.c \
78	addrtostr.c \
79	af.c \
80	ascii_strcasecmp.c \
81	checksum.c \
82	cpack.c \
83	gmpls.c \
84	in_cksum.c \
85	ipproto.c \
86	l2vpn.c \
87	machdep.c \
88	netdissect.c \
89	netdissect-alloc.c \
90	nlpid.c \
91	ntp.c \
92	oui.c \
93	parsenfsfh.c \
94	print.c \
95	print-802_11.c \
96	print-802_15_4.c \
97	print-ah.c \
98	print-ahcp.c \
99	print-aodv.c \
100	print-aoe.c \
101	print-ap1394.c \
102	print-arcnet.c \
103	print-arista.c \
104	print-arp.c \
105	print-ascii.c \
106	print-atalk.c \
107	print-atm.c \
108	print-babel.c \
109	print-bcm-li.c \
110	print-beep.c \
111	print-bfd.c \
112	print-bgp.c \
113	print-bootp.c \
114	print-brcmtag.c \
115	print-bt.c \
116	print-calm-fast.c \
117	print-carp.c \
118	print-cdp.c \
119	print-cfm.c \
120	print-chdlc.c \
121	print-cip.c \
122	print-cnfp.c \
123	print-dccp.c \
124	print-decnet.c \
125	print-dhcp6.c \
126	print-domain.c \
127	print-dsa.c \
128	print-dtp.c \
129	print-dvmrp.c \
130	print-eap.c \
131	print-egp.c \
132	print-eigrp.c \
133	print-enc.c \
134	print-esp.c \
135	print-ether.c \
136	print-fddi.c \
137	print-forces.c \
138	print-fr.c \
139	print-frag6.c \
140	print-ftp.c \
141	print-geneve.c \
142	print-geonet.c \
143	print-gre.c \
144	print-hncp.c \
145	print-hsrp.c \
146	print-http.c \
147	print-icmp.c \
148	print-icmp6.c \
149	print-igmp.c \
150	print-igrp.c \
151	print-ip-demux.c \
152	print-ip.c \
153	print-ip6.c \
154	print-ip6opts.c \
155	print-ipcomp.c \
156	print-ipfc.c \
157	print-ipnet.c \
158	print-ipoib.c \
159	print-ipx.c \
160	print-isakmp.c \
161	print-isoclns.c \
162	print-juniper.c \
163	print-krb.c \
164	print-l2tp.c \
165	print-lane.c \
166	print-ldp.c \
167	print-lisp.c \
168	print-llc.c \
169	print-lldp.c \
170	print-lmp.c \
171	print-loopback.c \
172	print-lspping.c \
173	print-lwapp.c \
174	print-lwres.c \
175	print-m3ua.c \
176	print-macsec.c \
177	print-mobile.c \
178	print-mobility.c \
179	print-mpcp.c \
180	print-mpls.c \
181	print-mptcp.c \
182	print-msdp.c \
183	print-msnlb.c \
184	print-nflog.c \
185	print-nfs.c \
186	print-nsh.c \
187	print-ntp.c \
188	print-null.c \
189	print-olsr.c \
190	print-openflow-1.0.c \
191	print-openflow-1.3.c \
192	print-openflow.c \
193	print-ospf.c \
194	print-ospf6.c \
195	print-otv.c \
196	print-pflog.c \
197	print-pgm.c \
198	print-pim.c \
199	print-pktap.c \
200	print-ppi.c \
201	print-ppp.c \
202	print-pppoe.c \
203	print-pptp.c \
204	print-ptp.c \
205	print-radius.c \
206	print-raw.c \
207	print-realtek.c \
208	print-resp.c \
209	print-rip.c \
210	print-ripng.c \
211	print-rpki-rtr.c \
212	print-rsvp.c \
213	print-rt6.c \
214	print-rtsp.c \
215	print-rx.c \
216	print-sctp.c \
217	print-sflow.c \
218	print-sip.c \
219	print-sl.c \
220	print-sll.c \
221	print-slow.c \
222	print-smtp.c \
223	print-snmp.c \
224	print-someip.c \
225	print-ssh.c \
226	print-stp.c \
227	print-sunatm.c \
228	print-sunrpc.c \
229	print-symantec.c \
230	print-syslog.c \
231	print-tcp.c \
232	print-telnet.c \
233	print-tftp.c \
234	print-timed.c \
235	print-tipc.c \
236	print-token.c \
237	print-udld.c \
238	print-udp.c \
239	print-unsupported.c \
240	print-usb.c \
241	print-vjc.c \
242	print-vqp.c \
243	print-vrrp.c \
244	print-vsock.c \
245	print-vtp.c \
246	print-vxlan-gpe.c \
247	print-vxlan.c \
248	print-wb.c \
249	print-whois.c \
250	print-zep.c \
251	print-zephyr.c \
252	print-zeromq.c \
253	signature.c \
254	strtoaddr.c \
255	util-print.c
256
257LOCALSRC = @LOCALSRC@
258LIBOBJS = @LIBOBJS@
259
260LIBNETDISSECT_OBJ=$(LIBNETDISSECT_SRC:.c=.o) ${LOCALSRC:.c=.o} ${LIBOBJS}
261LIBNETDISSECT=libnetdissect.a
262
263
264SRC =	$(CSRC) $(LOCALSRC)
265
266# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
267# hack the extra indirection
268OBJ =	$(CSRC:.c=.o)
269HDR = \
270	addrtoname.h \
271	addrtostr.h \
272	af.h \
273	ah.h \
274	appletalk.h \
275	ascii_strcasecmp.h \
276	atm.h \
277	chdlc.h \
278	compiler-tests.h \
279	cpack.h \
280	diag-control.h \
281	ethertype.h \
282	extract.h \
283	fptype.h \
284	ftmacros.h \
285	funcattrs.h \
286	getservent.h \
287	gmpls.h \
288	interface.h \
289	ip.h \
290	ip6.h \
291	ipproto.h \
292	l2vpn.h \
293	llc.h \
294	machdep.h \
295	mib.h \
296	mpls.h \
297	nameser.h \
298	netdissect.h \
299	netdissect-alloc.h \
300	netdissect-ctype.h \
301	netdissect-stdinc.h \
302	nfs.h \
303	nfsfh.h \
304	nlpid.h \
305	ntp.h \
306	openflow.h \
307	ospf.h \
308	oui.h \
309	pcap-missing.h \
310	pflog.h \
311	ppp.h \
312	print.h \
313	rpc_auth.h \
314	rpc_msg.h \
315	signature.h \
316	slcompress.h \
317	smb.h \
318	status-exit-codes.h \
319	strtoaddr.h \
320	tcp.h \
321	timeval-operations.h \
322	udp.h \
323	varattrs.h
324
325TAGHDR = \
326	/usr/include/netinet/if_ether.h \
327	/usr/include/netinet/in.h
328
329TAGFILES = $(SRC) $(HDR) $(TAGHDR) $(LIBNETDISSECT_SRC) \
330	print-smb.c smbutil.c
331
332CLEANFILES = $(PROG) $(OBJ) $(LIBNETDISSECT_OBJ) \
333	print-smb.o smbutil.o instrument-functions.o
334
335EXTRA_DIST = \
336	CHANGES \
337	CMakeLists.txt \
338	CONTRIBUTING.md \
339	CREDITS \
340	INSTALL.md \
341	LICENSE \
342	Makefile-devel-adds \
343	Makefile.in \
344	README.md \
345	VERSION \
346	aclocal.m4 \
347	autogen.sh \
348	atime.awk \
349	bpf_dump.c \
350	cmake/Modules/FindCRYPTO.cmake \
351	cmake/Modules/FindPCAP.cmake \
352	cmake/Modules/FindSMI.cmake \
353	cmake_uninstall.cmake.in \
354	cmakeconfig.h.in \
355	config.guess \
356	config.sub \
357	configure.ac \
358	doc/README.aix.md \
359	doc/README.haiku.md \
360	doc/README.NetBSD.md \
361	doc/README.solaris.md \
362	doc/README.windows.md \
363	install-sh \
364	instrument-functions.c \
365	lbl/os-osf4.h \
366	lbl/os-solaris2.h \
367	lbl/os-sunos4.h \
368	lbl/os-ultrix4.h \
369	makemib \
370	missing/datalinks.c \
371	missing/dlnames.c \
372	missing/getopt_long.c \
373	missing/getopt_long.h \
374	missing/getservent.c \
375	missing/pcap_dump_ftell.c \
376	missing/snprintf.c \
377	missing/strdup.c \
378	missing/strlcat.c \
379	missing/strlcpy.c \
380	missing/strsep.c \
381	mkdep \
382	packetdat.awk \
383	print-smb.c \
384	send-ack.awk \
385	smbutil.c \
386	stime.awk \
387	tcpdump.1.in
388
389TEST_DIST= `git -C "$$DIR" ls-files tests | grep -v 'tests/\..*'`
390
391RELEASE_FILES = $(CSRC) $(HDR) $(LIBNETDISSECT_SRC) $(EXTRA_DIST) $(TEST_DIST)
392
393all: $(PROG)
394
395$(PROG): $(OBJ) @V_PCAPDEP@ $(LIBNETDISSECT)
396	@rm -f $@
397	$(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBNETDISSECT) $(LIBS)
398
399$(LIBNETDISSECT): $(LIBNETDISSECT_OBJ)
400	@rm -f $@
401	$(AR) cr $@ $(LIBNETDISSECT_OBJ)
402	$(RANLIB) $@
403
404datalinks.o: $(srcdir)/missing/datalinks.c
405	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/datalinks.c
406dlnames.o: $(srcdir)/missing/dlnames.c
407	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/dlnames.c
408getservent.o: $(srcdir)/missing/getservent.c
409	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getservent.c
410getopt_long.o: $(srcdir)/missing/getopt_long.c
411	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/getopt_long.c
412snprintf.o: $(srcdir)/missing/snprintf.c
413	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
414strdup.o: $(srcdir)/missing/strdup.c
415	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strdup.c
416strlcat.o: $(srcdir)/missing/strlcat.c
417	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
418strlcpy.o: $(srcdir)/missing/strlcpy.c
419	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
420strsep.o: $(srcdir)/missing/strsep.c
421	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strsep.c
422pcap_dump_ftell.o: $(srcdir)/missing/pcap_dump_ftell.c
423	$(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/pcap_dump_ftell.c
424
425install: all
426	[ -d $(DESTDIR)$(bindir) ] || \
427	    (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
428	$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(bindir)/$(PROG)
429	$(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(bindir)/$(PROG).`cat ${srcdir}/VERSION`
430	[ -d $(DESTDIR)$(mandir)/man1 ] || \
431	    (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1)
432	$(INSTALL_DATA) $(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1
433
434uninstall:
435	rm -f $(DESTDIR)$(bindir)/$(PROG)
436	rm -f $(DESTDIR)$(bindir)/$(PROG).`cat ${srcdir}/VERSION`
437	rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1
438
439lint:
440	lint -hbxn $(SRC) $(LIBNETDISSECT_SRC) | \
441	    grep -v 'struct/union .* never defined' | \
442	    grep -v 'possible pointer alignment problem'
443
444clean:
445	rm -f $(CLEANFILES) $(PROG)-`cat ${srcdir}/VERSION`.tar.gz \
446	config.h.in~ configure~ configure.ac~
447
448distclean: clean
449	rm -f Makefile config.cache config.log config.status \
450	    config.h os-proto.h stamp-h stamp-h.in $(PROG).1 \
451	    libnetdissect.a tests/.failed tests/.passed \
452	    tests/failure-outputs.txt
453	rm -rf autom4te.cache tests/DIFF tests/NEW
454
455check: tcpdump
456	$(srcdir)/tests/TESTrun
457
458extags: $(TAGFILES)
459	ctags $(TAGFILES)
460
461tags: $(TAGFILES)
462	ctags -wtd $(TAGFILES)
463
464TAGS: $(TAGFILES)
465	etags $(TAGFILES)
466
467#
468# Use git archive piped to tar to construct a subdirectory whose name
469# is tcpdump-{release}, containing all the checked-in source files,
470# and then run autoreconf in that directory to generate the configure
471# script and other files from that source. Then remove autom4te.cache,
472# construct the release tarball from that subdirectory, and remove
473# the subdirectory.
474#
475# The --format=tar is to force git archive to write a non-compressed
476# archive, in case the platform's tar command doesn't have built-in
477# decompression.
478#
479# The ^{tree} is there to force git archive not to write out the
480# "helpful" global extended pax header with a commit ID, as not all
481# versions of tar can handle that (Solaris tar can't, for example).
482# (It turns HEAD, or a tag, both of which are apparently "tree-ish"es,
483# into a tree; apparently, unlike HEAD, or a tag, which have a commit
484# ID associated with them, the tree associated with them doesn't have
485# a commit ID, so no commit ID is available to write, and thus
486# git archive doesn't write one.)
487#
488releasetar:
489	@TAG=$(PROG)-`cat VERSION` && \
490	if [ ! -d .git ]; then echo 'Not in a git clone, stop.'; exit 1; fi && \
491	TMPTESTFILE=`mktemp -t tmptestfile_XXXXXXXX` && \
492	rm -f "$$TMPTESTFILE" && \
493	AUTORECONF_DIR=`dirname "$$TMPTESTFILE"`/"$(PROG)"_build_autoreconf_$$$$ && \
494	DIR=`pwd` && \
495	rm -rf "$$AUTORECONF_DIR" && \
496	mkdir "$$AUTORECONF_DIR" && \
497	cd "$$AUTORECONF_DIR" && \
498	if git -C "$$DIR" show-ref --tags --quiet --verify -- "refs/tags/$$TAG"; then \
499	    (git -C "$$DIR" archive --format=tar --prefix="$$TAG"/ "$$TAG^{tree}" $(RELEASE_FILES) | \
500	     tar xf -) && \
501	    echo "Archive build from tag $$TAG."; \
502	else \
503	    (git -C "$$DIR" archive --format=tar --prefix="$$TAG"/ "HEAD^{tree}" $(RELEASE_FILES) | \
504	     tar xf -) && \
505	    echo "No $$TAG tag. Archive build from HEAD."; \
506	fi && \
507	(cd "$$TAG" && "$${AUTORECONF:-autoreconf}" && rm -rf autom4te.cache) && \
508	tar cf "$$DIR/$$TAG".tar "$$TAG" && \
509	rm -f "$$DIR/$$TAG".tar.gz && \
510	gzip --best "$$DIR/$$TAG".tar && \
511	cd "$$DIR" && \
512	rm -rf "$$AUTORECONF_DIR"
513
514releasecheck: releasetar
515	@TAG=$(PROG)-`cat VERSION` && \
516	INSTALL_DIR=/tmp/install_"$$TAG"_$$$$ && \
517	DIR=`pwd` && \
518	cd /tmp && \
519	rm -rf "$$TAG" && \
520	rm -rf "$$INSTALL_DIR" && \
521	tar xf "$$DIR"/"$$TAG".tar.gz && \
522	cd "$$TAG" && \
523	echo "[$@] $$ touch .devel" && \
524	touch .devel && \
525	echo "[$@] $$ ./configure --enable-instrument-functions --enable-smb --quiet --prefix=$$INSTALL_DIR" && \
526	./configure --enable-instrument-functions --enable-smb --quiet --prefix="$$INSTALL_DIR" && \
527	echo '[$@] $$ $(MAKE) -s all check' && \
528	$(MAKE) -s all check >/dev/null && \
529	echo '[$@] $$ $(MAKE) -s install' && \
530	$(MAKE) -s install && \
531	cd .. && \
532	rm -rf "$$TAG" && \
533	rm -rf "$$INSTALL_DIR" && \
534	tar xf "$$DIR"/"$$TAG".tar.gz && \
535	cd "$$TAG" && \
536	echo "[$@] $$ touch .devel" && \
537	touch .devel && \
538	mkdir build && \
539	cd build && \
540	echo '[$@] $$ cmake -DENABLE_SMB=yes [...] ..' && \
541	cmake -DENABLE_SMB=yes \
542	    -DCMAKE_INSTALL_PREFIX="$$INSTALL_DIR" \
543	    -DCMAKE_MESSAGE_LOG_LEVEL=NOTICE \
544	    -DCMAKE_RULE_MESSAGES=OFF \
545	    -DCMAKE_INSTALL_MESSAGE=NEVER \
546	    .. && \
547	echo '[$@] $$ $(MAKE) -s all check' && \
548	$(MAKE) -s all check >/dev/null && \
549	echo '[$@] $$ $(MAKE) -s install' && \
550	$(MAKE) -s install && \
551	cd ../.. && \
552	rm -rf "$$TAG" && \
553	rm -rf "$$INSTALL_DIR" && \
554	echo '[$@] Done.'
555
556whitespacecheck:
557	@# trailing space(s)?
558	@if git grep -I -n ' $$' $$(git ls-files|grep -v '^tests/'); then \
559	    echo 'Error: Trailing space(s).'; \
560	    exit 1; \
561	fi
562	@# trailing tab(s)?
563	@if git grep -I -n '	$$' $$(git ls-files|grep -v '^tests/'); then \
564	    echo 'Error: Trailing tabs(s).'; \
565	    exit 1; \
566	fi
567	@# space(s) before tab(s)?
568	@if git grep -I -n '[ ][	]' $$(git ls-files|grep -v '^tests/'); then \
569	    echo 'Error: space(s) before tab(s).'; \
570	    exit 1; \
571	fi
572
573testlist:
574	echo $(TEST_DIST)
575
576depend:
577	@echo $(MKDEP) -c $(CC) -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(DEFS) $(INCLS) $(SRC) '<libnetdissect src list>'
578	@$(MKDEP) -c $(CC) -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(DEFS) $(INCLS) $(SRC) $(LIBNETDISSECT_SRC)
579
580shellcheck:
581	shellcheck -f gcc -e SC2006 autogen.sh build.sh build_matrix.sh build_common.sh mkdep .ci-coverity-scan-build.sh
582