This repo is obsolete, please see git://git.code.sf.net/p/dummynet/code@master
[ipfw.git] / ipfw / Makefile
1 #
2 # $Id: Makefile 11277 2012-06-10 17:44:15Z marta $
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 OSARCH := $(shell uname)
11 OSARCH := $(findstring $(OSARCH),FreeBSD Linux Darwin)
12 ifeq ($(OSARCH),)
13     OSARCH := Windows
14 endif
15
16 $(warning Building userland ipfw for $(VER) $(OSARCH))
17
18 #TCC=c:/tesi/tcc
19
20 # common flags
21 EXTRA_CFLAGS += -O1
22 EXTRA_CFLAGS += -Wall
23 EXTRA_CFLAGS += -include ../glue.h
24 EXTRA_CFLAGS += -I ./include_e -I ./include
25
26 TARGET := ipfw
27 ifneq ($(VER),openwrt)
28 ifeq ($(OSARCH),Linux)
29     EXTRA_CFLAGS += -D__BSD_VISIBLE
30     EXTRA_CFLAGS += -Werror
31     # Required by GCC 4.6
32     EXTRA_CFLAGS += -Wno-unused-but-set-variable
33 endif
34 ifeq ($(OSARCH),FreeBSD)
35     EXTRA_CFLAGS += -D__BSD_VISIBLE
36     EXTRA_CFLAGS += -Werror
37 endif
38 ifeq ($(OSARCH),Darwin)
39     EXTRA_CFLAGS += -D__BSD_VISIBLE
40     EXTRA_CFLAGS += -Werror
41 endif
42 # must be Cygwin ?
43 ifeq ($(OSARCH),Windows)
44 ifeq ($(TCC),)
45     EXTRA_CFLAGS += -I/cygdrive/c/WinDDK/7600.16385.0/inc/ddk
46     EXTRA_CFLAGS += -I .
47     EXTRA_CFLAGS += -pipe -Wall
48 else
49     # TCC points to the root of tcc tree
50     CC=$(TCC)/tcc.exe
51     EXTRA_CFLAGS += -DTCC -I..
52     EXTRA_CFLAGS += -I$(TCC)/include/winapi -I$(TCC)/include
53     EXTRA_CFLAGS += -nostdinc
54
55     EDIRS  += arpa net netinet sys
56     EFILES += err.h grp.h netdb.h pwd.h sysexits.h
57     EFILES += arpa/inet.h
58     EFILES += net/if.h
59     EFILES += netinet/in.h netinet/in_systm.h netinet/ip.h
60     EFILES += netinet/ip_icmp.h
61     EFILES += sys/cdefs.h sys/wait.h
62     EFILES += sys/ioctl.h sys/socket.h
63
64 endif
65     # EXTRA_CFLAGS += -D_WIN32 # see who defines it
66     EXTRA_CFLAGS += -Dsetsockopt=wnd_setsockopt
67     EXTRA_CFLAGS += -Dgetsockopt=wnd_getsockopt
68     EXTRA_CFLAGS += -DEMULATE_SYSCTL
69     EDIRS  += net netinet
70     EFILES += net/ethernet.h net/route.h
71     EFILES += netinet/ether.h netinet/icmp6.h
72     EFILES += sys/sysctl.h
73     TARGET := ipfw.exe
74 endif
75 endif # !openwrt
76
77 CFLAGS += $(EXTRA_CFLAGS)
78 # Location of OS headers and libraries. After our stuff.
79 USRDIR?= /usr
80 ifeq ($(TCC),)
81     CFLAGS += -I$(USRDIR)/include
82     LDFLAGS += -L$(USRDIR)/lib
83 else
84     LDFLAGS += -L. -L$(TCC)/lib -lws2_32
85 endif
86
87 OBJS = ipfw2.o dummynet.o main.o ipv6.o qsort_r.o
88 OBJS += expand_number.o humanize_number.o glue.o
89
90 # we don't use ALTQ
91 CFLAGS += -DNO_ALTQ
92 #OBJS += altq.o
93
94 all: $(TARGET)
95         echo "Done build for $(OSARCH) VER $(VER)"
96
97 $(TARGET): $(OBJS)
98         $(CC) $(LDFLAGS) -o $@ $^
99
100 $(OBJS) : ipfw2.h ../glue.h include_e
101
102 # support to create empty dirs and files in include_e/
103 # EDIRS is the list of directories, EFILES is the list of files.
104 EDIRS   += sys netinet
105 EFILES  += sys/sockio.h libutil.h
106
107 M ?= $(shell pwd)
108
109 include_e:
110         echo "running in $M"
111         -@rm -rf $(M)/include_e opt_*
112         -@mkdir -p $(M)/include_e
113         -@(cd $(M)/include_e; mkdir -p $(EDIRS); touch $(EFILES) )
114         -@(cd $(M)/include_e/netinet; \
115                 for i in ip_fw.h ip_dummynet.h tcp.h; do \
116                 cp ../../../dummynet2/include/netinet/$$i .; done; )
117
118 clean distclean:
119         -rm -f $(OBJS) $(TARGET)
120         -rm -rf include/netinet/ include_e