aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-08-21 13:41:49 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2013-08-21 14:37:42 +0200
commita9bf2a6890ee1a491fd6d09ea93b210b2b58b368 (patch)
tree491f7fe64a1cfa00d350a238394c100b09fac067
parent7476d91f882da665b4d15ef879927cee3d7762e3 (diff)
downloadpingu-a9bf2a6890ee1a491fd6d09ea93b210b2b58b368.tar.bz2
pingu-a9bf2a6890ee1a491fd6d09ea93b210b2b58b368.tar.xz
configure: add simple configure script
-rw-r--r--Makefile25
-rwxr-xr-xconfigure147
2 files changed, 164 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 964aaa8..d67b58b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,6 @@
+-include config.mk
+
BIN_TARGETS = mtu
SBIN_TARGETS = pingu pinguctl
LUA_TARGETS = client.so
@@ -11,16 +13,23 @@ PINGU_VERSION := $(shell \
echo $(VERSION); \
fi)
-prefix = /usr
-localstatedir = /var
-rundir = $(localstatedir)/run
+prefix ?= /usr/local
+exec_prefix ?= $(prefix)
+bindir ?= $(exec_prefix)/bin
+sbindir ?= $(exec_prefix)/sbin
+sysconfdir ?= $(prefix)/etc
+localstatedir ?= $(prefix)/var
+libdir ?= $(exec_prefix)/lib
+datarootdir ?= $(prefix)/share
+mandir ?= $(datarootdir)/man
+
+rundir ?= $(localstatedir)/run
+
pingustatedir = $(rundir)/pingu
luasharedir = /usr/share/lua/5.1
lualibdir = /usr/lib/lua/5.1
-BINDIR = $(prefix)/bin
-SBINDIR = $(prefix)/sbin
DESTDIR ?=
INSTALL = install
@@ -85,10 +94,10 @@ $(SUBDIRS):
$(MAKE) -C $@
install: $(TARGETS)
- $(INSTALLDIR) $(DESTDIR)/$(BINDIR) $(DESTDIR)/$(SBINDIR) \
+ $(INSTALLDIR) $(DESTDIR)/$(bindir) $(DESTDIR)/$(sbindir) \
$(DESTDIR)/$(pingustatedir)
- $(INSTALL) $(BIN_TARGETS) $(DESTDIR)/$(BINDIR)
- $(INSTALL) $(SBIN_TARGETS) $(DESTDIR)/$(SBINDIR)
+ $(INSTALL) $(BIN_TARGETS) $(DESTDIR)/$(bindir)
+ $(INSTALL) $(SBIN_TARGETS) $(DESTDIR)/$(sbindir)
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir $@ || break; \
done
diff --git a/configure b/configure
new file mode 100755
index 0000000..b0ea1cb
--- /dev/null
+++ b/configure
@@ -0,0 +1,147 @@
+#!/bin/sh
+
+PACKAGE=pingu
+
+TMPDIR=${TMPDIR:-${TEMPDIR:-/tmp}}
+TMPC="$TMPDIR/$PACKAGE-conf-$$.c"
+TMPO="$TMPDIR/$PACKAGE-conf-$$.o"
+TMPE="$TMPDIR/$PACKAGE-conf-$$"
+
+trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM
+rm -f config.log
+
+echo "# $PACKAGE configure log $(date)" >> config.log
+printf "# Configured with:" >> config.log
+printf " '%s'" "$0" "$@" >> config.log
+echo >> config.log
+echo "#" >> config.log
+
+die() { echo "$*" >&2; exit 1; }
+
+do_cc() {
+ echo $cc "$@" >> config.log
+ $cc "$@" >> config.log 2>&1 || return $?
+}
+
+compile_prog() {
+ do_cc $CFLAGS $1 -o $TMPE $TMPC $LDFLAGS
+}
+
+usage () {
+cat <<EOF
+Usage: $0 [OPTION]... [VAR=VALUE]... [TARGET]
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Installation directories:
+ --prefix=PREFIX main installation prefix [/usr/local]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --rundir=DIR pidfile and unix sockets [LOCALSTATEDIR/run]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+
+Optional features:
+ --enable-debug build with debugging information [disabled]
+ --enable-warnings build with recommended warnings flags [enabled]
+ --enable-werror build with -Werror [disabled]
+
+Some influential environment variables:
+ CC C compiler command [detected]
+ CFLAGS C compiler flags [-Os -pipe ...]
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+
+Use these variables to override the choices made by configure.
+
+EOF
+exit 0
+}
+
+prefix=/usr/local
+exec_prefix='$(prefix)'
+bindir='$(exec_prefix)/bin'
+sbindir='$(exec_prefix)/sbin'
+sysconfdir='$(prefix)/etc'
+localstatedir='$(prefix)/var'
+libdir='$(exec_prefix)/lib'
+datarootdir='$(prefix)/share'
+mandir='$(datarootdir)/man'
+
+enable_debug=false
+enable_warnings=true
+enable_werror=false
+
+for arg; do
+case "$arg" in
+--help) usage ;;
+--prefix=*) prefix=${arg#*=} ;;
+--exec-prefix=*) exec_prefix=${arg#*=} ;;
+--bindir=*) bindir=${arg#*=} ;;
+--sbindir=*) sbindir=${arg#*=} ;;
+--sysconfdir=*) sysconfdir=${arg#*=} ;;
+--localstatedir=*) localstatedir=${arg#*=} ;;
+--libdir=*) libdir=${arg#*=} ;;
+--datarootdir=*) datarootdir=${arg#*=} ;;
+--mandir=*) mandir=${arg#*=} ;;
+--enable-debug) enable_debug=true ;;
+--disable-debug) enable_debug=false ;;
+--enable-warnings) enable_warnings=true ;;
+--disable-warnings) enable_warnings=false ;;
+--enable-werror) enable_werror=true ;;
+--disable-werror) enable_werror=false ;;
+-* ) die "$0: unknown option $arg" ;;
+CC=*) CC=${arg#*=} ;;
+CFLAGS=*) CFLAGS=${arg#*=} ;;
+LDFLAGS=*) LDFLAGS=${arg#*=} ;;
+*=*) ;;
+*) target=$arg ;;
+esac
+done
+
+if $enable_debug; then
+ CFLAGS="$CFLAGS -g"
+fi
+
+if $enable_warnings; then
+ CFLAGS="$CFLAGS -Wall"
+fi
+
+if $enable_werror; then
+ CFLAGS="$CFLAGS -Werror"
+fi
+
+config_vars="
+prefix
+exec_prefix
+bindir
+sbindir
+sysconfdir
+localstatedir
+libdir
+datarootdir
+mandir
+CC
+CFLAGS
+LDFLAGS
+"
+
+echo "# this file is generated by $0" >config.mk
+for var in $config_vars; do
+ eval "value=\$$var"
+ if [ -n "$value" ]; then
+ echo "$var = $value" >> config.mk
+ fi
+done
+
+echo "$PACKAGE is configured. Please run 'make' to build"