|
| 1 | +# gnu Makefile to build a userland version of the |
| 2 | +# kernel code for ipfw+dummynet |
| 3 | +# |
| 4 | +# The kernel code is compiled with appropriate flags to make |
| 5 | +# it see a kernel-like environment. |
| 6 | +# The userland emulation code is compiler with regular flags. |
| 7 | + |
| 8 | +# M is the current directory, used in recursive builds |
| 9 | +# so we allow it to be overridden |
| 10 | +include ../Makefile.inc |
| 11 | +VPATH = ../extra:../sys/netpfil/ipfw:../sys/netinet:../sys/net |
| 12 | +M ?= $(shell pwd) |
| 13 | +OBJPATH = $(M)/../$(OBJDIR) |
| 14 | + |
| 15 | +ifeq ($(OSARCH),Darwin) |
| 16 | + CFLAGS2 += -D__BSD_VISIBLE |
| 17 | + EFILES_. += libutil.h |
| 18 | + EFILES_sys += condvar.h priv.h _lock.h rmlock.h |
| 19 | + EFILES_machine += in_cksum.h |
| 20 | + EFILES_netinet += ip_carp.h pim.h sctp.h |
| 21 | + EFILES_net += netisr.h vnet.h |
| 22 | +endif |
| 23 | + |
| 24 | +ifeq ($(OSARCH),Linux) |
| 25 | + CFLAGS2 += -D__BSD_VISIBLE |
| 26 | + CFLAGS2 += -include ../extra/linux_defs.h |
| 27 | + CFLAGS2 += -Wno-unused-but-set-variable |
| 28 | + EFILES_. += libutil.h |
| 29 | + EFILES_sys += condvar.h priv.h _lock.h rmlock.h |
| 30 | + EFILES_sys += lock.h ucred.h # taskqueue.h |
| 31 | + EFILES_sys += sockio.h |
| 32 | + EFILES_machine += in_cksum.h |
| 33 | + EFILES_netinet += in_pcb.h ip_carp.h pim.h sctp.h tcp_var.h |
| 34 | + EFILES_net += if_types.h bpf.h netisr.h vnet.h |
| 35 | + EFILES_linux += module.h |
| 36 | +endif |
| 37 | + |
| 38 | +ifeq ($(OSARCH),Windows) |
| 39 | + CFLAGS2 += -D__BSD_VISIBLE |
| 40 | +# CFLAGS2 += -include ../extra/linux_defs.h |
| 41 | + CFLAGS2 += -Wno-unused-but-set-variable |
| 42 | +# EFILES_. += libutil.h |
| 43 | +# EFILES_sys += condvar.h priv.h _lock.h rmlock.h |
| 44 | +# EFILES_sys += lock.h ucred.h # taskqueue.h |
| 45 | +# EFILES_sys += sockio.h |
| 46 | +# EFILES_machine += in_cksum.h |
| 47 | +# EFILES_netinet += in_pcb.h ip_carp.h pim.h sctp.h tcp_var.h |
| 48 | +# EFILES_net += if_types.h bpf.h netisr.h vnet.h |
| 49 | +# EFILES_linux += module.h |
| 50 | + EFILES_sys += sockio.h |
| 51 | + EFILES_net += ethernet.h |
| 52 | + EFILES_sys += condvar.h priv.h socketvar.h ucred.h |
| 53 | + EFILES_net += vnet.h |
| 54 | + EFILES_netinet += in_pcb.h ip_carp.h pim.h sctp.h tcp_var.h |
| 55 | +endif |
| 56 | + |
| 57 | +NETMAP_FLAGS = -DWITH_NETMAP -I$(NETMAP_INC) |
| 58 | + |
| 59 | +E_CFLAGS += $(INCDIRS) |
| 60 | +E_CFLAGS += -include $(M)/../extra/glue.h # headers |
| 61 | +E_CFLAGS += -include $(M)/../extra/missing.h # headers |
| 62 | +E_CFLAGS += -O2 -Wall -Werror -fno-strict-aliasing |
| 63 | +E_CFLAGS += -g |
| 64 | +E_CFLAGS += -DKERNEL_SIDE # build the kernel side of the firewall |
| 65 | +E_CFLAGS += -DUSERSPACE # communicate through userspace |
| 66 | +E_CFLAGS += $(EFLAGS) $(NETMAP_FLAGS) |
| 67 | +E_CFLAGS += -DINET |
| 68 | +E_CFLAGS += -DIPFIREWALL_DEFAULT_TO_ACCEPT |
| 69 | +E_CFLAGS += -D_BSD_SOURCE |
| 70 | +# many of the kernel headers need _KERNEL |
| 71 | +E_CFLAGS += -D_KERNEL |
| 72 | +E_CFLAGS += $(CFLAGS2) |
| 73 | + |
| 74 | +#ipfw + dummynet section, other parts are not compiled in |
| 75 | +SRCS_IPFW = ip_fw2.c ip_fw_pfil.c ip_fw_sockopt.c |
| 76 | +SRCS_IPFW += ip_fw_dynamic.c ip_fw_table.c |
| 77 | +SRCS_IPFW += ip_fw_log.c |
| 78 | +SRCS_IPFW += ip_dummynet.c ip_dn_io.c ip_dn_glue.c |
| 79 | +SRCS_IPFW += dn_heap.c |
| 80 | +SRCS_IPFW += dn_sched_fifo.c dn_sched_wf2q.c |
| 81 | +SRCS_IPFW += dn_sched_rr.c dn_sched_qfq.c |
| 82 | +SRCS_IPFW += dn_sched_prio.c |
| 83 | +SRCS_NET = radix.c |
| 84 | +SRCS_NETINET = in_cksum.c |
| 85 | +# Module glue and functions missing in linux |
| 86 | +IPFW_SRCS = $(SRCS_IPFW) $(SRCS_NET) $(SRCS_NETINET) |
| 87 | +IPFW_SRCS += ipfw2_mod.c # bsd_compat.c |
| 88 | + |
| 89 | +IPFW_SRCS += missing.c session.c netmap_io.c |
| 90 | +IPFW_CFLAGS= -DINET |
| 91 | + |
| 92 | +E_CFLAGS += -Dradix |
| 93 | +MOD := kipfw |
| 94 | + |
| 95 | +LIBS= -lpthread |
| 96 | +CFLAGS = $(E_CFLAGS) |
| 97 | + |
| 98 | +IPFW_OBJS= $(IPFW_SRCS:%.c=%.o) |
| 99 | + |
| 100 | +all: include_e $(MOD) |
| 101 | + |
| 102 | +# entries to create empty files |
| 103 | +EFILES_. += opt_inet.h opt_ipsec.h opt_ipdivert.h |
| 104 | +EFILES_. += opt_inet6.h opt_ipfw.h opt_mpath.h |
| 105 | +EFILES_. += opt_mbuf_stress_test.h opt_param.h |
| 106 | +EFILES_. += timeconv.h |
| 107 | + |
| 108 | +EFILES_altq += if_altq.h |
| 109 | + |
| 110 | +EFILES_net += if_var.h route.h if_clone.h |
| 111 | +EFILES_netpfil/pf += pf_mtag.h |
| 112 | +EFILES_netinet += in_var.h ip_var.h udp_var.h |
| 113 | +EFILES_netinet6 += ip6_var.h |
| 114 | +EFILES_sys += proc.h sockopt.h sysctl.h |
| 115 | +# new |
| 116 | +EFILES_sys += mutex.h _mutex.h _rwlock.h rwlock.h |
| 117 | +EFILES_sys += eventhandler.h |
| 118 | +EFILES_sys += jail.h ktr.h |
| 119 | + |
| 120 | +#EFILES += sys/_lock.h sys/_rwlock.h sys/rwlock.h sys/rmlock.h sys/_mutex.h sys/mutex.h |
| 121 | +#EFILES += sys/condvar.h sys/eventhandler.h # sys/domain.h |
| 122 | +#EFILES += sys/limits.h sys/lock.h sys/mutex.h sys/priv.h |
| 123 | +#EFILES += sys/proc.h sys/rwlock.h sys/socket.h sys/socketvar.h |
| 124 | +#EFILES += sys/sysctl.h sys/time.h sys/ucred.h |
| 125 | + |
| 126 | + |
| 127 | +#EFILES += vm/uma_int.h vm/vm_int.h vm/uma_dbg.h |
| 128 | +#EFILES += vm/vm_dbg.h vm/vm_page.h vm/vm.h |
| 129 | +#EFILES += sys/rwlock.h sys/sysctl.h |
| 130 | + |
| 131 | +# first make a list of directories from variable names |
| 132 | +EDIRS= $(subst EFILES_,,$(filter EFILES_%,$(.VARIABLES))) |
| 133 | +# then prepend the directory name to individual files. |
| 134 | +# $(empty) serves to interpret the following space literally, |
| 135 | +# and the ": = " substitution packs spaces into one. |
| 136 | +EFILES = $(foreach i,$(EDIRS),$(subst $(empty) , $(i)/, $(EFILES_$(i): = ))) |
| 137 | + |
| 138 | +include_e: |
| 139 | + -@echo "Building $(OBJPATH)/include_e ..." |
| 140 | + -$(HIDE) rm -rf $(OBJPATH)/include_e opt_* |
| 141 | + -$(HIDE) mkdir -p $(OBJPATH)/include_e |
| 142 | + -$(HIDE) (cd $(OBJPATH)/include_e; mkdir -p $(EDIRS); touch $(EFILES) ) |
| 143 | + |
| 144 | + |
| 145 | +$(IPFW_OBJS) : ../extra/glue.h |
| 146 | + |
| 147 | +ip_fw2.o ip_dummynet.o: # EFLAGS= -include missing.h |
| 148 | + |
| 149 | +radix.o:# CFLAGS += -U_KERNEL |
| 150 | + |
| 151 | +# session.o: CFLAGS = -O2 |
| 152 | +nm_util.o: CFLAGS = -O2 -Wall -Werror $(NETMAP_FLAGS) |
| 153 | + |
| 154 | +$(MOD): $(IPFW_OBJS) |
| 155 | + $(MSG) " LD $@" |
| 156 | + $(HIDE)$(CC) -o $@ $^ $(LIBS) |
| 157 | + |
| 158 | +clean: |
| 159 | + -rm -f *.o $(DN) $(MOD) |
| 160 | + -rm -rf include_e |
| 161 | + |
| 162 | +diff: |
| 163 | + @-(for i in $(SRCS_IPFW) ; do diff -ubw $(BSD_HEAD)/sys/netpfil/ipfw/$$i .; done) |
| 164 | + @-(for i in $(SRCS_NET) ; do diff -ubw $(BSD_HEAD)/sys/net/$$i . ; done) |
| 165 | + @-(for i in $(SRCS_NETINET) ; do diff -ubw $(BSD_HEAD)/sys/netinet/$$i .; done) |
0 commit comments