summaryrefslogtreecommitdiff
blob: ba8e9450eb3537744000811bca150db449bf8e7a (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--- a/Makefile
+++ b/Makefile
@@ -43,14 +43,13 @@
 INIT		= $(BUILD_ROOT)/etc/rc.d/init.d
 MKDIR		= mkdir
 INSTALL		= install
-STATIC_LIBS	= libipvs/libipvs.a
 
 ifeq "${ARCH}" "sparc64"
-    CFLAGS = -Wall -Wunused -Wstrict-prototypes -g -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow
+    CFLAGS := -g -m64 -pipe -mcpu=ultrasparc -mcmodel=medlow
 else
-    CFLAGS = -Wall -Wunused -Wstrict-prototypes -g
+    CFLAGS := -g
 endif
-
+OPTFLAGS += -Wall -Wunused -Wstrict-prototypes
 
 #####################################
 # No servicable parts below this line
@@ -94,10 +93,12 @@
 all:            libs ipvsadm
 
 libs:
-		make -C libipvs
+		$(MAKE) -C libipvs
+
+$(OBJS):	libs
 
-ipvsadm:	$(OBJS) $(STATIC_LIBS)
-		$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+ipvsadm:	$(OBJS)
+		$(CC) $(LDFLAGS) $(OPTFLAGS) $(CFLAGS) -o $@ $^ -Llibipvs -lipvs $(LIBS)
 
-install:        all
+install:
 		if [ ! -d $(SBIN) ]; then $(MKDIR) -p $(SBIN); fi
@@ -108,15 +109,13 @@
 		$(INSTALL) -m 0644 ipvsadm.8 $(MAN)
 		$(INSTALL) -m 0644 ipvsadm-save.8 $(MAN)
 		$(INSTALL) -m 0644 ipvsadm-restore.8 $(MAN)
-		[ -d $(INIT) ] || $(MKDIR) -p $(INIT)
-		$(INSTALL) -m 0755 ipvsadm.sh $(INIT)/ipvsadm
 
 clean:
 		rm -f ipvsadm $(NAME).spec $(NAME)-$(VERSION).tar.gz
 		rm -rf debian/tmp
 		find . -name '*.[ao]' -o -name "*~" -o -name "*.orig" \
 		  -o -name "*.rej" -o -name core | xargs rm -f
-		make -C libipvs clean
+		$(MAKE) -C libipvs clean
 
 distclean:	clean
 
@@ -149,4 +148,4 @@
 		dpkg-buildpackage
 
 %.o:	%.c
-		$(CC) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<
+		$(CC) $(OPTFLAGS) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<
--- a/libipvs/Makefile
+++ b/libipvs/Makefile
@@ -1,32 +1,39 @@
 # Makefile for libipvs
 
 CC		= gcc
-CFLAGS		= -Wall -Wunused -Wstrict-prototypes -g -fPIC
+OPTFLAGS = -Wall -Wunused -Wstrict-prototypes
 ifneq (0,$(HAVE_NL))
-CFLAGS		+= -DLIBIPVS_USE_NL
+DEFINES += -DLIBIPVS_USE_NL
 endif
 
 INCLUDE		+= $(shell if [ -f ../../ip_vs.h ]; then	\
 		     echo "-I../../."; fi;)
-DEFINES		= $(shell if [ ! -f ../../ip_vs.h ]; then	\
+DEFINES		+= $(shell if [ ! -f ../../ip_vs.h ]; then	\
 		    echo "-DHAVE_NET_IP_VS_H"; fi;)
 
 .PHONY		= all clean install dist distclean rpm rpms
-STATIC_LIB	= libipvs.a
-SHARED_LIB	= libipvs.so
 
-all:		$(STATIC_LIB) $(SHARED_LIB)
+TARGETS = libipvs.so
 
-$(STATIC_LIB):	libipvs.o ip_vs_nl_policy.o
+ifeq (1,$(STATIC_LIB))
+TARGETS += libipvs.a
+endif
+
+all:		$(TARGETS)
+
+libipvs.a:	libipvs.o ip_vs_nl_policy.o
 		ar rv $@ $^
 
-$(SHARED_LIB):	libipvs.o ip_vs_nl_policy.o
-		$(CC) -shared -Wl,-soname,$@ -o $@ $^
+libipvs.so:	libipvs.lo ip_vs_nl_policy.lo
+		$(CC) $(LDFLAGS) -shared -Wl,-soname,$@ -o $@ $^
+
+%.lo:		%.c
+		$(CC) -fPIC $(OPTFLAGS) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<
 
 %.o:		%.c
-		$(CC) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<
+		$(CC) $(OPTFLAGS) $(CFLAGS) $(INCLUDE) $(DEFINES) -c -o $@ $<
 
 clean:
-		rm -f *.[ao] *~ *.orig *.rej core *.so
+		rm -f *.[ao] *~ *.orig *.rej core *.so *.lo
 
 distclean:	clean