summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2009-07-30 12:02:04 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-06-26 00:30:13 -0600
commit56d4ab21576bcc3049f62374597b7a5f47a560ab (patch)
treecb9fd258c607ee0105ab057e6f05720d938b5e75
parent7f78b595ce3baf3ade82e546a3ed7cfba41c8ef9 (diff)
tweak makefiles
-rw-r--r--Makefile.in101
-rwxr-xr-xconfigure21
-rw-r--r--plugins/repo/Makefile.in56
-rw-r--r--rvs.sh33
4 files changed, 122 insertions, 89 deletions
diff --git a/Makefile.in b/Makefile.in
index 7a3e131..e26131a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,5 @@
#!/usr/bin/make -f
-# rvs Makefile
+name = @name@
# version 0.7.0
# Copyright (C) 2009 Luke Shumaker
# This program is distributed in the hope that it will be useful,
@@ -10,81 +10,86 @@
# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.
-# Variables ########################################################
-RM = rm -f
-CP = cp
-SED = sed
-INSTALL = install
-MKDIR = $(INSTALL) -d #mkdir -p
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL) -m 644
-TOUCH = touch
-export RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA
-
-SHELL = @SHELL@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-sbindir = @sbindir@
-rvsdir = @rvsdir@/rvs
-srcdir = @srcdir@
-export SHELL rvsdir srcdir
-
+export rvs = $(name)
+# Directories ######################################################
+srcdir = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+dirs = $(srcdir) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir)
+export srcdir prefix exec_prefix bindir sbindir libexecdir
+
+# Programs #########################################################
+RVS = @RVS@
+SHELL = @SHELL@
+RM = rm -f
+CP = cp
+SED = sed
+INSTALL = install
+MKDIR = $(INSTALL) -d #mkdir -p
+INSTALL_PROGRAM = $(INSTALL)
+INSTALL_DATA = $(INSTALL) -m 644
+TOUCH = touch
+export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH
+
+# plugin targets ###################################################
plugins = $(patsubst $(srcdir)/plugins/%,%,\
$(shell find $(srcdir)/plugins/* -maxdepth 0 -type d))
-
-# phony targets ####################################################
make-plugins = $(addprefix p-,$(plugins))
install-plugins = $(addprefix install-p-,$(plugins))
remove-plugins = $(addprefix remove-p-,$(plugins))
all-plugins = $(make-plugins) $(install-plugins) $(remove-plugins)
-all : rvs $(make-plugins)
+
+# phony targets ####################################################
+all : $(rvs) $(make-plugins)
#.PHONY : install uninstall clean distclean $(all-plugins)
.PHONY : install uninstall clean distclean
.SUFFIXES :
# targets ##########################################################
+b := @
+$(rvs) : $(srcdir)/rvs.sh
+ $(SED) \
+ -e 's/$bSHELL@/$(subst /,\/,$(SHELL) )/g' \
+ -e 's/$blibexecdir@/$(subst /,\/,$(libexecdir))/g' \
+ -e 's/$bname@/$(subst /,\/,$(name) )/g' \
+ < $< > $@
+
+$(bindir)/$(rvs) : $(rvs) $(bindir)
+ $(INSTALL_PROGRAM) $< $@
-$(rvsdir)/plugins :
- $(MKDIR) $(dir $@)
+$(libexecdir)/$(rvs)/plugins : $(rvsdir)
$(TOUCH) $@
# install/clean/remove #############################################
-install : $(bindir)/rvs $(rvsdir)/plugins $(install-plugins)
+install : install-$(name) $(rvsdir)/plugins $(install-plugins)
+install-$(name) : $(bindir)/$(rvs)
+
+
+uninstall :
+ $(RM) $(prefix)/$(bindir)/rvs
+ $(RM) -r $(libexecdir)/$(rvs)
clean :
distclean : clean
- $(RM) var.sed
$(RM) Makefile
-
-uninstall :
- $(RM) $(prefix)/$(bindir)/rvs
- $(RM) -r $(rvsdir)
+ $(RM) $(rvs)
# implicit rules ###################################################
-# 'build' shell scripts
-b := @
-% : $(srcdir)/%.sh
- $(MKDIR) $(dir $@)
- $(SED) -e 's/$bSHELL@/$(subst /,\/,$(SHELL) )/g' \
- -e 's/$brvsdir@/$(subst /,\/,$(rvsdir))/g' <$< > $@
-
-# install
-$(bindir)/% : %
- $(MKDIR) $(dir $@)
- $(INSTALL_PROGRAM) $< $@
+$(dirs) :
+ $(MKDIR) $@
-# make plugins
-p-% : plugins/% plugins/%/Makefile $(srcdir)/plugins/%
+# make/install/uninstall plugins
+p-% : plugins/% plugins/%/Makefile $(srcdir)/plugins/%
$(MAKE) -C $<
-# install plugins
-install-p-% : plugins/% plugins/%/Makefile $(srcdir)/plugins/% p-%
+install-p-% : plugins/% plugins/%/Makefile $(srcdir)/plugins/% p-%
$(MAKE) -C $< install
-# uninstall plugins
uninstall-p-% : plugins/% plugins/%/Makefile
$(MAKE) -C $< uninstall
diff --git a/configure b/configure
index 0bcd79b..90f4fe6 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
name='configure' # rvs configureation script
# version 0.7.0
# Copyright (C) 2009 Luke Shumaker
@@ -9,13 +9,15 @@ name='configure' # rvs configureation script
#
# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.
- _srcdir=$(readlink -f `dirname "$0"`)
+ _name='rvs'
+ _RVS='$(bindir)/$(rvs)'
_SHELL='/bin/sh'
_prefix='/usr/local'
_exec_prefix='$(prefix)'
_bindir='$(exec_prefix)/bin'
_sbindir='$(exec_prefix)/sbin'
- _rvsdir='/etc'
+ _libexecdir='$(exec_prefix)/libexec'
+ _srcdir=$(readlink -f `dirname "$0"`)
vars='srcdir SHELL prefix exec_prefix bindir sbindir rvsdir'
@@ -58,8 +60,12 @@ for var in $vars; do
var1="_$var"
val=${!var1}
- var=${var//':'/'\:'}
- val=${val//':'/'\:'}
+ # GNU bash optimized version
+ var=${var//':'/'\:'}
+ val=${val//':'/'\:'}
+ # POSIX version
+ #var=`echo "$var" | sed 's@:@\\:@g'`
+ #val=`echo "$val" | sed 's@:@\\:@g'`
echo "s:@$var@:$val:g" >> var.sed
done
@@ -71,11 +77,10 @@ Makefiles=`find "${_srcdir}/" -regextype posix-extended \
-regex '(.*/)?Makefile\.in' -type f`
for orig in $Makefiles; do
- new=${orig/%.orig/}
+ new=${orig/%.in/}
new=${new/#$_srcdir\//}
mkdir -p `dirname "$new"`
sed -f var.sed < "${orig}" > "${new}"
done
-#rm var.sed
-
+rm var.sed
diff --git a/plugins/repo/Makefile.in b/plugins/repo/Makefile.in
index 32a07dd..8105b75 100644
--- a/plugins/repo/Makefile.in
+++ b/plugins/repo/Makefile.in
@@ -10,70 +10,70 @@ name = repo
# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.
-# Variables ########################################################
-RM ?= rm -f
+export rvs ?= @name@
+# Directories ######################################################
+srcdir ?= @srcdir@
+prefix ?= @prefix@
+exec_prefix ?= @exec_prefix@
+bindir ?= @bindir@
+sbindir ?= @sbindir@
+libexecdir ?= @libexecdir@
+#export srcdir prefix exec_prefix bindir sbindir libexecdir
+
+# Programs #########################################################
+RVS ?= @RVS@
+SHELL ?= @SHELL@
+RM ?= rm
CP ?= cp
SED ?= sed
-INSTALL = install
+INSTALL ?= install
MKDIR ?= $(INSTALL) -d #mkdir -p
INSTALL_PROGRAM ?= $(INSTALL)
INSTALL_DATA ?= $(INSTALL) -m 644
-
-SHELL ?= @SHELL@
-rvsdir ?= @rvsdir@/rvs
-srcdir ?= @srcdir@
-
-libdir = $(rvsdir)/$(name)
-reldir = plugins/$(name)
-
-mysrcdir = $(srcdir)/$(reldir)
-VPATH = $(mysrcdir)
+TOUCH ?= touch # This file doesn't use touch
+#export RVS SHELL RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA TOUCH
# phony targets ####################################################
all : $(name)
.PHONY : $(name) install uninstall clean distclean
.SUFFIXES :
-# targets ##########################################################
+# main #############################################################
srcFiles = $(filter-out %/Makefile.in,$(shell find $(mysrcdir)/ -type f))
shSrcFiles = $(filter %.sh,$(srcFiles))
-shOutFiles = $(patsubst $(mysrcdir)/%,%,$(basename $(shSrcFiles)))
-shExeFiles = $(patsubst %,$(libdir)/%, $(shOutFiles) )
+shOutFiles = $(patsubst $(mysrcdir)/%,out/%,$(basename $(shSrcFiles)))
+
+mysrcdir = $(srcdir)/plugins/$(name)
+myoutdor = out
$(name) : $(shOutFiles)
# (un)install ######################################################
-install : $(shExeFiles)
- echo $(name) >> $(rvsdir)/plugins
+install : all
+ $(RVS) install $(name) $(myoutdir)
uninstall :
- $(RM) -r $(libdir)
- $(SED) -i "/^$(name)$/ d" $(rvsdir)/plugins
+ $(RVS) uninstall $(name)
# clean ############################################################
clean :
- $(RM) $(shOutFiles)
distclean : clean
$(RM) Makefile
+ $(RM) -r out
# implicit rules ###################################################
b := @
# build shell scripts
-% : $(mysrcdir)/%.sh
+$(myoutdir)/% : $(mysrcdir)/%.sh
$(MKDIR) $(dir $@)
$(SED) 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' <$< > $@
# workaround... idk why it doesn't match `lib/'
-lib/% : $(mysrcdir)/lib/%.sh
+$(myoutdir)/lib/% : $(mysrcdir)/lib/%.sh
$(MKDIR) $(dir $@)
$(SED) 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' <$< > $@
-# install
-$(libdir)/% : %
- $(MKDIR) $(dir $@)
- $(INSTALL_PROGRAM) $< $@
-
diff --git a/rvs.sh b/rvs.sh
index d020b90..3ac3526 100644
--- a/rvs.sh
+++ b/rvs.sh
@@ -1,5 +1,5 @@
#!@SHELL@
-name='rvs'
+name='@name@'
ver='0.7.0'
# Copyright (C) 2009 Luke Shumaker
# This program is distributed in the hope that it will be useful,
@@ -9,7 +9,7 @@ ver='0.7.0'
#
# Originally written by Luke Shumaker <lukeshu@sbcglobal.net>.
-RVSDIR='@rvsdir@'
+RVSDIR="@libexecdir@/$name"
error() {
echo "$name: $1" >> /dev/stderr
@@ -48,7 +48,7 @@ init() {
export REPO=.rvs/$plugin
echo 'foo2'
if [ -e "$RVSDIR/$plugin/init" ]; then
- $RVSDIR/$plugin/init
+ "$RVSDIR/$plugin/init"
fi
echo 'foo3'
done < $repo/plugins
@@ -57,13 +57,35 @@ init() {
fi
}
+install() {
+ id=$1
+ dir=${2-$id}
+ name=`echo $id | sed 's/-.*$//'`
+ if (grep "^$name-" "$RVSDIR/plugins" &> /dev/null); then
+ # an entry for this plugin already exists, though possibly a
+ # different version
+ sed -i "s/^$name-.*$/$id/" "$RVSDIR/plugins"
+ else
+ echo "$id" >> "$RVSDIR/plugins"
+ fi
+ cp -rp "$dir" "$RVSDIR/$id"
+}
+
+uninstall() {
+ id=$1
+ sed -i "/^$id$/ d" "$RVSDIR/plugins"
+ rm -rf "$RVSDIR/$id"
+}
+
# START OPTION HANDLING #
com=$1;
# END OPTION HANDLING #
case "$com" in
'') error 'no command specified';;
'repo') repo; exit $?;;
- 'init') init;;
+ 'init') init; exit $?;;
+ 'install') shift; install $@; exit $?;;
+ 'uninstall') shift; uninstall $@; exit $?;;
*)
if [ -f "$RVSDIR/$com" ]; then
export RVSDIR
@@ -72,10 +94,11 @@ case "$com" in
else
while read plugin; do
if [ -f "$RVSDIR/$plugin/$com" ]; then
+ done='yes'
export RVSDIR=$RVSDIR/$plugin
export REPO=`repo`/$plugin
$RVSDIR/$@
- done='yes'
+ exit $?
break
fi
done < $REPO/plugins