1#
2# IPTABLES Makefile
3#
4# Copyright (C) 2012, Broadcom Corporation. All Rights Reserved.
5# 
6# Permission to use, copy, modify, and/or distribute this software for any
7# purpose with or without fee is hereby granted, provided that the above
8# copyright notice and this permission notice appear in all copies.
9# 
10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17#
18# $Id: $
19#
20
21include ../.config
22
23HERE := $(shell pwd)
24IPTABLES_SRC = src
25IPTLIB_DIR=$(IPTABLES_SRC)/libiptc/.libs
26
27
28DIRS := ${IPTABLES_SRC}
29IPT_INSTALL_DIR=$(INSTALLDIR)/usr
30
31
32ifeq ($(CONFIG_IPV6),y)
33DOIPV6=1
34else
35DOIPV6=0
36endif
37
38
39.PHONY: all
40all: iptables
41
42.PHONY: configure
43ifeq ($(LINUX_VERSION),2_6_36)
44ifeq ($(CONFIG_IPV6),y)
45configure:
46	[ -f $(IPTABLES_SRC)/Makefile ] || \
47	(cd $(IPTABLES_SRC); \
48	 CC=$(CC) ./configure \
49	    --target=$(PLATFORM)-linux \
50	    --host=$(PLATFORM)-linux \
51	    --build=`/bin/arch`-linux \
52	    --with-kernel=$(KERNEL_DIR) \
53	    --prefix=$(HERE)/$(IPTABLES_SRC)/install \
54	    PKG_CONFIG=/bin/false)
55else # disable ipv6
56configure:
57	[ -f $(IPTABLES_SRC)/Makefile ] || \
58	(cd $(IPTABLES_SRC); \
59	 CC=$(CC) ./configure \
60	    --target=$(PLATFORM)-linux \
61	    --host=$(PLATFORM)-linux \
62	    --build=`/bin/arch`-linux \
63	    --with-kernel=$(KERNEL_DIR) \
64	    --prefix=$(HERE)/$(IPTABLES_SRC)/install \
65	    --disable-ipv6 \
66	    PKG_CONFIG=/bin/false)
67endif
68endif # linux-2.6.36
69
70.PHONY: iptables
71iptables: configure
72	+$(MAKE) -C $(IPTABLES_SRC)
73	+$(MAKE) -C $(IPTABLES_SRC) install
74ifeq ($(CONFIG_IPV6),y)	
75	$(AR) cru libiptc.a $(IPTLIB_DIR)/libip4tc.o $(IPTLIB_DIR)/libip6tc.o
76else
77	$(AR) cru libiptc.a $(IPTLIB_DIR)/libip4tc.o
78endif
79
80.PHONY: install
81install: all
82	install -d $(IPT_INSTALL_DIR)
83	install -d $(IPT_INSTALL_DIR)/lib/iptables
84	install $(IPTABLES_SRC)/extensions/*.so $(IPT_INSTALL_DIR)/lib/iptables
85	$(STRIP) $(IPT_INSTALL_DIR)/lib/iptables/*.so
86	cp -rf $(IPTABLES_SRC)/install/sbin $(IPT_INSTALL_DIR)
87	install -d $(INSTALLDIR)/lib
88	cp -f $(IPTABLES_SRC)/install/lib/libip* $(INSTALLDIR)/lib
89
90
91.PHONY: clean
92clean: 
93	+$(if $(wildcard $(IPTABLES_SRC)/Makefile), \
94		$(MAKE) -C $(IPTABLES_SRC) distclean \
95	   , \
96	    @true \
97	  )
98	  rm -f libiptc.a
99
100.PHONY: $(addprefix clean-,${DIRS})
101$(addprefix clean-,${DIRS}):
102	+$(MAKE) -C $(patsubst clean-%,%,$@) clean
103