X-Git-Url: http://git.onelab.eu/?p=ipfw.git;a=blobdiff_plain;f=ipfw%2FMakefile;h=4800b4a86ffae7beadee49ec387e74abf895e3b7;hp=a8a4f474a1492544f0c17840eeb1363186c37e26;hb=HEAD;hpb=5f337135c613b2ee3cb24ade7617ecaae0a74681 diff --git a/ipfw/Makefile b/ipfw/Makefile index a8a4f47..4800b4a 100644 --- a/ipfw/Makefile +++ b/ipfw/Makefile @@ -1,45 +1,120 @@ # -# $Id$ +# $Id: Makefile 11277 2012-06-10 17:44:15Z marta $ # -# GNUMakefile to build the userland part of ipfw on Linux +# GNUMakefile to build the userland part of ipfw on Linux and Windows # # enable extra debugging information # Do not set with = or := so we can inherit from the caller -$(warning Building userland ipfw for $(VER)) -EXTRA_CFLAGS += -EXTRA_CFLAGS += -O1 -EXTRA_CFLAGS += -include ../glue.h +XOSARCH := $(shell uname) +OSARCH ?= $(XOSARCH) +OSARCH := $(shell uname) +OSARCH := $(findstring $(OSARCH),FreeBSD Linux Darwin) +ifeq ($(OSARCH),) + OSARCH := Windows +endif + +$(warning Building userland ipfw for $(VER) $(OSARCH)) -LDFLAGS= +#TCC=c:/tesi/tcc -EXTRA_CFLAGS += -I ./include +# common flags +EXTRA_CFLAGS += -O1 +EXTRA_CFLAGS += -Wall +EXTRA_CFLAGS += -include ../glue.h +EXTRA_CFLAGS += -I ./include_e -I ./include +TARGET := ipfw ifneq ($(VER),openwrt) -OSARCH := $(shell uname) ifeq ($(OSARCH),Linux) EXTRA_CFLAGS += -D__BSD_VISIBLE + EXTRA_CFLAGS += -Werror + # Required by GCC 4.6 + EXTRA_CFLAGS += -Wno-unused-but-set-variable +endif +ifeq ($(OSARCH),FreeBSD) + EXTRA_CFLAGS += -D__BSD_VISIBLE + EXTRA_CFLAGS += -Werror +endif +ifeq ($(OSARCH),Darwin) + EXTRA_CFLAGS += -D__BSD_VISIBLE + EXTRA_CFLAGS += -Werror +endif +# must be Cygwin ? +ifeq ($(OSARCH),Windows) +ifeq ($(TCC),) + EXTRA_CFLAGS += -I/cygdrive/c/WinDDK/7600.16385.0/inc/ddk + EXTRA_CFLAGS += -I . + EXTRA_CFLAGS += -pipe -Wall else - HAVE_NAT := $(shell grep O_NAT /usr/include/netinet/ip_fw.h) - # EXTRA_CFLAGS += ... + # TCC points to the root of tcc tree + CC=$(TCC)/tcc.exe + EXTRA_CFLAGS += -DTCC -I.. + EXTRA_CFLAGS += -I$(TCC)/include/winapi -I$(TCC)/include + EXTRA_CFLAGS += -nostdinc + + EDIRS += arpa net netinet sys + EFILES += err.h grp.h netdb.h pwd.h sysexits.h + EFILES += arpa/inet.h + EFILES += net/if.h + EFILES += netinet/in.h netinet/in_systm.h netinet/ip.h + EFILES += netinet/ip_icmp.h + EFILES += sys/cdefs.h sys/wait.h + EFILES += sys/ioctl.h sys/socket.h + +endif + # EXTRA_CFLAGS += -D_WIN32 # see who defines it + EXTRA_CFLAGS += -Dsetsockopt=wnd_setsockopt + EXTRA_CFLAGS += -Dgetsockopt=wnd_getsockopt + EXTRA_CFLAGS += -DEMULATE_SYSCTL + EDIRS += net netinet + EFILES += net/ethernet.h net/route.h + EFILES += netinet/ether.h netinet/icmp6.h + EFILES += sys/sysctl.h + TARGET := ipfw.exe endif endif # !openwrt CFLAGS += $(EXTRA_CFLAGS) - -OBJS = ipfw2.o dummynet.o main.o ipv6.o altq.o -ifneq ($(HAVE_NAT),) - OBJS += nat.o - EXTRA_CFLAGS += -DHAVE_NAT +# Location of OS headers and libraries. After our stuff. +USRDIR?= /usr +ifeq ($(TCC),) + CFLAGS += -I$(USRDIR)/include + LDFLAGS += -L$(USRDIR)/lib +else + LDFLAGS += -L. -L$(TCC)/lib -lws2_32 endif -OBJS += glue.o -all: ipfw - echo "VER is $(VER)" +OBJS = ipfw2.o dummynet.o main.o ipv6.o qsort_r.o +OBJS += expand_number.o humanize_number.o glue.o -ipfw: $(OBJS) +# we don't use ALTQ +CFLAGS += -DNO_ALTQ +#OBJS += altq.o + +all: $(TARGET) + echo "Done build for $(OSARCH) VER $(VER)" + +$(TARGET): $(OBJS) $(CC) $(LDFLAGS) -o $@ $^ -$(OBJS) : ipfw2.h ../glue.h +$(OBJS) : ipfw2.h ../glue.h include_e + +# support to create empty dirs and files in include_e/ +# EDIRS is the list of directories, EFILES is the list of files. +EDIRS += sys netinet +EFILES += sys/sockio.h libutil.h + +M ?= $(shell pwd) + +include_e: + echo "running in $M" + -@rm -rf $(M)/include_e opt_* + -@mkdir -p $(M)/include_e + -@(cd $(M)/include_e; mkdir -p $(EDIRS); touch $(EFILES) ) + -@(cd $(M)/include_e/netinet; \ + for i in ip_fw.h ip_dummynet.h tcp.h; do \ + cp ../../../dummynet2/include/netinet/$$i .; done; ) clean distclean: - -rm -f $(OBJS) ipfw + -rm -f $(OBJS) $(TARGET) + -rm -rf include/netinet/ include_e