[BUILD] Added support for 'make install'
To be flexible while installing haproxy following variables have been
added to the Makefile:
- DESTDIR useful i.e. while installing in a sandbox (not set by default)
- PREFIX defines the default install prefix (default: /usr/local)
- SBINDIR defines the dir the haproxy binary gets installed
(default: $PREFIX/sbin)
diff --git a/Makefile b/Makefile
index 4976ffd..f74f8f8 100644
--- a/Makefile
+++ b/Makefile
@@ -38,6 +38,12 @@
# by "haproxy -vv" in CFLAGS.
# SILENT_DEFINE may be used to specify other defines which will not be
# reported by "haproxy -vv".
+# DESTDIR is not set by default and is used for installation only.
+# It might be useful to set DESTDIR if you want to install haproxy
+# in a sandbox.
+# PREFIX is set to "/usr/local" by default and is used for installation only.
+# SBINDIR is set to "$(PREFIX)/sbin" by default and is used for installation
+# only.
#
# Other variables :
# DLMALLOC_SRC : build with dlmalloc, indicate the location of dlmalloc.c.
@@ -48,6 +54,10 @@
# SUBVERS : add a sub-version (eg: platform, model, ...).
# VERDATE : force haproxy's release date.
+#### Installation options.
+DESTDIR =
+PREFIX = /usr/local
+SBINDIR = $(PREFIX)/sbin
#### TARGET system
# Use TARGET=<target_name> to optimize for a specifc target OS among the
@@ -462,6 +472,10 @@
src/dlmalloc.o: $(DLMALLOC_SRC)
$(CC) $(COPTS) -DDEFAULT_MMAP_THRESHOLD=$(DLMALLOC_THRES) -c -o $@ $<
+install: all
+ install -d $(DESTDIR)/$(SBINDIR)
+ install haproxy $(DESTDIR)/$(SBINDIR)
+
clean:
rm -f *.[oas] src/*.[oas] core haproxy test
for dir in . src include/* doc; do rm -f $$dir/*~ $$dir/*.rej;done