xref: /386bsd/usr/src/usr.sbin/tcpdump/Makefile (revision a2142627)
1#  Copyright (c) 1988-1990 The Regents of the University of California.
2#  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# @(#) $Header: Makefile,v 1.85 91/06/17 16:43:42 mccanne Exp $ (LBL)
21
22# Possible Options:
23#  -DCSLIP	include support for kernel slip interface
24#  -DPPP	include support for point to point protocol
25#  -DIBMRTPC	enable the MERIT additions to the Stanford Enetfilter
26#  -DNOVFPRINTF	simulate vfprintf() on systems that don't have it
27#
28# CSLIP and PPP work only under BPF.
29#
30DEFINES = -DCSLIP -DPPP
31CCOPT = -O
32INCLUDES = -I.. -I/usr/include/nonstd/bsd
33
34# The installed binary is owned by this group.
35GROUP = operator
36
37# Full pathname of where to install the binary
38BINDEST = /usr/sbin/tcpdump
39# Full pathname of where to install the manual entry
40MANDEST = /usr/share/man/man8/tcpdump.8
41
42# Standard CFLAGS
43STANDARD_CFLAGS = $(CCOPT) $(DEFINES) $(INCLUDES)
44
45# CFLAGS definitions per machine vs. os
46CFLAGS = $(STANDARD_CFLAGS)
47#mips-ultrix#CFLAGS = $(STANDARD_CFLAGS)
48#rt-bsd#CFLAGS = $(STANDARD_CFLAGS) -U__STDC__
49#sun3-sunos3#CFLAGS = $(STANDARD_CFLAGS)
50#sun3-sunos4#CFLAGS = $(STANDARD_CFLAGS)
51#sun4-sunos4#CFLAGS = $(STANDARD_CFLAGS)
52#tahoe-bsd#CFLAGS = $(STANDARD_CFLAGS)
53#vax-bsd#CFLAGS = $(STANDARD_CFLAGS)
54#vax-ultrix#CFLAGS = $(STANDARD_CFLAGS)
55
56SUBDIRS = hp300-bsd mips-ultrix sun?-sunos? tahoe-bsd vax-bsd vax-ultrix rt-bsd
57
58# Change these to cc/lex/yacc if you don't have gcc, flex and/or bison.
59CC = cc -g
60LEX = lex
61YACC = yacc
62MAKE = make
63
64# Script (or program) that returns the machine and os types,
65# or jsut edit in the name yourself.
66MD=i386
67# `./mdtype`
68OS=bsd
69# `./ostype`
70
71# Explicitly define compiliation rule since SunOS 4's make doesn't like gcc.
72# Also, gcc does not remove the .o before forking 'as', which can be a
73# problem if you don't own the file but can write to the directory.
74.c.o:
75	rm -f $@; $(CC) $(CFLAGS) -c $*.c
76
77CSRC =	tcpdump.c addrtoname.c \
78	print-ether.c print-ip.c print-arp.c print-tcp.c print-udp.c \
79	print-atalk.c print-domain.c print-tftp.c print-bootp.c print-nfs.c \
80	print-icmp.c nametoaddr.c print-sl.c print-ppp.c print-rip.c \
81	print-snmp.c print-ntp.c \
82	savefile.c util.c etherent.c inet.c gencode.c optimize.c \
83	bpf_dump.c bpf_filter.c bpf_image.c
84
85SRC =	$(CSRC) tcpgram.y tcplex.l
86
87MSRC =	md-hp300.c md-mips.c md-sun3.c md-sun4.c md-vax.c md-rt.c
88
89PSRC =	pcap-nit.c pcap-pf.c pcap-snit.c pcap-bpf.c pcap-enet.c
90
91OSRC =	os-sunos3.c os-sunos4.c os-bsd.c os-ultrix.c
92
93OBJ =	tcpdump.o tcpgram.o tcplex.o addrtoname.o \
94	print-ether.o print-ip.o print-arp.o print-tcp.o print-udp.o \
95	print-atalk.o print-domain.o print-tftp.o print-bootp.o print-nfs.o \
96	print-icmp.o nametoaddr.o print-sl.o print-ppp.o print-rip.o \
97	print-snmp.o print-ntp.o \
98	pcap.o md.o os.o \
99	savefile.o util.o etherent.o inet.o gencode.o optimize.o \
100	bpf_dump.o bpf_filter.o bpf_image.o
101
102HDR =	interface.h appletalk.h addrtoname.h \
103	bootp.h mib.h savefile.h etherproto.h nametoaddr.h \
104	etherent.h ntp.h gencode.h extract.h
105
106MHDR =	md-hp300.h md-sun3.h md-sun4.h md-mips.h md-vax.h md-rt.h
107
108OHDR =	os-bsd.h os-sunos3.h os-sunos4.h os-ultrix.h
109
110TAGHDR=	/usr/include/netinet/in.h \
111	/usr/include/netinet/udp.h \
112	/usr/include/netinet/tcp.h \
113	/usr/include/arpa/tftp.h \
114	/usr/include/netinet/if_ether.h
115
116# These files are automatically generated.
117#
118GEN =	tokdefs.h tcpgram.c tcplex.c
119
120AWKS =	atime.awk packetdat.awk send-ack.awk stime.awk
121
122# "all" must come before tcpdump so we can delete it with sed
123all: submake
124
125tcpdump: $(OBJ)
126	$(CC) $(CFLAGS) -o $@ $(OBJ) $(LIB)
127
128submake: force
129	-@dir=$(MD)-$(OS); \
130	if [ ! -d $$dir ]; then ${MAKE} ${MFLAGS} config; fi; \
131	set -x; \
132	cd $$dir; ${MAKE} ${MFLAGS}
133
134# N.B.- symbolic links are used in the subdirectory rather than VPATH
135# because at least one Sun cc compiler puts the .o in the wrong place
136# when using VPATH and it's almost impossible to get "make depend" to
137# do the right thing.
138
139config:
140	-@md=$(MD); os=$(OS); dir=$$md-$$os; list=; \
141	if [ -f /dev/bpf0 ] ; then pcap="bpf"; \
142	elif [ $$os = "sunos3" ] ; then pcap="nit"; \
143	elif [ $$os = "sunos4" ] ; then pcap="snit"; \
144	elif [ $$os = "ultrix" ] ; then pcap="pf"; \
145	elif [ -f /usr/include/net/enet.h ] ; then pcap="enet"; \
146	else pcap="bpf"; fi; \
147	for i in $(SRC) $(HDR); do list="../$$i $$list"; done; \
148	set -x; mkdir $$dir; chmod ug+w $$dir; ln -s $$list $$dir; \
149	ln -s ../md-$$md.c $$dir/md.c; ln -s ../md-$$md.h $$dir/md.h; \
150	ln -s ../os-$$os.c $$dir/os.c; ln -s ../os-$$os.h $$dir/os.h; \
151	ln -s ../pcap-$$pcap.c $$dir/pcap.c; \
152	sed -e "/^all:/d" -e "s/^#$$dir#//" Makefile >$$dir/Makefile; \
153	chmod ug+w $$dir/Makefile; \
154	cd $$dir ; ${MAKE} ${MFLAGS} depend
155
156tcplex.c: tcplex.l
157	rm -f $@
158	$(LEX) $<
159	mv -f lex.yy.c tcplex.c
160
161tokdefs.h: tcpgram.c
162tcpgram.c: tcpgram.y
163	rm -f tcpgram.c tokdefs.h
164	$(YACC) -d $<
165	mv y.tab.c tcpgram.c
166	mv y.tab.h tokdefs.h
167
168install: force
169	@dir=$(MD)-$(OS); set -x; \
170	install -m 750 -g $(GROUP) $$dir/tcpdump $(DESTDIR)$(BINDEST); \
171	install -c tcpdump.1 $(DESTDIR)$(MANDEST)
172
173lint:	force
174	lint -hbxn $(CSRC) | \
175	    grep -v 'struct/union .* never defined' | \
176	    grep -v 'possible pointer alignment problem'
177
178# This might be futile
179lint.ultrix: force
180	lint $(CFLAGS_ULTRIX) $(CSRC) tcplex.c tcpgram.c
181
182clean:
183	rm -f *.o tcpdump tcpdump.shar $(GEN) ; \
184	rm -rf $(SUBDIRS)
185
186TAGFILES = $(SRC) md.c os.c pcap.c $(HDR) md.h os.h $(TAGHDR)
187
188tags:	$(TAGFILES)
189	ctags -wt $(TAGFILES)
190
191TARNAME = /tmp/tcpdump-2.1beta.tar
192
193tar:	force
194	tar cf $(TARNAME) README INSTALL Makefile tcpdump.1 \
195		mdtype ostype ostype.awk makemib \
196		$(SRC) $(MSRC) $(OSRC) $(PSRC) \
197		$(HDR) $(MHDR) $(OHDR) \
198		$(AWKS) \
199		SUNOS4 net
200	tar ufhFF $(TARNAME) bpf
201	rm -f $(TARNAME).Z
202	compress $(TARNAME)
203
204force:	/tmp
205
206depend:	force
207	@set -x ; \
208	rm -f $(GEN) ; \
209	grep '^#include' tcpgram.y > tcpgram.c ; \
210	grep '^#include' tcplex.l > tcplex.c ; \
211	touch tokdefs.h
212	-mkdep $(DEFINES) $(INCLUDES) $(CSRC) tcpgram.c tcplex.c
213	rm -f $(GEN)
214