#
+# $Id: Makefile 11277 2012-06-10 17:44:15Z marta $
+#
# 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
XOSARCH := $(shell uname)
OSARCH ?= $(XOSARCH)
-$(warning Building userland ipfw for $(VER) $(OSARCH))
+OSARCH := $(shell uname)
+OSARCH := $(findstring $(OSARCH),FreeBSD Linux Darwin)
+ifeq ($(OSARCH),)
+ OSARCH := Windows
+endif
-# utility to figure if gcc has a given option
-#################### extract from Kbuild.include
-# try-run
-# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
-# Exit code chooses option. "$$TMP" is can be used as temporary file and
-# is automatically cleaned up.
-try-run = $(shell set -e; \
- TMP="$(TMPOUT).$$$$.tmp"; \
- TMPO="$(TMPOUT).$$$$.o"; \
- if ($(1)) >/dev/null 2>&1; \
- then echo "$(2)"; \
- else echo "$(3)"; \
- fi; \
- rm -f "$$TMP" "$$TMPO")
-
-# cc-option
-# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
-
-cc-option = $(call try-run,\
- $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2))
-####################
+$(warning Building userland ipfw for $(VER) $(OSARCH))
#TCC=c:/tesi/tcc
ifeq ($(OSARCH),Linux)
EXTRA_CFLAGS += -D__BSD_VISIBLE
EXTRA_CFLAGS += -Werror
- EXTRA_CFLAGS += $(call cc-option, -Wno-unused-but-set-variable)
-else # must be Cygwin ?
+ # 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 .
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
CFLAGS += -I$(USRDIR)/include
LDFLAGS += -L$(USRDIR)/lib
else
- LDFLAGS += -L. -lws2_32
+ LDFLAGS += -L. -L$(TCC)/lib -lws2_32
endif
OBJS = ipfw2.o dummynet.o main.o ipv6.o qsort_r.o