2 # $Id: Makefile 11277 2012-06-10 17:44:15Z marta $
4 # GNUMakefile to build the userland part of ipfw on Linux and Windows
6 # enable extra debugging information
7 # Do not set with = or := so we can inherit from the caller
8 XOSARCH := $(shell uname)
10 OSARCH := $(shell uname)
11 OSARCH := $(findstring $(OSARCH),FreeBSD Linux Darwin)
16 $(warning Building userland ipfw for $(VER) $(OSARCH))
23 EXTRA_CFLAGS += -include ../glue.h
24 EXTRA_CFLAGS += -I ./include_e -I ./include
27 ifneq ($(VER),openwrt)
28 ifeq ($(OSARCH),Linux)
29 EXTRA_CFLAGS += -D__BSD_VISIBLE
30 EXTRA_CFLAGS += -Werror
32 EXTRA_CFLAGS += -Wno-unused-but-set-variable
34 ifeq ($(OSARCH),FreeBSD)
35 EXTRA_CFLAGS += -D__BSD_VISIBLE
36 EXTRA_CFLAGS += -Werror
38 ifeq ($(OSARCH),Darwin)
39 EXTRA_CFLAGS += -D__BSD_VISIBLE
40 EXTRA_CFLAGS += -Werror
43 ifeq ($(OSARCH),Windows)
45 EXTRA_CFLAGS += -I/cygdrive/c/WinDDK/7600.16385.0/inc/ddk
47 EXTRA_CFLAGS += -pipe -Wall
49 # TCC points to the root of tcc tree
51 EXTRA_CFLAGS += -DTCC -I..
52 EXTRA_CFLAGS += -I$(TCC)/include/winapi -I$(TCC)/include
53 EXTRA_CFLAGS += -nostdinc
55 EDIRS += arpa net netinet sys
56 EFILES += err.h grp.h netdb.h pwd.h sysexits.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
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
70 EFILES += net/ethernet.h net/route.h
71 EFILES += netinet/ether.h netinet/icmp6.h
72 EFILES += sys/sysctl.h
77 CFLAGS += $(EXTRA_CFLAGS)
78 # Location of OS headers and libraries. After our stuff.
81 CFLAGS += -I$(USRDIR)/include
82 LDFLAGS += -L$(USRDIR)/lib
84 LDFLAGS += -L. -L$(TCC)/lib -lws2_32
87 OBJS = ipfw2.o dummynet.o main.o ipv6.o qsort_r.o
88 OBJS += expand_number.o humanize_number.o glue.o
95 echo "Done build for $(OSARCH) VER $(VER)"
98 $(CC) $(LDFLAGS) -o $@ $^
100 $(OBJS) : ipfw2.h ../glue.h include_e
102 # support to create empty dirs and files in include_e/
103 # EDIRS is the list of directories, EFILES is the list of files.
105 EFILES += sys/sockio.h libutil.h
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; )
119 -rm -f $(OBJS) $(TARGET)
120 -rm -rf include/netinet/ include_e