summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 89fd6e7e3763ee92d9fbe92557c093ed2835c174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
ARPTABLES_VERSION:=0.0.3-3

KERNEL_DIR:=./
# default paths
PREFIX:=/usr/local
LIBDIR:=$(PREFIX)/lib
BINDIR:=$(PREFIX)/sbin
MANDIR:=$(PREFIX)/man
INITDIR:=/etc/rc.d/init.d
SYSCONFIGDIR:=/etc/sysconfig
DESTDIR:=

COPT_FLAGS:=-O2
CFLAGS:=$(COPT_FLAGS) -Wall -Wunused -I$(KERNEL_DIR)/include/ -Iinclude/ -DARPTABLES_VERSION=\"$(ARPTABLES_VERSION)\" #-g -DDEBUG #-pg # -DARPTC_DEBUG

ifndef ARPT_LIBDIR
ARPT_LIBDIR:=$(LIBDIR)/arptables
endif

include extensions/Makefile

all: arptables

arptables.o: arptables.c
	$(CC) $(CFLAGS) -c -o $@ $<

arptables-standalone.o: arptables-standalone.c
	$(CC) $(CFLAGS) -c -o $@ $<

libarptc/libarptc.o: libarptc/libarptc.c libarptc/libarptc_incl.c
	$(CC) $(CFLAGS) -c -o $@ $<

arptables: arptables-standalone.o arptables.o libarptc/libarptc.o $(EXT_OBJS)
	$(CC) $(CFLAGS) -o $@ $^

$(DESTDIR)$(MANDIR)/man8/arptables.8: arptables.8
	mkdir -p $(@D)
	install -m 0644 -o root -g root $< $@

$(DESTDIR)$(BINDIR)/arptables: arptables
	mkdir -p $(DESTDIR)$(BINDIR)
	install -m 0755 -o root -g root $< $@

tmp1:=$(shell printf $(BINDIR) | sed 's/\//\\\//g')
tmp2:=$(shell printf $(SYSCONFIGDIR) | sed 's/\//\\\//g')
.PHONY: scripts
scripts: arptables-save arptables-restore arptables.sysv
	cat arptables-save | sed 's/__EXEC_PATH__/$(tmp1)/g' > arptables-save_
	install -m 0755 -o root -g root arptables-save_ $(DESTDIR)$(BINDIR)/arptables-save
	cat arptables-restore | sed 's/__EXEC_PATH__/$(tmp1)/g' > arptables-restore_
	install -m 0755 -o root -g root arptables-restore_ $(DESTDIR)$(BINDIR)/arptables-restore
	cat arptables.sysv | sed 's/__EXEC_PATH__/$(tmp1)/g' | sed 's/__SYSCONFIG__/$(tmp2)/g' > arptables.sysv_
	install -m 0755 -o root -g root arptables.sysv_ $(DESTDIR)$(INITDIR)/arptables
	rm -f arptables-save_ arptables-restore_ arptables.sysv_

.PHONY: install
install: $(DESTDIR)$(MANDIR)/man8/arptables.8 $(DESTDIR)$(BINDIR)/arptables scripts

.PHONY: clean
clean:
	rm -f arptables
	rm -f *.o *~
	rm -f extensions/*.o extensions/*~
	rm -f libarptc/*.o libarptc/*~
	rm -f include/*~ include/libarptc/*~

DIR:=arptables-v$(ARPTABLES_VERSION)
CVSDIRS:=CVS extensions/CVS libarptc/CVS include/CVS include/libarptc/CVS
# This is used to make a new userspace release
.PHONY: release
release:
	rm -rf $(CVSDIRS)
	mkdir -p include/linux/netfilter_arp
	install -m 0644 -o root -g root \
		$(KERNEL_DIR)/include/linux/netfilter_arp.h include/linux/
	install -m 0644 -o root -g root \
		$(KERNEL_DIR)/include/linux/netfilter_arp/*.h \
		include/linux/netfilter_arp/
	install -m 0644 -o root -g root \
		include/arp_tables.h include/linux/netfilter_arp/arp_tables.h
	make clean
	cd ..;tar -c $(DIR) | gzip >$(DIR).tar.gz