changeset 2:5f36d8d69aba

Set up a build framework.
author David A. Holland
date Sun, 19 Feb 2012 18:57:59 -0500
parents 5f96b693f41a
children 290b6543dc2b
files Makefile cgitools/Makefile cgitools/cgitools.mk cgitools/fetch/Makefile cgitools/search/Makefile cgitools/submit/Makefile cgitools/summary/Makefile configure crontools/Makefile crontools/crontools.mk crontools/daily/Makefile crontools/monthly/Makefile crontools/nag/Makefile database/Makefile mailtools/Makefile mailtools/incoming/Makefile mailtools/mailtools.mk mk/base.mk mk/script.mk mk/subdir.mk shelltools/Makefile shelltools/browse-pr/Makefile shelltools/edit-pr/Makefile shelltools/query-pr/Makefile shelltools/shelltools.mk shelltools/sql-pr/Makefile
diffstat 26 files changed, 297 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,6 @@
+TOP=.
+include $(TOP)/mk/base.mk
+
+SUBDIRS=database .WAIT cgitools crontools mailtools shelltools
+
+include $(TOP)/mk/subdir.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgitools/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,6 @@
+TOP=..
+include $(TOP)/mk/base.mk
+
+SUBDIRS=fetch search submit summary
+
+include $(TOP)/mk/subdir.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgitools/cgitools.mk	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,2 @@
+BINDIR=libexec/swallowtail
+BINSUFFIX=.cgi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgitools/fetch/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../cgitools.mk
+
+SCRIPT=fetch.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgitools/search/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../cgitools.mk
+
+SCRIPT=search.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgitools/submit/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../cgitools.mk
+
+SCRIPT=submit.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgitools/summary/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../cgitools.mk
+
+SCRIPT=summary.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,135 @@
+#!/bin/sh
+# configure - configure swallowtail
+# usage: see configure --help
+# note: this is not an autoconf-generated script
+
+help() {
+	cat <<EOF
+Usage: $0 [args]
+where args can be:
+	--help			Print usage
+	--destdir=DIR		Set install chroot [none]
+	--prefix=DIR		Set install prefix [/usr/local]
+	--python=FILE		Set path to Python interpreter [probed]
+	--sh=FILE		Set path to Bourne shell [/bin/sh]
+EOF
+}
+
+usage() {
+	echo "Usage: $0 [args}" 1>&2
+	echo "Try --help" 1>&2
+}
+
+############################################################
+# args
+
+DESTDIR=
+PREFIX=/usr/local
+PYTHON=probed
+SH=/bin/sh
+
+for ARG in "$@"; do
+	case "$ARG" in
+		--help) help; exit;;
+		--destdir=*) DESTDIR=`echo "$ARG" | sed 's/^[^=]*=//'`;;
+		--prefix=*) PREFIX=`echo "$ARG" | sed 's/^[^=]*=//'`;;
+		--python=*) PYTHON=`echo "$ARG" | sed 's/^[^=]*=//'`;;
+		--sh=*) SHELL=`echo "$ARG" | sed 's/^[^=]*=//'`;;
+		*) usage; exit 1;;
+	esac
+done
+
+############################################################
+# check for python
+
+echo -n 'Checking for python... '
+
+nopython() {
+	echo "failed"
+	echo "$0: $1" 1>&2
+	echo "$0: Install python or use --python=PATH option" 1>&2
+	exit 1
+}
+
+testpython() {
+	if [ ! -x "$1" ]; then
+		return 1
+	fi
+	VER=$("$1" -V 2>&1)
+	case "$VER" in
+		"Python "*.*.*) return 0;;
+		"Python "*.*) return 0;;
+		*) ;;
+	esac
+	return 1
+}
+
+FOUND=0
+case "$PYTHON" in
+	probed)
+		for D in \
+		    /usr/local/bin \
+		    /usr/pkg/bin \
+		    /usr/contrib/bin \
+		    /usr/bin \
+		    /opt/bin \
+		; do
+			for PY in \
+				python \
+				python2.7 python27 \
+				python2.6 python26 \
+				python2.5 python25 \
+				python2.4 python24 \
+			; do
+				if testpython $D/$PY; then
+					PYTHON="$D/$PY"
+					FOUND=1
+					break
+				fi
+			done
+			if [ $FOUND = 1 ]; then
+				break
+			fi
+		done
+		if [ $FOUND = 0 ]; then
+			nopython "Cannot find python"
+		fi
+	;;
+	/*)
+		if testpython "$PYTHON"; then
+			:
+		else
+			nopython "$PYTHON does not appear to be python"
+		fi
+	;;
+	*)
+		nopython "$PYTHON is not an absolute path"
+	;;
+esac
+echo "$PYTHON"
+
+############################################################
+# Generate config.*
+
+echo 'Generating config.sed'
+
+cat > config.sed.new <<EOF
+s,@@PYTHON@@,$PYTHON,
+s,@@SH@@,$SH,
+EOF
+
+mv -f config.sed.new config.sed
+
+echo 'Generating config.mk'
+
+cat > config.mk.new <<EOF
+DESTDIR=$DESTDIR
+PREFIX=$PREFIX
+EOF
+
+mv -f config.mk.new config.mk
+
+############################################################
+# done
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crontools/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,6 @@
+TOP=..
+include $(TOP)/mk/base.mk
+
+SUBDIRS=daily monthly nag
+
+include $(TOP)/mk/subdir.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crontools/crontools.mk	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,2 @@
+BINDIR=libexec/swallowtail
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crontools/daily/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../crontools.mk
+
+SCRIPT=daily.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crontools/monthly/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../crontools.mk
+
+SCRIPT=monthly.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crontools/nag/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../crontools.mk
+
+SCRIPT=nag.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/database/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,4 @@
+TOP=..
+include $(TOP)/mk/base.mk
+
+all depend install clean distclean: ;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mailtools/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,6 @@
+TOP=..
+include $(TOP)/mk/base.mk
+
+SUBDIRS=incoming
+
+include $(TOP)/mk/subdir.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mailtools/incoming/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../mailtools.mk
+
+SCRIPT=incoming.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mailtools/mailtools.mk	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,2 @@
+BINDIR=libexec/swallowtail
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/base.mk	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,2 @@
+include $(TOP)/config.mk
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/script.mk	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,19 @@
+.SUFFIXES: .py .pl .sh
+
+PROG=$(SCRIPT:R)$(BINSUFFIX)
+
+all: $(PROG)
+
+$(PROG): $(SCRIPT)
+	$(SED) -f $(TOP)/config.sed < $(SCRIPT) > $@.new
+	mv -f $@.new $@
+
+depend: ;
+
+install:
+	$(INSTALL) -c $(PROG) $(DESTDIR)$(PREFIX)/$(BINDIR)/$(PROG)
+
+clean distclean:
+	rm -f $(PROG) $(PROG).new
+
+.PHONY: all depend install clean distclean
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/subdir.mk	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,15 @@
+TARGETS?=all depend install clean distclean
+
+$(TARGETS): ;
+
+.for _T in $(TARGETS)
+.for _D in $(SUBDIRS)
+.if $(_D) == .WAIT
+$(_T): .WAIT
+.else
+$(_T)-in-$(_D):
+	(cd $(_D) && $(MAKE) $(_T))
+$(_T): $(_T)-in-$(_D)
+.endif
+.endfor
+.endfor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shelltools/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,6 @@
+TOP=..
+include $(TOP)/mk/base.mk
+
+SUBDIRS=browse-pr edit-pr query-pr sql-pr
+
+include $(TOP)/mk/subdir.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shelltools/browse-pr/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../shelltools.mk
+
+SCRIPT=browse.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shelltools/edit-pr/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../shelltools.mk
+
+SCRIPT=edit.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shelltools/query-pr/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../shelltools.mk
+
+SCRIPT=query.py
+
+include $(TOP)/mk/script.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shelltools/shelltools.mk	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,2 @@
+BINDIR=bin
+BINSUFFIX=-pr
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shelltools/sql-pr/Makefile	Sun Feb 19 18:57:59 2012 -0500
@@ -0,0 +1,7 @@
+TOP=../..
+include $(TOP)/mk/base.mk
+include ../shelltools.mk
+
+SCRIPT=sql.sh
+
+include $(TOP)/mk/script.mk