aboutsummaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
Diffstat (limited to 'mk')
-rw-r--r--mk/os.mk8
-rw-r--r--mk/scripts.mk18
-rw-r--r--mk/sys.mk15
3 files changed, 26 insertions, 15 deletions
diff --git a/mk/os.mk b/mk/os.mk
index c99f8b6e..e4f3c76f 100644
--- a/mk/os.mk
+++ b/mk/os.mk
@@ -29,3 +29,11 @@ LIBDL?= ${_LIBDL}$(shell ${_LIBDL_SH})
_LIBKVM_SH= case `uname -s` in *BSD) echo "-lkvm";; *) echo;; esac
_LIBKVM!= ${_LIBKVM_SH}
LIBKVM?= ${_LIBKVM}$(shell ${_LIBKVM_SH})
+
+_PREFIX_SH= if test -n "${PREFIX}" && test "${PREFIX}" != "/"; then echo "-DPREFIX=\\\"${PREFIX}\\\""; else echo ""; fi
+_PREFIX!= ${_PREFIX_SH}
+CFLAGS+= ${_PREFIX}$(shell ${_PREFIX_SH})
+
+_PKG_PREFIX_SH= if test -n "${PKG_PREFIX}" && test "${PKG_PREFIX}" != "/"; then echo "-DPKG_PREFIX=\\\"${PKG_PREFIX}\\\""; else echo ""; fi
+_PKG_PREFIX!= ${_PKG_PREFIX_SH}
+CFLAGS+= ${_PKG_PREFIX}$(shell ${_PKG_PREFIX_SH})
diff --git a/mk/scripts.mk b/mk/scripts.mk
index 114d5e2b..561545de 100644
--- a/mk/scripts.mk
+++ b/mk/scripts.mk
@@ -16,24 +16,24 @@ include ${MK}/os.mk
# Tweak our shell scripts
.SUFFIXES: .sh.in
.sh.in.sh:
- sed -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' $< > $@
+ sed -e 's:@SHELL@:${SH}:g' -e 's:@LIB@:${LIBNAME}:g' -e 's:@PREFIX@:${PREFIX}:g' -e 's:@PKG_PREFIX@:${PKG_PREFIX}:g' $< > $@
all: ${OBJS}
realinstall: ${BIN} ${CONF} ${CONF_APPEND}
- if test -n "${DIR}"; then ${INSTALL} -d ${DESTDIR}${DIR} || exit $$?; fi
- if test -n "${BIN}"; then ${INSTALL} -m ${BINMODE} ${BIN} ${DESTDIR}${DIR} || exit $$?; fi
- if test -n "${INC}"; then ${INSTALL} -m ${INCMODE} ${INC} ${DESTDIR}${DIR} || exit $$?; fi
+ if test -n "${DIR}"; then ${INSTALL} -d ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi
+ if test -n "${BIN}"; then ${INSTALL} -m ${BINMODE} ${BIN} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi
+ if test -n "${INC}"; then ${INSTALL} -m ${INCMODE} ${INC} ${DESTDIR}/${PREFIX}${DIR} || exit $$?; fi
for x in ${CONF}; do \
- if ! test -e ${DESTDIR}${DIR}/$$x; then \
- ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}${DIR} || exit $$?; \
+ if ! test -e ${DESTDIR}/${PREFIX}${DIR}/$$x; then \
+ ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \
fi; \
done
for x in ${CONF_APPEND}; do \
- if test -e ${DESTDIR}${DIR}/$$x; then \
- cat $$x >> ${DESTDIR}${DIR}/$$x || exit $$?; \
+ if test -e ${DESTDIR}/${PREFIX}${DIR}/$$x; then \
+ cat $$x >> ${DESTDIR}/${PREFIX}${DIR}/$$x || exit $$?; \
else \
- ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}${DIR} || exit $$?; \
+ ${INSTALL} -m ${CONFMODE} $$x ${DESTDIR}/${PREFIX}${DIR} || exit $$?; \
fi; \
done
diff --git a/mk/sys.mk b/mk/sys.mk
index 7be86426..e3111e37 100644
--- a/mk/sys.mk
+++ b/mk/sys.mk
@@ -7,23 +7,26 @@ INSTALL?= install
RANLIB?= ranlib
SH= /bin/sh
+PREFIX=
+PKG_PREFIX= /usr/local
+
PICFLAG?= -fPIC
-BINDIR?= /sbin
+BINDIR?= ${PREFIX}/sbin
BINMODE?= 0755
-INCDIR?= /usr/include
+INCDIR?= ${PREFIX}/usr/include
INCMODE?= 0444
LIBNAME?= lib
-LIBDIR?= /usr/${LIBNAME}
+LIBDIR?= ${PREFIX}/usr/${LIBNAME}
LIBMODE?= 0444
-SHLIBDIR?= /${LIBNAME}
+SHLIBDIR?= ${PREFIX}/${LIBNAME}
-MANDIR?= /usr/share/man/man
+MANDIR?= ${PREFIX}/usr/share/man/man
MANMODE?= 0444
-DOCDIR?= /usr/share/doc
+DOCDIR?= ${PREFIX}/usr/share/doc
DOCMODE?= 0644
CONFMODE?= 0644