Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 1 | # Standard part of Makefile for topdir. |
| 2 | TOPLEVEL_INCLUDED=YES |
| 3 | |
| 4 | ifndef KERNEL_DIR |
| 5 | KERNEL_DIR=/usr/src/linux |
| 6 | endif |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 7 | NETFILTER_VERSION:=1.0.1 |
| 8 | OLD_NETFILTER_VERSION:=1.0.0 |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 9 | |
| 10 | LIBDIR:=/usr/local/lib |
| 11 | BINDIR:=/usr/local/bin |
| 12 | MANDIR:=/usr/local/man |
| 13 | |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 14 | COPT_FLAGS:=-O #-O2 |
| 15 | CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -Iinclude/ -I$(KERNEL_DIR)/include -DNETFILTER_VERSION=\"$(NETFILTER_VERSION)\" -g #-pg # -DNDEBUG |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 16 | |
| 17 | DEPFILES := $(SHARED_LIBS:%.so=%.d) |
| 18 | SH_CFLAGS:=$(CFLAGS) -fPIC |
| 19 | DEPFILES := $(SHARED_LIBS:%.so=%.d) |
| 20 | |
| 21 | EXTRAS+=iptables iptables.o #iptables-save iptables-restore |
| 22 | EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8 #$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-restore |
| 23 | |
Rusty Russell | 09b9a41 | 2000-04-27 10:16:47 +0000 | [diff] [blame^] | 24 | # Sparc64 hack |
| 25 | ifeq ($(shell uname -m),sparc64) |
| 26 | # The kernel is 64-bit, even though userspace is 32. |
| 27 | CFLAGS+=-DIPT_MIN_MATCH_ALIGN=8 -DIPT_MIN_ENTRY_ALIGN=8 |
| 28 | endif |
| 29 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 30 | ifndef IPT_LIBDIR |
| 31 | IPT_LIBDIR:=$(LIBDIR)/iptables |
| 32 | endif |
| 33 | |
| 34 | default: all |
| 35 | |
| 36 | iptables.o: iptables.c |
| 37 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $< |
| 38 | |
| 39 | iptables: iptables-standalone.c iptables.o libiptc/libiptc.a |
| 40 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 41 | |
| 42 | $(DESTDIR)$(BINDIR)/iptables: iptables |
| 43 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 44 | cp $< $@ |
| 45 | |
| 46 | iptables-save: iptables-save.c iptables.o libiptc/libiptc.a |
| 47 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 48 | |
| 49 | $(DESTDIR)$(BINDIR)/iptables-save: iptables-save |
| 50 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 51 | cp $< $@ |
| 52 | |
| 53 | iptables-restore: iptables-restore.c iptables.o libiptc/libiptc.a |
| 54 | $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl |
| 55 | |
| 56 | $(DESTDIR)$(BINDIR)/iptables-restore: iptables-restore |
| 57 | @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR) |
| 58 | cp $< $@ |
| 59 | |
| 60 | $(DESTDIR)$(MANDIR)/man8/iptables.8: iptables.8 |
| 61 | @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8 |
| 62 | cp $< $@ |
| 63 | |
| 64 | EXTRA_DEPENDS+=iptables-standalone.d iptables.d |
| 65 | |
| 66 | iptables-standalone.d iptables.d: %.d: %.c |
| 67 | @-$(CC) -M -MG $(CFLAGS) $< | sed -e 's@^.*\.o:@$*.d $*.o:@' > $@ |
| 68 | |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 69 | distclean: clean |
| 70 | @rm -f TAGS `find . -name '*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 71 | |
| 72 | # Rusty's distro magic. |
| 73 | distrib: check nowhitespace distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums |
| 74 | |
| 75 | # Makefile must not define: |
| 76 | # -g -pg |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 77 | # And must define -NDEBUG |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 78 | check: |
Rusty Russell | 849779c | 2000-04-23 15:51:51 +0000 | [diff] [blame] | 79 | @if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi |
| 80 | @if echo $(CFLAGS) | egrep -e NDEBUG >/dev/null; then exit 0; else echo Define -DNDEBUG; exit 1; fi |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 81 | |
| 82 | nowhitespace: |
| 83 | @if grep -n ' $$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi |
| 84 | |
| 85 | delrelease: |
| 86 | rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 87 | |
| 88 | /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2: |
Rusty Russell | 905795c | 2000-04-19 11:22:03 +0000 | [diff] [blame] | 89 | cd .. && ln -sf userspace iptables-$(NETFILTER_VERSION) && tar cvf - --exclude CVS iptables-$(NETFILTER_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(NETFILTER_VERSION) |
Rusty Russell | 175f641 | 2000-03-24 09:32:20 +0000 | [diff] [blame] | 90 | |
| 91 | diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 92 | @mkdir /tmp/diffdir |
| 93 | @cd /tmp/diffdir && tar xfI /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 |
| 94 | @set -e; cd /tmp/diffdir; tar xfI /home/public/netfilter/iptables-$(OLD_NETFILTER_VERSION).tar.bz2; echo Creating patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2; diff -urN iptables-$(OLD_NETFILTER_VERSION) iptables-$(NETFILTER_VERSION) | bzip2 -9 > /home/public/netfilter/patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2 |
| 95 | @rm -rf /tmp/diffdir |
| 96 | |
| 97 | md5sums: |
| 98 | cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2 |
| 99 | |
Marc Boucher | e6869a8 | 2000-03-20 06:03:29 +0000 | [diff] [blame] | 100 | # $(wildcard) fails wierdly with make v.3.78.1. |
| 101 | include $(shell echo */Makefile) |
| 102 | include Rules.make |