jw-pkg/conf/jcs/jcs.mk

122 lines
3.6 KiB
Makefile
Raw Normal View History

SHELL = /bin/sh
WD := $(shell pwd)
MOD := $(shell pwd | xargs basename)
LOG_DIR := $(shell . /etc/jcs/jcs.conf; echo $$jcs_log_dir)
INSTALL_LOG := $(LOG_DIR)/install.log
SETUP_LOG := $(LOG_DIR)/setup.log
TEE := /usr/bin/tee
BINDIR := /usr/local/bin
SBINDIR := /usr/local/bin
INF := $(wildcard *.inf)
INF_DONE := $(addsuffix .done,$(basename $(INF)))
INF_SU_DONE := $(addsuffix .su_done,$(basename $(INF)))
JCS_HTTP_PATH := $(shell . /etc/jcs/jcs.conf; echo $$jcs_http_path)
JCS = /opt/jw-build/bin/jcs
export SETUP_LOG INSTALL_LOG TEE BINDIR SBINDIR
all:
define recurse_subdirs
@set -e ;\
TARGET=$@ ;\
N="`echo $(SUBDIRS) | wc -w`" ;\
I=1 ;\
while [ $$I -le $$N ] ; do \
SUBDIR="`echo $(SUBDIRS) | cut -d' ' -f$$I`" ;\
$(MAKE) -C $$SUBDIR $$TARGET;\
I=`expr $$I + 1`;\
done
endef
%.done: %.inf
sudo $(JCS) install $<
touch $@
%.su_done: %.inf
sudo $(JCS) install -b setup -f $<
touch $@
install_inf: $(INF_DONE)
install_inf.old: checkroot checkdirs
@echo "####" checking installation information files ... ;\
if [ -n "`find . -name '*.inf' -maxdepth 1`" ] ; then \
sudo $(JCS) install *.inf ;\
fi | $(TEE) -a $(INSTALL_LOG)
install_link:
install_link.old: checkroot checkdirs
@echo "####" checking link information files ... ;\
if [ -e link.sh ] ; then \
$(JCS) linkout link.sh -b install ;\
fi | $(TEE) -a $(INSTALL_LOG)
setup_inf: $(INF_SU_DONE)
setup_inf.old: checkroot checkdirs
@echo "####" checking installation information files ... ;\
if [ -n "`find . -name '*.inf' -maxdepth 1`" ] ; then \
sudo $(JCS) install -b setup -f *.inf ;\
fi | $(TEE) -a $(SETUP_LOG)
setup_link: checkroot checkdirs
@echo "####" checking link information files ... ;\
if [ -e link.sh ] ; then \
$(JCS) linkout -f -b setup link.sh ;\
fi | $(TEE) -a $(SETUP_LOG)
test_inf: checkdirs
@echo "####" testing installation information files ... ;\
if [ -n "`find . -name '*.inf' -maxdepth 1`" ] ; then \
sudo $(JCS) install *.inf -t ;\
fi | $(TEE) -a $(INSTALL_LOG)
test_link: checkdirs
@echo "####" testing link information files ... ;\
if [ -e link.sh ] ; then \
$(JCS) linkout -t link.sh ;\
fi | $(TEE) -a $(INSTALL_LOG)
get: checkdirs
@echo "####" getting files. ;\
if [ -n "$(GETFILES)" ] ; then $(JCS) get $(GETFILES) ; fi
getall: $(LOCAL_GET) get $(LOCAL_POST_GET)
$(recurse_subdirs)
checksum: checkroot # TODO integrate tripwire
@if [ "$$cfg_use_checksum" = TRUE ] ; then \
echo "####" updating checksum database ... ;\
$$update_checksum_command ;\
fi
install: checkroot $(LOCAL_INSTALL) install_inf install_link $(LOCAL_POST_INSTALL) checksum
$(recurse_subdirs)
setup: checkroot $(LOCAL_SETUP) setup_inf setup_link $(LOCAL_POST_SETUP) checksum
$(recurse_subdirs)
test: $(LOCAL_TEST) test_inf test_link $(LOCAL_POST_TEST)
$(recurse_subdirs)
dist: clean
cd ..;\
find $(MOD) -type f -o -type l | \
grep -ve "CVS\|trash\|$(MOD)/setup" | \
xargs tar -cvzf $(MOD).tar.gz ;\
mv $(MOD).tar.gz $(MOD)
checkroot:
# @if [ `whoami` != root ] ; then echo "Only root can do this." >&2; exit 1; fi
checkdirs:
@test -f /etc/jcs/jcs.conf || exit 1 ;\
test -d `dirname $(SETUP_LOG)` || mkdir -p `dirname $(SETUP_LOG)` ;\
test -d `dirname $(INSTALL_LOG)` || mkdir -p `dirname $(INSTALL_LOG)`
clean: $(LOCAL_CLEAN)
$(recurse_subdirs) ;\
rm -f *~ *.swp *.rep .\#* *.done *.su_done $(MOD).tar.gz default.cache 2>/dev/null