From 87348edd1b6f1e0f79f76d0c95676214396a5fcd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 27 Jul 2009 17:19:52 -0400 Subject: Further refactoring. Mostly tweaking makefiles. Switched to autoconf-style variables. This means I had to change every shell script... --- Makefile.orig | 49 ++++++++++++++-------------- configure | 7 ++-- plugins/repo/Makefile.orig | 44 ++++++++++++++++--------- plugins/repo/commit.d.sh | 2 +- plugins/repo/commit.f.sh | 2 +- plugins/repo/commit.sh | 2 +- plugins/repo/get.d.sh | 2 +- plugins/repo/get.f.sh | 2 +- plugins/repo/get.sh | 2 +- plugins/repo/lib/stdio.sh | 2 +- plugins/users/Makefile.orig | 79 +++++++++++++++++++++++++++++++++++++++++++++ plugins/users/init.sh | 2 +- plugins/users/mkuser.sh | 2 +- plugins/users/rmuser.sh | 2 +- rvs.sh | 4 +-- 15 files changed, 150 insertions(+), 53 deletions(-) create mode 100644 plugins/users/Makefile.orig diff --git a/Makefile.orig b/Makefile.orig index 9b8473d..7a3e131 100644 --- a/Makefile.orig +++ b/Makefile.orig @@ -13,12 +13,13 @@ # 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 INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA +export RM CP SED INSTALL MKDIR INSTALL_PROGRAM INSTALL_DATA SHELL = @SHELL@ prefix = @prefix@ @@ -29,61 +30,61 @@ rvsdir = @rvsdir@/rvs srcdir = @srcdir@ export SHELL rvsdir srcdir -plugins = $(shell find $(srcdir)/plugins/* -maxdepth 0 -type d) +plugins = $(patsubst $(srcdir)/plugins/%,%,\ + $(shell find $(srcdir)/plugins/* -maxdepth 0 -type d)) # phony targets #################################################### -make-plugins = $(addprefix make-,$(plugins)) -install-plugins = $(addprefix install-,$(plugins)) -remove-plugins = $(addprefix remove-,$(plugins)) +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 : rvs install clean remove $(all-plugins) +#.PHONY : install uninstall clean distclean $(all-plugins) +.PHONY : install uninstall clean distclean .SUFFIXES : # targets ########################################################## -rvs : out/rvs out/plugins/plugins - -out/plugins/plugins : $(srcdir)/src/plugins/plugins $(PRE) - $(MKDIR) $(dir $@) - $(PRE) <$< > $@ - $(rvsdir)/plugins : - $(MKDIR) -d $(dir $@) + $(MKDIR) $(dir $@) $(TOUCH) $@ # install/clean/remove ############################################# -install : $(prefix)/$(bindir)/rvs $(rvsdir)/plugins $(install-plugins) +install : $(bindir)/rvs $(rvsdir)/plugins $(install-plugins) clean : - $(RM) -r out + +distclean : clean $(RM) var.sed $(RM) Makefile -remove : +uninstall : $(RM) $(prefix)/$(bindir)/rvs $(RM) -r $(rvsdir) # implicit rules ################################################### # 'build' shell scripts -out/% : $(srcdir)/%.sh +b := @ +% : $(srcdir)/%.sh $(MKDIR) $(dir $@) - $(PRE) <$< > $@ + $(SED) -e 's/$bSHELL@/$(subst /,\/,$(SHELL) )/g' \ + -e 's/$brvsdir@/$(subst /,\/,$(rvsdir))/g' <$< > $@ # install -$(prefix)/$(bindir)/% : out/% +$(bindir)/% : % $(MKDIR) $(dir $@) $(INSTALL_PROGRAM) $< $@ # make plugins -make-% : $(srcdir)/plugins/% - $(MAKE) -C $($< +p-% : plugins/% plugins/%/Makefile $(srcdir)/plugins/% + $(MAKE) -C $< # install plugins -install-% : make-% +install-p-% : plugins/% plugins/%/Makefile $(srcdir)/plugins/% p-% $(MAKE) -C $< install - -#remove-% +# uninstall plugins +uninstall-p-% : plugins/% plugins/%/Makefile + $(MAKE) -C $< uninstall diff --git a/configure b/configure index 3cb0b29..1983a5f 100755 --- a/configure +++ b/configure @@ -15,7 +15,7 @@ name='configure' # rvs configureation script _exec_prefix='$(prefix)' _bindir='$(exec_prefix)/bin' _sbindir='$(exec_prefix)/sbin' - rvsdir='/etc' + _rvsdir='/etc' vars='srcdir SHELL prefix exec_prefix bindir sbindir rvsdir' @@ -72,7 +72,10 @@ Makefiles=`find "${_srcdir}/" -regextype posix-extended \ for orig in $Makefiles; do new=${orig/%.orig/} - new=${new/#$_srcdir/} + new=${new/#$_srcdir\//} + mkdir -p `dirname "$new"` sed -f var.sed < "${orig}" > "${new}" done +#rm var.sed + diff --git a/plugins/repo/Makefile.orig b/plugins/repo/Makefile.orig index 00ffc5f..e4114be 100644 --- a/plugins/repo/Makefile.orig +++ b/plugins/repo/Makefile.orig @@ -13,6 +13,7 @@ name = repo # Variables ######################################################## RM ?= rm -f CP ?= cp +SED ?= sed INSTALL = install MKDIR ?= $(INSTALL) -d #mkdir -p INSTALL_PROGRAM ?= $(INSTALL) @@ -22,10 +23,11 @@ SHELL ?= @SHELL@ rvsdir ?= @rvsdir@/rvs srcdir ?= @srcdir@ -libdir = $(rvsdir)/$(name) +libdir = $(rvsdir)/$(name) reldir = plugins/$(name) -VPATH = $(srcdir)/$(reldir) +mysrcdir = $(srcdir)/$(reldir) +VPATH = $(mysrcdir) # phony targets #################################################### all : $(name) @@ -33,30 +35,42 @@ all : $(name) .SUFFIXES : # targets ########################################################## -srcFiles = $(filter-out %/Makefile.orig,$(shell find $(VPATH)/ -type f)) -shFiles = $(patsubst $(VPATH)/%,%,$(basename $(filter %.sh,$(srcFiles)))) +srcFiles = $(filter-out %/Makefile.orig,$(shell find $(mysrcdir)/ -type f)) -$(name) : $(shFiles) -#$(name) : +shSrcFiles = $(filter %.sh,$(srcFiles)) +shOutFiles = $(patsubst $(mysrcdir)/%,%,$(basename $(shSrcFiles))) +shExeFiles = $(patsubst %,$(libdir)/%, $(shOutFiles) ) +$(name) : $(shOutFiles) -# install/clean/remove ############################################# +# (un)install ###################################################### -#install : +install : $(shExeFiles) + echo $(name) >> $(rvsdir)/plugins + +uninstall : + $(RM) -r $(libdir) + $(SED) -i "/^$(name)$/ d" $(rvsdir)/plugins + +# clean ############################################################ clean : - $(RM) -r ./* - $(RM) Makefile + $(RM) $(shOutFiles) -remove : - $(RM) -r $(libdir) +distclean : clean + $(RM) Makefile # implicit rules ################################################### -# 'build' shell scripts -% : %.sh +b := @ +# build shell scripts +% : $(mysrcdir)/%.sh + $(MKDIR) $(dir $@) + $(SED) 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' <$< > $@ +# workaround... idk why it doesn't match `lib/' +lib/% : $(mysrcdir)/lib/%.sh $(MKDIR) $(dir $@) - $(CP) $< $@ + $(SED) 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' <$< > $@ # install $(libdir)/% : % diff --git a/plugins/repo/commit.d.sh b/plugins/repo/commit.d.sh index 7cfe98a..eabdc78 100644 --- a/plugins/repo/commit.d.sh +++ b/plugins/repo/commit.d.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs commit.d' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/repo/commit.f.sh b/plugins/repo/commit.f.sh index c3a652c..bb4a7d8 100644 --- a/plugins/repo/commit.f.sh +++ b/plugins/repo/commit.f.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs commit.f' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/repo/commit.sh b/plugins/repo/commit.sh index e5e8eba..fbfd7ca 100644 --- a/plugins/repo/commit.sh +++ b/plugins/repo/commit.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs commit' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/repo/get.d.sh b/plugins/repo/get.d.sh index 77107c2..98c490c 100644 --- a/plugins/repo/get.d.sh +++ b/plugins/repo/get.d.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs get.d' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/repo/get.f.sh b/plugins/repo/get.f.sh index f6ab761..37d7b26 100644 --- a/plugins/repo/get.f.sh +++ b/plugins/repo/get.f.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs get.f' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/repo/get.sh b/plugins/repo/get.sh index e1289f7..5618d0a 100644 --- a/plugins/repo/get.sh +++ b/plugins/repo/get.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs get' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/repo/lib/stdio.sh b/plugins/repo/lib/stdio.sh index e20cb7f..f85b7fa 100644 --- a/plugins/repo/lib/stdio.sh +++ b/plugins/repo/lib/stdio.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ #name='rvs stdio' #ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/users/Makefile.orig b/plugins/users/Makefile.orig new file mode 100644 index 0000000..ab109a7 --- /dev/null +++ b/plugins/users/Makefile.orig @@ -0,0 +1,79 @@ +#!/usr/bin/make -f +name = users +# version 0.7.0 +# Copyright (C) 2009 Luke Shumaker +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# Originally written by Luke Shumaker . + + +# Variables ######################################################## +RM ?= rm -f +CP ?= cp +SED ?= sed +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) + +# phony targets #################################################### +all : $(name) +.PHONY : $(name) install clean remove +.SUFFIXES : + +# targets ########################################################## +srcFiles = $(filter-out %/Makefile.orig,$(shell find $(mysrcdir)/ -type f)) + +shSrcFiles = $(filter %.sh,$(srcFiles)) +shOutFiles = $(patsubst $(mysrcdir)/%,%,$(basename $(shSrcFiles))) +shExeFiles = $(patsubst %,$(libdir)/%, $(shOutFiles) ) + +$(name) : $(shOutFiles) + +# (un)install ###################################################### + +install : $(shExeFiles) + echo $(name) >> $(rvsdir)/plugins + +uninstall : + $(RM) -r $(libdir) + $(SED) -i "/^$(name)$/ d" $(rvsdir)/plugins + +# clean ############################################################ + +clean : + $(RM) $(shOutFiles) + +distclean : clean + $(RM) Makefile + +# implicit rules ################################################### + +b := @ +# build shell scripts +% : $(mysrcdir)/%.sh + $(MKDIR) $(dir $@) + $(SED) 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' <$< > $@ +# workaround... idk why it doesn't match `lib/' +lib/% : $(mysrcdir)/lib/%.sh + $(MKDIR) $(dir $@) + $(SED) 's/$bSHELL@/$(subst /,\/,$(SHELL))/g' <$< > $@ + +# install +$(libdir)/% : % + $(MKDIR) $(dir $@) + $(INSTALL_PROGRAM) $< $@ + diff --git a/plugins/users/init.sh b/plugins/users/init.sh index ee570ff..ce1c6fd 100644 --- a/plugins/users/init.sh +++ b/plugins/users/init.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs init' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/users/mkuser.sh b/plugins/users/mkuser.sh index 594c024..de4aeea 100644 --- a/plugins/users/mkuser.sh +++ b/plugins/users/mkuser.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs mkuser' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/plugins/users/rmuser.sh b/plugins/users/rmuser.sh index 598bae9..85ba64a 100644 --- a/plugins/users/rmuser.sh +++ b/plugins/users/rmuser.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs rmuser' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker diff --git a/rvs.sh b/rvs.sh index d26c94d..88c4a9b 100644 --- a/rvs.sh +++ b/rvs.sh @@ -1,4 +1,4 @@ -#!$$SHELL$$ +#!@SHELL@ name='rvs' ver='0.7.0' # Copyright (C) 2009 Luke Shumaker @@ -9,7 +9,7 @@ ver='0.7.0' # # Originally written by Luke Shumaker . -RVSDIR='$$libdir$$' +RVSDIR='@rvsdir@' REPO=`$RVSDIR/repo` error() { -- cgit v1.2.3-54-g00ecf