Makefile revision 95419
16539Sweijun# 29330Slana# Copyright (C) 1993-1998 by Darren Reed. 36539Sweijun# 46539Sweijun# Redistribution and use in source and binary forms are permitted 56539Sweijun# provided that this notice is preserved and due credit is given 66539Sweijun# to the original author and the contributors. 76539Sweijun# 86539SweijunBINDEST=/usr/sbin 96539SweijunSBINDEST=/sbin 106539SweijunSEARCHDIRS=$(BINDEST) $(SBINDEST) /bin /usr/bin /sbin /usr/sbin \ 116539Sweijun /usr/local/bin /usr/local/sbin 126539SweijunMANDIR=/usr/share/man 136539SweijunCC=cc -Wall -Wstrict-prototypes -Wuninitialized -O 146539SweijunCFLAGS=-g -I$(TOP) 156539Sweijun# 166539Sweijun# For NetBSD/FreeBSD 176539Sweijun# 186539SweijunDEVFS!=/usr/bin/lsvfs 2>&1 | sed -n 's/.*devfs.*/-DDEVFS/p' 196539SweijunCPU!=uname -m 206539SweijunINC=-I/usr/include -I/sys -I/sys/sys -I/sys/arch 216539SweijunDEF=-D$(CPU) -D__$(CPU)__ -DINET -DKERNEL -D_KERNEL $(INC) $(DEVFS) 226539SweijunIPDEF=$(DEF) -DGATEWAY -DDIRECTED_BROADCAST 236539SweijunVNODESHDIR=/sys/kern 246539SweijunMLD=$(ML) vnode_if.h 256539SweijunML=mln_ipl.c 266539SweijunIPFILC=ip_fil.c 276539SweijunLKM=if_ipl.o 286539SweijunDLKM= 296539SweijunMFLAGS="BINDEST=$(BINDEST)" "SBINDEST=$(SBINDEST)" "MANDIR=$(MANDIR)" \ 306539Sweijun 'CFLAGS=$(CFLAGS) $(SOLARIS2)' "IPFLKM=$(IPFLKM)" \ 316539Sweijun "IPFLOG=$(IPFLOG)" "LOGFAC=$(LOGFAC)" "POLICY=$(POLICY)" \ 326539Sweijun "SOLARIS2=$(SOLARIS2)" "DEBUG=$(DEBUG)" "DCPU=$(CPU)" \ 336539Sweijun "CPUDIR=$(CPUDIR)" 346539Sweijun# 356539Sweijun########## ########## ########## ########## ########## ########## ########## 366539Sweijun# 376539SweijunCP=/bin/cp 386539SweijunRM=/bin/rm 396539SweijunCHMOD=/bin/chmod 406539SweijunINSTALL=install 416539Sweijun# 426539SweijunMODOBJS=ip_fil.o fil_k.o ml_ipl.o ip_nat.o ip_frag.o ip_state.o ip_proxy.o \ 436539Sweijun ip_auth.o ip_log.o 446539SweijunDFLAGS=$(IPFLKM) $(DEF) $(DLKM) 456539SweijunIPF=ipf.o parse.o common.o opt.o facpri.o 466539SweijunIPT=ipt.o parse.o common.o fil.o ipft_sn.o ipft_ef.o ipft_td.o ipft_pc.o \ 476539Sweijun opt.o ipft_tx.o misc.o ip_frag_u.o ip_state_u.o ip_nat_u.o ip_proxy_u.o \ 486539Sweijun ip_auth_u.o ipft_hx.o ip_fil_u.o ip_log_u.o natparse.o facpri.o \ 496539Sweijun printnat.o printstate.o 506539SweijunIPNAT=ipnat.o kmem.o natparse.o common.o printnat.o 516539SweijunFILS=fils.o parse.o kmem.o opt.o facpri.o common.o printstate.o 526539Sweijun 536539Sweijunbuild all: ipf ipfs ipfstat ipftest ipmon ipnat $(LKM) 546539Sweijun /bin/rm -f $(TOP)/ipf 556539Sweijun ln -s `pwd`/ipf $(TOP) 566539Sweijun /bin/rm -f $(TOP)/ipftest 576539Sweijun ln -s `pwd`/ipftest $(TOP) 586539Sweijun /bin/rm -f $(TOP)/ipmon 596539Sweijun ln -s `pwd`/ipmon $(TOP) 606539Sweijun /bin/rm -f $(TOP)/ipnat 616539Sweijun ln -s `pwd`/ipnat $(TOP) 62 63ipfstat: $(FILS) 64 $(CC) -static $(DEBUG) $(CFLAGS) $(STATETOP_CFLAGS) $(STATETOP_INC) \ 65 $(FILS) -o $@ $(LIBS) $(STATETOP_LIB) -lkvm 66 67ipf: $(IPF) 68 $(CC) -static $(DEBUG) $(CFLAGS) $(IPF) -o $@ $(LIBS) 69 70ipftest: $(IPT) 71 $(CC) $(DEBUG) $(CFLAGS) $(IPT) -o $@ $(LIBS) 72 73ipnat: $(IPNAT) 74 $(CC) -static $(DEBUG) $(CFLAGS) $(IPNAT) -o $@ $(LIBS) -lkvm 75 76ipfs: ipfs.o 77 $(CC) -static $(DEBUG) $(CFLAGS) ipfs.o -o $@ $(LIBS) 78 79tests: 80 (cd test; make ) 81 82fils.o: $(TOP)/fils.c $(TOP)/ip_fil.h $(TOP)/ipf.h $(TOP)/ip_frag.h \ 83 $(TOP)/ip_compat.h $(TOP)/ip_state.h $(TOP)/ip_nat.h 84 $(CC) $(DEBUG) $(CFLAGS) $(STATETOP_CFLAGS) $(STATETOP_INC) \ 85 -c $(TOP)/fils.c -o $@ 86 87ipfs.o: $(TOP)/ipfs.c $(TOP)/ip_fil.h $(TOP)/ipf.h $(TOP)/ip_state.h \ 88 $(TOP)/ip_nat.h 89 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipfs.c -o $@ 90 91fil.o: $(TOP)/fil.c $(TOP)/ip_fil.h $(TOP)/ipf.h $(TOP)/ip_compat.h 92 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/fil.c -o $@ 93 94fil_k.o: $(TOP)/fil.c $(TOP)/ip_fil.h $(TOP)/ipf.h $(TOP)/ip_compat.h \ 95 $(TOP)/ipl.h 96 $(CC) $(DEBUG) $(CFLAGS) $(POLICY) $(DFLAGS) -c $(TOP)/fil.c -o $@ 97 98ipf.o: $(TOP)/ipf.c $(TOP)/ip_fil.h $(TOP)/ipf.h 99 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipf.c -o $@ 100 101ipt.o: $(TOP)/ipt.c $(TOP)/ip_fil.h $(TOP)/ipt.h $(TOP)/ipf.h 102 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipt.c -o $@ 103 104misc.o: $(TOP)/misc.c $(TOP)/ip_fil.h $(TOP)/ipt.h $(TOP)/ipf.h 105 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/misc.c -o $@ 106 107opt.o: $(TOP)/opt.c $(TOP)/ip_fil.h $(TOP)/ipf.h 108 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/opt.c -o $@ 109 110ipnat.o: $(TOP)/ipnat.c $(TOP)/ip_fil.h $(TOP)/ipf.h $(TOP)/ip_nat.h 111 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipnat.c -o $@ 112 113natparse.o: $(TOP)/natparse.c $(TOP)/ip_fil.h $(TOP)/ipf.h $(TOP)/ip_nat.h \ 114 $(TOP)/ip_compat.h 115 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/natparse.c -o $@ 116 117printnat.o: $(TOP)/printnat.c $(TOP)/ip_fil.h $(TOP)/ipf.h $(TOP)/ip_nat.h \ 118 $(TOP)/ip_compat.h $(TOP)/ip_proxy.h 119 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/printnat.c -o $@ 120 121printstate.o: $(TOP)/printstate.c $(TOP)/ip_fil.h $(TOP)/ipf.h \ 122 $(TOP)/ip_state.h $(TOP)/ip_compat.h 123 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/printstate.c -o $@ 124 125ipft_sn.o: $(TOP)/ipft_sn.c $(TOP)/ipt.h $(TOP)/ipf.h $(TOP)/ip_fil.h \ 126 $(TOP)/snoop.h 127 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipft_sn.c -o $@ 128 129ipft_ef.o: $(TOP)/ipft_ef.c $(TOP)/ipf.h $(TOP)/ip_fil.h $(TOP)/ipt.h 130 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipft_ef.c -o $@ 131 132ipft_td.o: $(TOP)/ipft_td.c $(TOP)/ipf.h $(TOP)/ip_fil.h $(TOP)/ipt.h 133 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipft_td.c -o $@ 134 135ipft_pc.o: $(TOP)/ipft_pc.c $(TOP)/ipf.h $(TOP)/ip_fil.h $(TOP)/ipt.h 136 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipft_pc.c -o $@ 137 138ipft_tx.o: $(TOP)/ipft_tx.c $(TOP)/ipf.h $(TOP)/ip_fil.h $(TOP)/ipt.h 139 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipft_tx.c -o $@ 140 141ipft_hx.o: $(TOP)/ipft_hx.c $(TOP)/ipf.h $(TOP)/ip_fil.h $(TOP)/ipt.h 142 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ipft_hx.c -o $@ 143 144ip_nat_u.o: $(TOP)/ip_nat.c $(TOP)/ip_nat.h $(TOP)/ip_compat.h $(TOP)/ip_fil.h 145 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ip_nat.c -o $@ 146 147ip_proxy_u.o: $(TOP)/ip_proxy.c $(TOP)/ip_proxy.h $(TOP)/ip_compat.h \ 148 $(TOP)/ip_fil.h $(TOP)/ip_ftp_pxy.c $(TOP)/ip_rcmd_pxy.c \ 149 $(TOP)/ip_raudio_pxy.c $(TOP)/ip_ipsec_pxy.c $(TOP)/ip_nat.h 150 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ip_proxy.c -o $@ 151 152ip_frag_u.o: $(TOP)/ip_frag.c $(TOP)/ip_frag.h $(TOP)/ip_compat.h \ 153 $(TOP)/ip_fil.h 154 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ip_frag.c -o $@ 155 156ip_state_u.o: $(TOP)/ip_state.c $(TOP)/ip_state.h $(TOP)/ip_compat.h \ 157 $(TOP)/ip_fil.h $(TOP)/ip_nat.h 158 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ip_state.c -o $@ 159 160ip_auth_u.o: $(TOP)/ip_auth.c $(TOP)/ip_auth.h $(TOP)/ip_compat.h \ 161 $(TOP)/ip_fil.h 162 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ip_auth.c -o $@ 163 164ip_fil_u.o: $(TOP)/$(IPFILC) $(TOP)/ip_fil.h $(TOP)/ip_compat.h 165 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/$(IPFILC) -o $@ 166 167ip_log_u.o: $(TOP)/ip_log.c $(TOP)/ip_fil.h $(TOP)/ip_compat.h 168 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/ip_log.c -o $@ 169 170if_ipl.o: $(MODOBJS) 171 ld -r $(MODOBJS) -o $(LKM) 172 ${RM} -f if_ipl 173 174ipf.ko ipl.ko: $(MODOBJS) 175 gensetdefs $(MODOBJS) 176 $(CC) $(DEBUG) $(CFLAGS) -c setdef0.c 177 $(CC) $(DEBUG) $(CFLAGS) -c setdef1.c 178 ld -Bshareable -o $(LKM) setdef0.o $(MODOBJS) setdef1.o 179 180ip_nat.o: $(TOP)/ip_nat.c $(TOP)/ip_nat.h $(TOP)/ip_compat.h $(TOP)/ip_fil.h 181 $(CC) $(DEBUG) $(CFLAGS) $(DFLAGS) -c $(TOP)/ip_nat.c -o $@ 182 183ip_frag.o: $(TOP)/ip_frag.c $(TOP)/ip_frag.h $(TOP)/ip_compat.h $(TOP)/ip_fil.h 184 $(CC) $(DEBUG) $(CFLAGS) $(DFLAGS) -c $(TOP)/ip_frag.c -o $@ 185 186ip_state.o: $(TOP)/ip_state.c $(TOP)/ip_state.h $(TOP)/ip_compat.h \ 187 $(TOP)/ip_fil.h $(TOP)/ip_nat.h 188 $(CC) $(DEBUG) $(CFLAGS) $(DFLAGS) -c $(TOP)/ip_state.c -o $@ 189 190ip_proxy.o: $(TOP)/ip_proxy.c $(TOP)/ip_proxy.h $(TOP)/ip_compat.h \ 191 $(TOP)/ip_fil.h $(TOP)/ip_ftp_pxy.c $(TOP)/ip_raudio_pxy.c \ 192 $(TOP)/ip_rcmd_pxy.c $(TOP)/ip_ipsec_pxy.c $(TOP)/ip_nat.h 193 $(CC) $(DEBUG) $(CFLAGS) $(DFLAGS) -c $(TOP)/ip_proxy.c -o $@ 194 195ip_auth.o: $(TOP)/ip_auth.c $(TOP)/ip_auth.h $(TOP)/ip_compat.h \ 196 $(TOP)/ip_fil.h 197 $(CC) $(DEBUG) $(CFLAGS) $(DFLAGS) -c $(TOP)/ip_auth.c -o $@ 198 199ip_fil.o: $(TOP)/$(IPFILC) $(TOP)/ip_fil.h $(TOP)/ip_compat.h $(TOP)/ip_nat.h 200 $(CC) $(DEBUG) $(CFLAGS) $(DFLAGS) -c $(TOP)/$(IPFILC) -o $@ 201 202ip_log.o: $(TOP)/ip_log.c $(TOP)/ip_compat.h $(TOP)/ip_fil.h 203 $(CC) $(DEBUG) $(CFLAGS) $(DFLAGS) -c $(TOP)/ip_log.c -o $@ 204 205vnode_if.h: $(VNODESHDIR)/vnode_if.sh $(VNODESHDIR)/vnode_if.src 206 mkdir -p ../sys 207 sh $(VNODESHDIR)/vnode_if.sh $(VNODESHDIR)/vnode_if.src 208 if [ -f ../sys/vnode_if.h ] ; then mv ../sys/vnode_if.h .; fi 209 rmdir ../sys 210 211ml_ipl.o: $(TOP)/$(MLD) $(TOP)/ipl.h 212 -/bin/rm -f vnode_if.c 213 $(CC) -I. $(CFLAGS) $(DFLAGS) -c $(TOP)/$(ML) -o $@ 214 215kmem.o: $(TOP)/kmem.c 216 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/kmem.c -o $@ 217 218parse.o: $(TOP)/parse.c $(TOP)/ip_fil.h 219 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/parse.c -o $@ 220 221common.o: $(TOP)/common.c $(TOP)/ip_fil.h 222 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/common.c -o $@ 223 224facpri.o: $(TOP)/facpri.c $(TOP)/facpri.h 225 $(CC) $(DEBUG) $(CFLAGS) -c $(TOP)/facpri.c -o $@ 226 227ipmon: $(TOP)/ipmon.c 228 $(CC) $(DEBUG) $(CFLAGS) $(LOGFAC) $(TOP)/ipmon.c -o $@ $(LIBS) 229 230clean: 231 ${RM} -f *.core *.o ipt fils ipf ipfstat ipftest ipmon if_ipl ipnat \ 232 vnode_if.h $(LKM) ioconf.h *.ko setdef1.c setdef0.c setdefs.h \ 233 y.tab.? lex.yy.c ipfs 234 235 ${MAKE} -f Makefile.ipsend ${MFLAGS} clean 236 -(for i in *; do \ 237 if [ -d $${i} -a -f $${i}/Makefile ] ; then \ 238 cd $${i}; (make clean); cd ..; \ 239 rm $${i}/Makefile $${i}/Makefile.ipsend; \ 240 rmdir $${i}; \ 241 fi \ 242 done) 243 244install: 245 -$(CP) $(TOP)/ip_fil.h /usr/include/netinet/ip_fil.h 246 -$(CHMOD) 444 /usr/include/netinet/ip_fil.h 247 -if [ -d /lkm -a -f if_ipl.o ] ; then \ 248 cp if_ipl.o /lkm; \ 249 fi 250 -if [ -d /modules -a -f ipf.ko ] ; then \ 251 cp ipf.ko /modules; \ 252 fi 253 @for i in ipf:$(SBINDEST) ipfs:$(SBINDEST) ipnat:$(SBINDEST) \ 254 ipfstat:$(SBINDEST) ipftest:$(SBINDEST) ipmon:$(BINDEST); do \ 255 def="`expr $$i : '[^:]*:\(.*\)'`"; \ 256 p="`expr $$i : '\([^:]*\):.*'`"; \ 257 for d in $(SEARCHDIRS); do \ 258 if [ -f $$d/$$p ] ; then \ 259 echo "$(INSTALL) -cs -g wheel -m 755 -o root $$p $$d"; \ 260 $(INSTALL) -cs -g wheel -m 755 -o root $$p $$d; \ 261 dd=$$d; \ 262 fi; \ 263 done; \ 264 if [ -z "$$dd" ] ; then \ 265 echo $(INSTALL) -cs -g wheel -m 755 -o root $$p $$def; \ 266 $(INSTALL) -cs -g wheel -m 755 -o root $$p $$def; \ 267 fi \ 268 done 269 (cd $(TOP)/man; make INSTALL=$(INSTALL) MANDIR=$(MANDIR) install; cd $(TOP)) 270