From 97b2c8aac2b80c4ed85d896dd0da79185d38081e Mon Sep 17 00:00:00 2001 From: Bart Trojanowski Date: Thu, 27 Sep 2007 20:55:20 -0400 Subject: [PATCH] differentiate between installing in $HOME and system wide Signed-off-by: Bart Trojanowski --- Makefile | 130 ++++++++++++++++++++++++++++++++++++-------------- README | 62 +++++++++++++++++++++--- config.mk | 39 +++++++++++++++ install-wmiirc-lua | 48 +++++++++++++++++++ luaeventloop/Makefile | 10 +++- luaixp/Makefile | 10 +++- 6 files changed, 253 insertions(+), 46 deletions(-) create mode 100644 config.mk create mode 100755 install-wmiirc-lua diff --git a/Makefile b/Makefile index fe8144b..af72bd1 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,52 @@ +include config.mk + MAN = wmii.3lua -.PHONY: all luaixp luaeventloop clean tags install -all: luaixp luaeventloop +# ------------------------------------------------------------------------ +# main target + +.PHONY: all help libs luaixp luaeventloop docs man clean tags install install-user +all: libs man + +help: + @echo "make [target]" + @echo + @echo " general targets" + @echo " all - build everything" + @echo " libs - build libraries" + @echo " docs - build documentation" + @echo " clean - clean up build" + @echo " install - install in system dir" + @echo " install-user - install in user home dir" + @echo + @echo " development targets" + @echo " tags - build ctags index" + @echo " cscope - build cscope index" -luaixp luaeventloop: +xxx: + ${MAKE} install DESTDIR=$(shell pwd)/debian/tmp PREFIX=/usr + +# ------------------------------------------------------------------------ +# building + +libs: luaeventloop clean +luaeventloop luaixp: ${MAKE} -C $@ +docs: man +man: ${MAN} +${MAN}: core/wmii.lua + ${POD2MAN} \ + --name=wmii \ + --center="WMII Lua Integration" \ + --section=3lua \ + --release="wmii 3.6" \ + $< $@ + +# ------------------------------------------------------------------------ +# cleaning + clean: -rm -f *~ */*~ -rm -f wmii.3lua @@ -14,6 +54,57 @@ clean: -${MAKE} -C luaixp clean -${MAKE} -C luaeventloop clean +# ------------------------------------------------------------------------ +# installing + +# +# install system wide +# +install: ${MAN} + # create directories + ${INSTALL} -d ${ALL_INSTALL_DIRS} + # + # install libraries + ${MAKE} -C luaixp install + ${MAKE} -C luaeventloop install + # + # install core and plugin lua scripts + ${INSTALL} -m 0644 -t ${CORE_LUA_DIR} core/*.lua + ${INSTALL} -m 0644 -t ${PLUGIN_LUA_DIR} plugins/*.lua + # + # install template files + ${INSTALL} -m 0755 -T wmiirc.lua ${RC_DIR}/wmiirc + ${INSTALL} -m 0644 -t ${RC_DIR} ${MAN} + # + # install scripts + ${INSTALL} -m 0744 -t ${BIN_DIR} install-wmiirc-lua + +# +# install in user directory +# +install-user: +ifeq ($(shell pwd),$(wildcard ~/.wmii-3.5)) + @echo "You're already in the ~/.wmii-3.5/ directory" +else + ${INSTALL} -d ${ALL_HOME_DIRS} + @if test -f ${HOME_WMII}/wmiirc ; then \ + echo "NOTE: you might want to look at ${HOME_WMII}/wmiirc.dist" ; \ + ${INSTALL} -T -m 0744 -b wmiirc.lua ${HOME_WMII}/wmiirc.dist ; \ + else \ + echo "Installing new ${HOME_WMII}/wmiirc" ; \ + ${INSTALL} -T -m 0744 -b wmiirc.lua ${HOME_WMII}/wmiirc ; \ + fi + ${INSTALL} -m 0644 -b -t ${HOME_CORE} core/*.lua + ${INSTALL} -m 0644 -b -t ${HOME_PLUGINS} plugins/*.lua + ${INSTALL} -m 0644 -b -t ${HOME_WMII} ${MAN} + ${MAKE} -C luaixp install-user + ${MAKE} -C luaeventloop install-user + +install-user: ${MAN} +endif + +# ------------------------------------------------------------------------ +# tags and cscope cscope.files:: find . -name '*.[ch]' -o -name '*.lua' | grep -v -e CVS -e SCCS > cscope.files @@ -25,36 +116,3 @@ tags: cscope.out rm -f tags xargs -n 50 ctags -a < cscope.files - -install: -ifeq ($(shell pwd),$(wildcard ~/.wmii-3.5)) - @echo "You're already in the ~/wmii-3.5/ directory" -else - mkdir -p ~/.wmii-3.5/core/ ~/.wmii-3.5/plugins/ - @if test -f ~/.wmii-3.5/wmiirc ; then \ - echo "NOTE: you might want to look at ~/.wmii-3.5/wmiirc.dist" ; \ - install -b wmiirc.lua ~/.wmii-3.5/wmiirc.dist ; \ - chmod +x ~/.wmii-3.5/wmiirc.dist ; \ - else \ - echo "Installing new ~/.wmii-3.5/wmiirc" ; \ - install -b wmiirc.lua ~/.wmii-3.5/wmiirc ; \ - chmod +x ~/.wmii-3.5/wmiirc ; \ - fi - install -b -m 640 -t ~/.wmii-3.5/core/ core/*.lua - install -b -m 640 -t ~/.wmii-3.5/plugins/ plugins/*.lua - install -b -m 640 -t ~/.wmii-3.5 ${MAN} - ${MAKE} -C luaixp install - ${MAKE} -C luaeventloop install - -install: ${MAN} -endif - - -man: ${MAN} -${MAN}: core/wmii.lua - pod2man \ - --name=wmii \ - --center="WMII Lua Integration" \ - --section=3lua \ - --release="wmii 3.6" \ - $< $@ diff --git a/README b/README index 8d9730d..e75f6c8 100644 --- a/README +++ b/README @@ -39,8 +39,8 @@ and we don't officially support anything older then wmii from the hg (mercurial) repository. -Installation ------------- +Building prerequisites +---------------------- If you are running Debian (or derivative) these steps may help you: 1) install Debian packages that you need to build @@ -70,13 +70,63 @@ If you are running Debian (or derivative) these steps may help you: sudo make install cd .. - 3) build wmiirc-lua - # you can skip this step if you already have wmiirc-lua :) +Installation +------------ +Now that you have the prerequisites installed, you can chose one of the +following options. + + A. Make a Debian package + + A.1. build the actual DEB + + # (optional) get the sources + git clone git://repo.or.cz/wmiirc-lua.git/ + cd wmiirc-lua + + make deb + + A.2. install deb + + # as root + dpkg -i wmiirc-lua*.deb + + A.3. Setting up $HOME for wmiirc-lua + + # as the user run + install-wmiirc-lua + + B. Install system wide, and in $HOME + + B.1. get the sources + + # (optional) get the sources + git clone git://repo.or.cz/wmiirc-lua.git/ + cd wmiirc-lua + + # (optional) configure where things go + vim config.mk + + B.2. Installing software in shared directories + + # build as anyone + make + + # install system-wide as root + make install + + B.3. Setting up $HOME for wmiirc-lua + + # as the user run + install-wmiirc-lua + + C. Install in $HOME only + + # (optional) get the sources git clone git://repo.or.cz/wmiirc-lua.git/ cd wmiirc-lua - - make install + + make install-user Running wmii diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..4d1b0af --- /dev/null +++ b/config.mk @@ -0,0 +1,39 @@ +# ------------------------------------------------------------------------ +LUA_VERSION = 5.1 + +CC = cc +INSTALL = install +POD2MAN = pod2man + +# ------------------------------------------------------------------------ +# system directories + +DESTDIR = +PREFIX = /usr/local + +CORE_LIB_DIR = ${DESTDIR}${PREFIX}/lib/lua/${LUA_VERSION} +CORE_LUA_DIR = ${DESTDIR}${PREFIX}/share/lua/${LUA_VERSION} + +PLUGIN_LIB_DIR = ${DESTDIR}${PREFIX}/lib/lua/${LUA_VERSION}/wmii +PLUGIN_LUA_DIR = ${DESTDIR}${PREFIX}/share/lua/${LUA_VERSION}/wmii + +BIN_DIR = ${DESTDIR}${PREFIX}/bin +RC_DIR = ${DESTDIR}/etc/X11/wmii-3.5 + +ALL_INSTALL_DIRS= ${CORE_LIB_DIR} \ + ${CORE_LUA_DIR} \ + ${PLUGIN_LIB_DIR} \ + ${PLUGIN_LUA_DIR} \ + ${BIN_DIR} \ + ${RC_DIR} + +# ------------------------------------------------------------------------ +# home directories + +HOME_WMII = ~/.wmii-3.5 +HOME_CORE = ${HOME_WMII}/core +HOME_PLUGINS = ${HOME_WMII}/plugins + +ALL_HOME_DIRS = ${HOME_CORE} \ + ${HOME_PLUGINS} + diff --git a/install-wmiirc-lua b/install-wmiirc-lua new file mode 100755 index 0000000..7f37968 --- /dev/null +++ b/install-wmiirc-lua @@ -0,0 +1,48 @@ +#!/bin/bash +# Copyright (c) 2007, Bart Trojanowski +# +# This script installs wmiirc-lua files into $HOME/.wmii-3.5 + +SRC=/etc/X11/wmii-3.5 +DEST=${HOME}/.wmii-3.5 + +do_install () { + INSTALL="install $@" + + ${INSTALL} -d ${DEST} + for f in "$SRC"/* ; do + ${INSTALL} -t ${DEST} ${f} + done +} + +while true ; do + cmd=$1 ; shift + case $cmd in + --force) + do_install + ;; + --backup) + do_install -b + ;; + *) + break + ;; + esac +done + +if [ -f "${SRC}/wmiirc" ] ; then + echo >&2 "System wide files for wmiirc-lua not installed." + exit 1 +fi + +if [ -f "${DEST}/wmiirc" ] ; then + echo >&2 "You already have files installed in ${DEST}." + echo >&2 "" + echo >&2 "Please select one of the following options and rerun this script:" + echo >&2 "" + echo >&2 " $0 --force - overwrite existing files" + echo >&2 " $0 --backup - backup existing files" + exit 1 +fi + + diff --git a/luaeventloop/Makefile b/luaeventloop/Makefile index 9b8bb82..0637941 100644 --- a/luaeventloop/Makefile +++ b/luaeventloop/Makefile @@ -1,3 +1,5 @@ +include ../config.mk + SRCS = lel_main.c lel_debug.c lel_util.c lel_instance.c OBJS = $(SRCS:.c=.o) @@ -28,5 +30,9 @@ clean: -rm -f *.o *.so *~ install: ${TARGET} - mkdir -p ~/.wmii-3.5/core/ - install -b -t ~/.wmii-3.5/core/ ${TARGET} + ${INSTALL} -d ${CORE_LIB_DIR} + ${INSTALL} -b -t ${CORE_LIB_DIR} ${TARGET} + +install-user: ${TARGET} + ${INSTALL} -d ${HOME_CORE} + ${INSTALL} -m 0744 -b -t ${HOME_CORE} ${TARGET} diff --git a/luaixp/Makefile b/luaixp/Makefile index b600f4d..974a060 100644 --- a/luaixp/Makefile +++ b/luaixp/Makefile @@ -1,3 +1,5 @@ +include ../config.mk + SRCS = lixp_main.c lixp_debug.c lixp_util.c lixp_instance.c OBJS = $(SRCS:.c=.o) @@ -30,5 +32,9 @@ clean: -rm -f *.o *.so *~ install: ${TARGET} - mkdir -p ~/.wmii-3.5/core/ - install -b -t ~/.wmii-3.5/core/ ${TARGET} + ${INSTALL} -d ${CORE_LIB_DIR} + ${INSTALL} -b -t ${CORE_LIB_DIR} ${TARGET} + +install-user: ${TARGET} + ${INSTALL} -d ${HOME_CORE} + ${INSTALL} -m 0744 -b -t ${HOME_CORE} ${TARGET} -- 2.11.4.GIT