Merge commit 'origin/trunk@12184' into fedora
[iptables.git] / Makefile.nolibnsl
1 # uncomment this to get a fully statically linked version
2 # NO_SHARED_LIBS = 1
3
4 # uncomment this to disable IPv6 support
5 # DO_IPV6 = 0
6
7 ######################################################################
8 # YOU SHOULD NOT NEED TO TOUCH ANYTHING BELOW THIS LINE
9 ######################################################################
10
11 # Standard part of Makefile for topdir.
12 TOPLEVEL_INCLUDED=YES
13
14 ifndef KERNEL_DIR
15 KERNEL_DIR=/usr/src/linux
16 endif
17 IPTABLES_VERSION:=1.2.9
18 OLD_IPTABLES_VERSION:=1.2.8
19
20 PREFIX:=/usr
21 LIBDIR:=$(PREFIX)/lib
22 BINDIR:=$(PREFIX)/sbin
23 MANDIR:=$(PREFIX)/man
24 INCDIR:=$(PREFIX)/include
25
26 # directory for new iptables releases
27 RELEASE_DIR:=/tmp
28
29 # Need libc6 for this.  FIXME: Should covert to autoconf.
30 ifeq ($(shell [ -f /usr/include/netinet/ip6.h ] && echo YES), YES)
31 DO_IPV6:=1
32 endif
33
34 COPT_FLAGS:=-O2
35 CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include -Iinclude/ -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DIPTC_DEBUG
36
37 ifdef NO_SHARED_LIBS
38 CFLAGS += -DNO_SHARED_LIBS=1
39 endif
40
41 ifndef NO_SHARED_LIBS
42 DEPFILES = $(SHARED_LIBS:%.so=%.d)
43 SH_CFLAGS:=$(CFLAGS) -fPIC
44 STATIC_LIBS  =
45 STATIC6_LIBS =
46 LDFLAGS      = -rdynamic
47 LDLIBS       = -ldl -lnsl
48 else
49 DEPFILES = $(EXT_OBJS:%.o=%.d)
50 STATIC_LIBS  = extensions/libext.a
51 STATIC6_LIBS = extensions/libext6.a
52 LDFLAGS      = -static
53 LDLIBS       =
54 endif
55
56 EXTRAS+=iptables iptables.o
57 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
58
59 # No longer experimental.
60 EXTRAS+=iptables-save iptables-restore
61 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8
62
63 ifeq ($(DO_IPV6), 1)
64 EXTRAS+=ip6tables ip6tables.o
65 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables $(DESTDIR)$(MANDIR)/man8/ip6tables.8
66 EXTRAS_EXP+=ip6tables-save ip6tables-restore
67 EXTRA_INSTALLS_EXP+=$(DESTDIR)$(BINDIR)/ip6tables-save $(DESTDIR)$(BINDIR)/ip6tables-restore # $(DESTDIR)$(MANDIR)/man8/iptables-restore.8 $(DESTDIR)$(MANDIR)/man8/iptables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-restore.8
68 endif
69
70 # Sparc64 hack
71 ifeq ($(shell uname -m),sparc64)
72 # The kernel is 64-bit, even though userspace is 32.
73 CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
74 endif
75
76 # HPPA hack
77 ifeq ($(shell uname -m),parisc64)
78 # The kernel is 64-bit, even though userspace is 32.
79 CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
80 endif
81
82 ifndef IPT_LIBDIR
83 IPT_LIBDIR:=$(LIBDIR)/iptables
84 endif
85
86 .PHONY: default
87 default: print-extensions all
88
89 .PHONY: print-extensions
90 print-extensions:
91         @[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)
92
93 iptables.o: iptables.c
94         $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
95
96 iptables: iptables-standalone.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
97         $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
98
99 $(DESTDIR)$(BINDIR)/iptables: iptables
100         @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
101         cp $< $@
102
103 iptables-save: iptables-save.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
104         $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
105
106 $(DESTDIR)$(BINDIR)/iptables-save: iptables-save
107         @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
108         cp $< $@
109
110 iptables-restore: iptables-restore.c iptables.o $(STATIC_LIBS) libiptc/libiptc.a
111         $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
112
113 $(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore
114         @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
115         cp $< $@
116
117 ip6tables.o: ip6tables.c
118         $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
119
120 ip6tables: ip6tables-standalone.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
121         $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
122
123 $(DESTDIR)$(BINDIR)/ip6tables: ip6tables
124         @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
125         cp $< $@
126
127 ip6tables-save: ip6tables-save.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
128         $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
129
130 $(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
131         @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
132         cp $< $@
133
134 ip6tables-restore: ip6tables-restore.c ip6tables.o $(STATIC6_LIBS) libiptc/libiptc.a
135         $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
136
137 $(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
138         @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
139         cp $< $@
140
141 $(DESTDIR)$(MANDIR)/man8/%.8: %.8
142         @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
143         cp $< $@
144
145 EXTRA_DEPENDS+=iptables-standalone.d iptables.d
146
147 iptables-standalone.d iptables.d: %.d: %.c
148         @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@
149
150
151 # Development Targets
152 .PHONY: install-devel-man3
153 install-devel-man3: $(DEVEL_MAN3)
154         @[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
155         @cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3
156
157 .PHONY: install-devel-headers
158 install-devel-headers: $(DEVEL_HEADERS)
159         @[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
160         @cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)
161
162 .PHONY: install-devel-libs
163 install-devel-libs: $(DEVEL_LIBS)
164         @[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
165         @cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)
166
167 .PHONY: install-devel
168 install-devel: all install-devel-man3 install-devel-headers install-devel-libs
169
170 .PHONY: distclean
171 distclean: clean
172         @rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst
173
174 # Rusty's distro magic.
175 .PHONY: distrib
176 distrib: check distclean delrelease $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2 diff md5sums # nowhitespace
177
178 # Makefile must not define:
179 # -g -pg -DIPTC_DEBUG
180 .PHONY: check
181 check:
182         @if echo $(CFLAGS) | egrep -e '-g|-pg|IPTC_DEBUG' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
183
184 .PHONY: nowhitespace
185 nowhitespace:
186         @if grep -n '[  ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi
187
188 .PHONY: delrelease
189 delrelease:
190         rm -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
191
192 $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2:
193         cd .. && ln -sf userspace iptables-$(IPTABLES_VERSION) && tar cvf - --exclude CVS iptables-$(IPTABLES_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(IPTABLES_VERSION)
194
195 .PHONY: diff
196 diff: $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
197         @mkdir /tmp/diffdir
198         @cd /tmp/diffdir && tar -x --bzip2 -f $(RELEASE_DIR)/iptables-$(IPTABLES_VERSION).tar.bz2
199         @set -e; cd /tmp/diffdir; tar -x --bzip2 -f $(RELEASE_DIR)/iptables-$(OLD_IPTABLES_VERSION).tar.bz2; echo Creating patch-iptables-$(OLD_IPTABLES_VERSION)-$(IPTABLES_VERSION).bz2; diff -urN iptables-$(OLD_IPTABLES_VERSION) iptables-$(IPTABLES_VERSION) | bzip2 -9 > $(RELEASE_DIR)/patch-iptables-$(OLD_IPTABLES_VERSION)-$(IPTABLES_VERSION).bz2
200         @rm -rf /tmp/diffdir
201
202 .PHONY: md5sums
203 md5sums:
204         cd $(RELEASE_DIR)/ && md5sum patch-iptables-*-$(IPTABLES_VERSION).bz2 iptables-$(IPTABLES_VERSION).tar.bz2
205
206 # $(wildcard) fails wierdly with make v.3.78.1.
207 include $(shell echo */Makefile)
208 include Rules.make