remove duplicate entry
[ipfw-google.git] / ipfw / Makefile
1 #
2 # $Id: Makefile 11688 2012-08-12 20:58:26Z luigi $
3 #
4 # GNUMakefile to build the userland part of ipfw on Linux and Windows
5 #
6 # Do not set with = or := so we can inherit from the caller
7
8 include ../Makefile.inc
9 TARGET := ipfw
10
11 all: $(TARGET)
12
13 #TCC=c:/path/to/tcc
14
15 # common flags
16 EXTRA_CFLAGS += -O1
17 EXTRA_CFLAGS += -Wall
18 EXTRA_CFLAGS += -include ../glue.h
19 EXTRA_CFLAGS += -I ./include_e -I ./include
20
21 ifneq ($(VER),openwrt)
22 ifeq ($(OSARCH),Linux)
23     EXTRA_CFLAGS += -D__BSD_VISIBLE
24     EXTRA_CFLAGS += -Werror
25     # Required by GCC 4.6
26     EXTRA_CFLAGS += -Wno-unused-but-set-variable
27 endif
28 ifeq ($(OSARCH),FreeBSD)
29     EXTRA_CFLAGS += -D__BSD_VISIBLE
30     EXTRA_CFLAGS += -Werror
31 endif
32 ifeq ($(OSARCH),Darwin)
33     EXTRA_CFLAGS += -D__BSD_VISIBLE
34     EXTRA_CFLAGS += -Werror
35 endif
36
37 ifeq ($(OSARCH),Windows)
38 # we only support Cygwin and tcc as compilers.
39 ifeq ($(WIN64),1)
40     EXTRA_CFLAGS += -D_X64EMU
41 endif
42
43 ifeq ($(TCC),)  # cygwin
44     EXTRA_CFLAGS += -I/cygdrive/c/$(DDKDIR)/inc/ddk
45     EXTRA_CFLAGS += -I .
46     EXTRA_CFLAGS += -pipe -Wall
47 else            #-- build with tcc
48     # TCC points to the root of tcc tree
49     CC=$(TCC)/tcc.exe
50     EXTRA_CFLAGS += -DTCC -I..
51     EXTRA_CFLAGS += -I$(TCC)/include/winapi -I$(TCC)/include
52     EXTRA_CFLAGS += -nostdinc
53
54     EFILES_. += err.h grp.h netdb.h pwd.h sysexits.h
55     EFILES_arpa += inet.h
56     EFILES_net += if.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
59
60 endif
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
68     TARGET = ipfw.exe
69 ipfw: $(TARGET)
70 endif # windows
71 endif # !openwrt
72
73 CFLAGS += $(EXTRA_CFLAGS)
74 # Location of OS headers and libraries. After our stuff.
75 USRDIR?= /usr
76 ifeq ($(TCC),)
77     CFLAGS += -I$(USRDIR)/include
78     LDFLAGS += -L$(USRDIR)/lib
79 else
80     LDFLAGS += -L. -L$(TCC)/lib -lws2_32
81 endif
82
83 OBJS = ipfw2.o dummynet.o main.o ipv6.o qsort_r.o
84 OBJS += expand_number.o humanize_number.o glue.o
85
86 # we don't use ALTQ
87 CFLAGS += -DNO_ALTQ
88 #OBJS += altq.o
89
90
91 $(TARGET): $(OBJS)
92         $(MSG) "   LD  $@"
93         $(HIDE)$(CC) $(LDFLAGS) -o $@ $^
94
95 $(OBJS) : ipfw2.h ../glue.h include_e
96
97 # support to create empty dirs and files in include_e/
98 # EDIRS is the list of directories, EFILES is the list of files.
99 EFILES_sys  += sockio.h
100 EFILES_.    += libutil.h
101 EFILES_netinet += __emtpy.h
102
103 M ?= $(shell pwd)
104
105 # first make a list of directories from variable names
106 EDIRS= $(subst EFILES_,,$(filter EFILES_%,$(.VARIABLES)))
107 # then prepend the directory name to individual files.
108 #       $(empty) serves to interpret the following space literally,
109 #       and the ":  = " substitution packs spaces into one.
110 EFILES = $(foreach i,$(EDIRS),$(subst $(empty) , $(i)/, $(EFILES_$(i):  = )))
111
112 include_e:
113         $(MSG) "building include_e in $M"
114         -@rm -rf $(M)/include_e opt_*
115         -@mkdir -p $(M)/include_e
116         -@(cd $(M)/include_e; mkdir -p $(EDIRS); touch $(EFILES) )
117         -@(cd $(M)/include_e/netinet; \
118                 for i in ip_fw.h ip_dummynet.h tcp.h; do \
119                 cp ../../../sys/netinet/$$i .; done; )
120
121 clean distclean:
122         -@rm -rf $(OBJS) $(TARGET) include_e
123
124 diff:
125         -@(diff -upr $(BSD_HEAD)/sbin/ipfw .)
126