2
# ipvsadm - IP Virtual Server ADMinistration program
3
# for IPVS NetFilter Module in kernel 2.4
5
# Version: $Id: Makefile 77 2011-02-08 00:23:51Z wensong $
7
# Authors: Wensong Zhang <wensong@linux-vs.org>
8
# Peter Kese <peter.kese@ijs.si>
14
# Wensong : Modified the Makefile and the spec files so
15
# : that rpms can be created with ipvsadm alone
16
# P.Copeland : Modified the Makefile and the spec files so
17
# : that it is possible to create rpms on the fly
19
# : Also added NAME, VERSION and RELEASE numbers to
21
# Horms : Updated to add config_stream.c dynamic_array.c
22
# : Added autodetection of libpot
23
# : Added BUILD_ROOT support
24
# Wensong : Changed the OBJS according to detection
25
# Ratz : Fixed to use the correct CFLAGS on sparc64
29
VERSION = $(shell cat VERSION)
31
SCHEDULERS = "$(shell cat SCHEDULERS)"
32
PE_LIST = "$(shell cat PERSISTENCE_ENGINES)"
33
PROGROOT = $(shell basename `pwd`)
34
ARCH = $(shell uname -m)
35
RPMSOURCEDIR = $(shell rpm --eval '%_sourcedir')
36
RPMSPECDIR = $(shell rpm --eval '%_specdir')
40
SBIN = $(BUILD_ROOT)/sbin
42
MAN = $(BUILD_ROOT)/$(MANDIR)/man8
43
INIT = $(BUILD_ROOT)/etc/rc.d/init.d
46
STATIC_LIBS = libipvs/libipvs.a
48
ifeq "${ARCH}" "sparc64"
49
CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow
51
CFLAGS = -Wall -Wunused -Wstrict-prototypes -g
55
#####################################
56
# No servicable parts below this line
59
if [ -x /usr/bin/rpmbuild ]; then \
60
echo "/usr/bin/rpmbuild"; \
65
ifeq (,$(FORCE_GETOPT))
66
LIB_SEARCH = /lib64 /usr/lib64 /usr/local/lib64 /lib /usr/lib /usr/local/lib
67
POPT_LIB = $(shell for i in $(LIB_SEARCH); do \
68
if [ -f $$i/libpopt.a ]; then \
69
if nm $$i/libpopt.a | fgrep -q poptGetContext; then \
78
POPT_DEFINE = -DHAVE_POPT
81
OBJS = ipvsadm.o config_stream.o dynamic_array.o
86
DEFINES = -DVERSION=\"$(VERSION)\" -DSCHEDULERS=\"$(SCHEDULERS)\" \
87
-DPE_LIST=\"$(PE_LIST)\" $(POPT_DEFINE)
88
DEFINES += $(shell if [ ! -f ../ip_vs.h ]; then \
89
echo "-DHAVE_NET_IP_VS_H"; fi;)
92
.PHONY = all clean install dist distclean rpm rpms
99
ipvsadm: $(OBJS) $(STATIC_LIBS)
100
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
103
if [ ! -d $(SBIN) ]; then $(MKDIR) -p $(SBIN); fi
104
$(INSTALL) -m 0755 ipvsadm $(SBIN)
105
$(INSTALL) -m 0755 ipvsadm-save $(SBIN)
106
$(INSTALL) -m 0755 ipvsadm-restore $(SBIN)
107
[ -d $(MAN) ] || $(MKDIR) -p $(MAN)
108
$(INSTALL) -m 0644 ipvsadm.8 $(MAN)
109
$(INSTALL) -m 0644 ipvsadm-save.8 $(MAN)
110
$(INSTALL) -m 0644 ipvsadm-restore.8 $(MAN)
111
[ -d $(INIT) ] || $(MKDIR) -p $(INIT)
112
$(INSTALL) -m 0755 ipvsadm.sh $(INIT)/ipvsadm
115
rm -f ipvsadm $(NAME).spec $(NAME)-$(VERSION).tar.gz
117
find . -name '*.[ao]' -o -name "*~" -o -name "*.orig" \
118
-o -name "*.rej" -o -name core | xargs rm -f
119
make -C libipvs clean
124
sed -e "s/@@VERSION@@/$(VERSION)/g" \
125
-e "s/@@RELEASE@@/$(RELEASE)/g" \
126
< ipvsadm.spec.in > ipvsadm.spec
127
rm -f $(NAME)-$(VERSION)
128
ln -s . $(NAME)-$(VERSION)
129
tar czvf $(NAME)-$(VERSION).tar.gz \
130
--exclude CVS --exclude .svn --exclude TAGS \
131
--exclude $(NAME)-$(VERSION)/$(NAME)-$(VERSION) \
132
--exclude $(NAME)-$(VERSION).tar.gz \
134
rm -f $(NAME)-$(VERSION)
137
cp $(NAME)-$(VERSION).tar.gz $(RPMSOURCEDIR)/
138
cp $(NAME).spec $(RPMSPECDIR)/
139
$(RPMBUILD) -ba $(RPMSPECDIR)/$(NAME).spec
142
cp $(NAME)-$(VERSION).tar.gz $(RPMSOURCEDIR)/
143
cp $(NAME).spec $(RPMSPECDIR)/
144
$(RPMBUILD) -bs $(RPMSPECDIR)/$(NAME).spec
152
$(CC) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<