Sync with the new ipfw3 version.
[ipfw.git] / ipfw / Makefile
1 #
2 # $Id$
3 #
4 # GNUMakefile to build the userland part of ipfw on Linux and Windows
5 #
6 # enable extra debugging information
7 # Do not set with = or := so we can inherit from the caller
8 XOSARCH := $(shell uname)
9 OSARCH ?= $(XOSARCH)
10 $(warning Building userland ipfw for $(VER) $(OSARCH))
11
12 #TCC=c:/tesi/tcc
13
14 # common flags
15 EXTRA_CFLAGS += -O1
16 EXTRA_CFLAGS += -Wall
17 EXTRA_CFLAGS += -include ../glue.h
18 EXTRA_CFLAGS += -I ./include_e -I ./include
19
20 TARGET := ipfw
21 ifneq ($(VER),openwrt)
22 ifeq ($(OSARCH),Linux)
23     EXTRA_CFLAGS += -D__BSD_VISIBLE
24     EXTRA_CFLAGS += -Werror
25 else # must be Cygwin ?
26 ifeq ($(TCC),)
27     EXTRA_CFLAGS += -I/cygdrive/c/WinDDK/7600.16385.0/inc/ddk
28     EXTRA_CFLAGS += -I .
29     EXTRA_CFLAGS += -pipe -Wall
30 else
31     # TCC points to the root of tcc tree
32     CC=$(TCC)/tcc.exe
33     EXTRA_CFLAGS += -DTCC -I..
34     EXTRA_CFLAGS += -I$(TCC)/include/winapi -I$(TCC)/include
35     EXTRA_CFLAGS += -nostdinc
36
37     EDIRS  += arpa net netinet sys
38     EFILES += err.h grp.h netdb.h pwd.h sysexits.h
39     EFILES += arpa/inet.h
40     EFILES += net/if.h
41     EFILES += netinet/in.h netinet/in_systm.h netinet/ip.h
42     EFILES += netinet/ip_icmp.h
43     EFILES += sys/cdefs.h sys/wait.h
44     EFILES += sys/ioctl.h sys/socket.h
45 endif
46     # EXTRA_CFLAGS += -D_WIN32 # see who defines it
47     EXTRA_CFLAGS += -Dsetsockopt=wnd_setsockopt
48     EXTRA_CFLAGS += -Dgetsockopt=wnd_getsockopt
49     EXTRA_CFLAGS += -DEMULATE_SYSCTL
50     EDIRS  += net netinet
51     EFILES += net/ethernet.h net/route.h
52     EFILES += netinet/ether.h netinet/icmp6.h
53     EFILES += sys/sysctl.h
54     TARGET := ipfw.exe
55 endif
56 endif # !openwrt
57
58 CFLAGS += $(EXTRA_CFLAGS)
59 # Location of OS headers and libraries. After our stuff.
60 USRDIR?= /usr
61 ifeq ($(TCC),)
62     CFLAGS += -I$(USRDIR)/include
63     LDFLAGS += -L$(USRDIR)/lib
64 else
65     LDFLAGS += -L. -lws2_32
66 endif
67
68 OBJS = ipfw2.o dummynet.o main.o ipv6.o qsort_r.o
69 OBJS += expand_number.o humanize_number.o glue.o
70
71 # we don't use ALTQ
72 CFLAGS += -DNO_ALTQ
73 #OBJS += altq.o
74
75 all: $(TARGET)
76         echo "Done build for $(OSARCH) VER $(VER)"
77
78 $(TARGET): $(OBJS)
79         $(CC) $(LDFLAGS) -o $@ $^
80
81 $(OBJS) : ipfw2.h ../glue.h include_e
82
83 # support to create empty dirs and files in include_e/
84 # EDIRS is the list of directories, EFILES is the list of files.
85 EDIRS   += sys netinet
86 EFILES  += sys/sockio.h libutil.h
87
88 M ?= $(shell pwd)
89
90 include_e:
91         echo "running in $M"
92         -@rm -rf $(M)/include_e opt_*
93         -@mkdir -p $(M)/include_e
94         -@(cd $(M)/include_e; mkdir -p $(EDIRS); touch $(EFILES) )
95         -@(cd $(M)/include_e/netinet; \
96                 for i in ip_fw.h ip_dummynet.h tcp.h; do \
97                 cp ../../../dummynet2/include/netinet/$$i .; done; )
98
99 clean distclean:
100         -rm -f $(OBJS) $(TARGET)
101         -rm -rf include/netinet/ include_e