summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 23302b0c6b17d5c1b9eac71c24f862c8f8b0e719 (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
#!/usr/bin/make

IPSET_VERSION:=v1.0
IPSET_LIB_DIR:=$(DESTDIR)$(LIBDIR)/ipset
#IPSET_LIB_DIR:=.
#CFLAGS:=-I$(KERNEL_DIR)/include

SETTYPES:=ipmap portmap macipmap iphash

EXTRAS+=$(shell [ -f $(KERNEL_DIR)/include/linux/netfilter_ipv4/ip_set.h ] && echo ipset/ipset)
EXTRAS+=$(foreach T, $(SETTYPES),ipset/libipset_$(T).so)
EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ipset $(DESTDIR)$(MANDIR)/man8/ipset.8
EXTRA_INSTALLS+=$(foreach T, $(SETTYPES), $(DESTDIR)$(LIBDIR)/ipset/libipset_$(T).so)

ifndef TOPLEVEL_INCLUDED
local:
	cd .. && $(MAKE) $(KERN_TARGETS) $(SHARED_LIBS) $(EXTRAS)

else
EXTRA_DEPENDS+=$(shell [ -f $(KERNEL_DIR)/include/linux/netfilter_ipv4/ip_set.h ] && echo "")
CFLAGS+=-DIPSET_VERSION=$(IPSET_VERSION) -DIPSET_LIB_DIR=\"$(IPSET_LIB_DIR)\"

#The ipset(8) self
ipset/ipset.o: ipset/ipset.c
	$(CC) $(CFLAGS) -g -c -o $@ $<

ipset/ipset: ipset/ipset.o
	$(CC) $(CFLAGS) -ldl -rdynamic -o $@ $^

#Pooltypes
ipset/ipset_%.o: ipset/ipset_%.c
	$(CC) $(CFLAGS) -c -o $@ $<

ipset/libipset_%.so: ipset/ipset_%.o
	$(LD) -shared -o $@ $<

$(DESTDIR)$(LIBDIR)/ipset/libipset_%.so: ipset/libipset_%.so
	@[ -d $(DESTDIR)$(LIBDIR)/ipset ] || mkdir -p $(DESTDIR)$(LIBDIR)/ipset
	cp $< $@

$(DESTDIR)$(BINDIR)/ipset: ipset/ipset
	@[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
	cp $< $@

$(DESTDIR)$(MANDIR)/man8/ipset.8: ipset/ipset.8
	@[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
	cp $< $@
endif