diff --git a/Makefile b/Makefile
index 42c3436..3aded36 100644
--- a/Makefile
+++ b/Makefile
@@ -99,7 +99,7 @@ ic3_gcovr:
ic3_test_cov: cov
${MAKE} -C test ic3_test_cov
-install: all
+install:
${MAKE} -C libc3 install
${MAKE} -C ic3 install
${MAKE} -C c3s install
diff --git a/c3s/Makefile b/c3s/Makefile
index 3acc935..52ad7b3 100644
--- a/c3s/Makefile
+++ b/c3s/Makefile
@@ -47,6 +47,9 @@ gcovr:
gdb_c3s: debug
if [ -f c3s.debug.core ]; then gdb c3s.debug c3s.debug.core; else gdb c3s.debug; fi
+install:
+ install -m 755 c3s ${PREFIX}/bin
+
.PHONY: all asan cov debug clean clean_cov distclean
include config.mk
diff --git a/config.subr b/config.subr
index 2b17a35..eeac8f6 100644
--- a/config.subr
+++ b/config.subr
@@ -124,7 +124,7 @@ VER=0.1
echo "VER = $VER" >> ${CONFIG_MK}
echo "C3_TOP = $C3_TOP" >> ${CONFIG_MK}
-if test -z "$CC"; then
+if [ "x$CC" = "x" ]; then
if test -n $(which cc); then
CC=cc
elif test -n $(which gcc); then
@@ -150,14 +150,14 @@ if ${HAVE_GCOV}; then
echo "GCOV = $GCOV" >> ${CONFIG_MK}
fi
-if test -z "$INSTALL"; then
+if [ "x$INSTALL" = "x" ]; then
if test -x "$(which install)"; then
INSTALL=install
fi
fi
echo "INSTALL = $INSTALL" >> ${CONFIG_MK}
-if test -z "$LIBTOOL"; then
+if [ "x$LIBTOOL" = "x" ]; then
if test -x "$(which glibtool 2>/dev/null)"; then
LIBTOOL="$(which glibtool)"
elif test -x "/usr/local/bin/libtool"; then
@@ -170,37 +170,31 @@ if test -z "$LIBTOOL"; then
fi
echo "LIBTOOL = $LIBTOOL" >> ${CONFIG_MK}
-if test -z "$PREFIX"; then
- if test -d "$HOME/.c3"; then
+if [ "x$PREFIX" = "x" ]; then
+ if [ -d "$HOME/.c3" ]; then
PREFIX="$HOME/.c3"
- elif test -d /usr/local; then
+ else
PREFIX=/usr/local
- elif test -d /usr; then
- PREFIX=/usr
- elif test -d /opt/local; then
- PREFIX=/opt/local
- elif test -d /opt; then
- PREFIX=/opt
fi
fi
echo "PREFIX = $PREFIX" >> ${CONFIG_MK}
-if test -z "$OWNER"; then
+if [ "x$OWNER" = "x" ]; then
OWNER="$(ls -ld "$PREFIX" | tr -s ' ' | cut -d ' ' -f 3)"
fi
echo "OWNER = $OWNER" >> ${CONFIG_MK}
-if test -z "$GROUP"; then
+if [ "x$GROUP" = "x" ]; then
GROUP="$(ls -ld "$PREFIX" | tr -s ' ' | cut -d ' ' -f 4)"
fi
echo "GROUP = $GROUP" >> ${CONFIG_MK}
-if test -z "$BINDIR"; then
+if [ "x$BINDIR" = "x" ]; then
BINDIR=${PREFIX}/bin
fi
echo "BINDIR = $BINDIR" >> ${CONFIG_MK}
-if test -z "$LIBDIR"; then
+if [ "x$LIBDIR" = "x" ]; then
LIBDIR=${PREFIX}/lib
fi
echo "LIBDIR = $LIBDIR" >> ${CONFIG_MK}
diff --git a/configure b/configure
index 8348c69..9d092b1 100755
--- a/configure
+++ b/configure
@@ -16,6 +16,13 @@ set -e
export C3_TOP="$(pwd)"
+PREFIX=${PREFIX:-/usr/local}
+if [ "x$1" = "x--prefix" ]; then
+ PREFIX="$2"
+ shift 2
+fi
+export PREFIX
+
( cd libtommath && ./configure; )
( cd ucd2c && ./configure; )
( cd libc3 && ./configure; )
diff --git a/ic3/Makefile b/ic3/Makefile
index 943f939..94487fe 100644
--- a/ic3/Makefile
+++ b/ic3/Makefile
@@ -47,6 +47,9 @@ gcovr:
gdb_ic3: debug
if [ -f ic3.debug.core ]; then gdb ic3.debug ic3.debug.core; else gdb ic3.debug; fi
+install:
+ install -m 755 ic3 ${PREFIX}/bin
+
.PHONY: all asan cov debug clean clean_cov distclean
include config.mk
diff --git a/libc3/Makefile b/libc3/Makefile
index f9fbf91..003dd48 100644
--- a/libc3/Makefile
+++ b/libc3/Makefile
@@ -44,6 +44,37 @@ distclean:
gcovr:
gcovr --gcov-executable ${GCOV} --html-details libc3.html
+install:
+ mkdir -p "${PREFIX}/include/c3"
+ install -m 644 arg.h "${PREFIX}/include/c3/"
+ install -m 644 bool.h "${PREFIX}/include/c3/"
+ install -m 644 buf.h "${PREFIX}/include/c3/"
+ install -m 644 buf_file.h "${PREFIX}/include/c3/"
+ install -m 644 buf_inspect.h "${PREFIX}/include/c3/"
+ install -m 644 buf_parse.h "${PREFIX}/include/c3/"
+ install -m 644 buf_save.h "${PREFIX}/include/c3/"
+ install -m 644 c3.h "${PREFIX}/include/c3/"
+ install -m 644 call.h "${PREFIX}/include/c3/"
+ install -m 644 character.h "${PREFIX}/include/c3/"
+ install -m 644 compare.h "${PREFIX}/include/c3/"
+ install -m 644 debug.h "${PREFIX}/include/c3/"
+ install -m 644 env.h "${PREFIX}/include/c3/"
+ install -m 644 eval.h "${PREFIX}/include/c3/"
+ install -m 644 fact.h "${PREFIX}/include/c3/"
+ install -m 644 facts.h "${PREFIX}/include/c3/"
+ install -m 644 fn.h "${PREFIX}/include/c3/"
+ install -m 644 hash.h "${PREFIX}/include/c3/"
+ install -m 644 ident.h "${PREFIX}/include/c3/"
+ install -m 644 integer.h "${PREFIX}/include/c3/"
+ install -m 644 list.h "${PREFIX}/include/c3/"
+ install -m 644 quote.h "${PREFIX}/include/c3/"
+ install -m 644 str.h "${PREFIX}/include/c3/"
+ install -m 644 tag.h "${PREFIX}/include/c3/"
+ install -m 644 tuple.h "${PREFIX}/include/c3/"
+ install -m 644 ucd.h "${PREFIX}/include/c3/"
+ mkdir -p "${PREFIX}/lib"
+ libtool install libc3.la "${PREFIX}/lib"
+
libc3.a: libc3.la
cp .libs/libc3.a ./
@@ -99,7 +130,7 @@ test:
update_sources:
./update_sources
-.PHONY: all asan build clean cov debug distclean test update_sources
+.PHONY: all asan build clean cov debug distclean install test update_sources
include config.mk
include sources.mk