2 # $Id: Makefile 11688 2012-08-12 20:58:26Z luigi $
4 # GNUMakefile to build the userland part of ipfw on Linux and Windows
6 # Do not set with = or := so we can inherit from the caller
8 include ../Makefile.inc
18 EXTRA_CFLAGS += -include ../glue.h
19 EXTRA_CFLAGS += -I ./include_e -I ./include
21 ifneq ($(VER),openwrt)
22 ifeq ($(OSARCH),Linux)
23 EXTRA_CFLAGS += -D__BSD_VISIBLE
24 EXTRA_CFLAGS += -Werror
26 EXTRA_CFLAGS += -Wno-unused-but-set-variable
28 ifeq ($(OSARCH),FreeBSD)
29 EXTRA_CFLAGS += -D__BSD_VISIBLE
30 EXTRA_CFLAGS += -Werror
32 ifeq ($(OSARCH),Darwin)
33 EXTRA_CFLAGS += -D__BSD_VISIBLE
34 EXTRA_CFLAGS += -Werror
37 ifeq ($(OSARCH),Windows)
38 # we only support Cygwin and tcc as compilers.
40 EXTRA_CFLAGS += -D_X64EMU
43 ifeq ($(TCC),) # cygwin
44 EXTRA_CFLAGS += -I/cygdrive/c/$(DDKDIR)/inc/ddk
46 EXTRA_CFLAGS += -pipe -Wall
47 else #-- build with tcc
48 # TCC points to the root of tcc tree
50 EXTRA_CFLAGS += -DTCC -I..
51 EXTRA_CFLAGS += -I$(TCC)/include/winapi -I$(TCC)/include
52 EXTRA_CFLAGS += -nostdinc
54 EFILES_. += err.h grp.h netdb.h pwd.h sysexits.h
57 EFILES_netinet += in.h in_systm.h ip.h ip_icmp.h
58 EFILES_sys += cdefs.h wait.h ioctl.h socket.h
61 # EXTRA_CFLAGS += -D_WIN32 # see who defines it
62 EXTRA_CFLAGS += -Dsetsockopt=wnd_setsockopt
63 EXTRA_CFLAGS += -Dgetsockopt=wnd_getsockopt
64 EXTRA_CFLAGS += -DEMULATE_SYSCTL
65 EFILES_net += ethernet.h route.h
66 EFILES_netinet += ether.h icmp6.h
67 EFILES_sys += sysctl.h
73 CFLAGS += $(EXTRA_CFLAGS)
74 # Location of OS headers and libraries. After our stuff.
77 CFLAGS += -I$(USRDIR)/include
78 LDFLAGS += -L$(USRDIR)/lib
80 LDFLAGS += -L. -L$(TCC)/lib -lws2_32
83 OBJS = ipfw2.o dummynet.o main.o ipv6.o qsort_r.o
84 OBJS += expand_number.o humanize_number.o glue.o
91 -@echo "Done build for $(OSARCH)"
95 $(HIDE)$(CC) $(LDFLAGS) -o $@ $^
97 $(OBJS) : ipfw2.h ../glue.h include_e
99 # support to create empty dirs and files in include_e/
100 # EDIRS is the list of directories, EFILES is the list of files.
101 EFILES_sys += sockio.h
102 EFILES_. += libutil.h
103 EFILES_netinet += __emtpy.h
107 # first make a list of directories from variable names
108 EDIRS= $(subst EFILES_,,$(filter EFILES_%,$(.VARIABLES)))
109 # then prepend the directory name to individual files.
110 # $(empty) serves to interpret the following space literally,
111 # and the ": = " substitution packs spaces into one.
112 EFILES = $(foreach i,$(EDIRS),$(subst $(empty) , $(i)/, $(EFILES_$(i): = )))
115 $(MSG) "building include_e in $M"
116 -@rm -rf $(M)/include_e opt_*
117 -@mkdir -p $(M)/include_e
118 -@(cd $(M)/include_e; mkdir -p $(EDIRS); touch $(EFILES) )
119 -@(cd $(M)/include_e/netinet; \
120 for i in ip_fw.h ip_dummynet.h tcp.h; do \
121 cp ../../../sys/netinet/$$i .; done; )
124 -@rm -rf $(OBJS) $(TARGET) include_e
127 -@(diff -upr $(BSD_HEAD)/sbin/ipfw .)