Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
109 lines (87 sloc) 3.81 KB
# -*- makefile -*-
# This is a makefile that builds Streams into a directory structure
# that makes installation and packaging easier.
# for brace expansion
SHELL=bash
# use the date/time of the latest hg log as the version number. Additional
# tweak: if the repo is stale (outgoing or uncommited changes) or not
# 'default', give it the magic revision number 666.
CURRENT_BRANCH:=$(shell hg branch)
BRANCH_SPEC:=$(shell [ "${CURRENT_BRANCH}" != "default" ] && echo "${CURRENT_BRANCH}.")
STALE:=$(shell (hg outgoing | grep -q '^no changes found$$' && \
test -z "$$(hg diff; hg status -d)") || echo "stale.")
FUNNY:=${BRANCH_SPEC}${STALE}
STREAMS_VERSION:=${FUNNY}$(shell hg log -b "$(CURRENT_BRANCH)" -l1 --template '{date|isodate}\n' | \
cut -d' ' -f1-2 | sed 's/[:-]//g' | sed 's/[^0-9]/./g')
PACKAGE:=rabbitmq-streams-${STREAMS_VERSION}
TMP_DIR:=packaging/tmp
TARGET_DIR:=${PACKAGE}
PACKAGE_FILE:=${CURDIR}/${TMP_DIR}/${PACKAGE}.tar.gz
LIB_TARGET_DIR:=${TMP_DIR}/lib
SBIN_TARGET_DIR:=${TMP_DIR}/sbin
INSTALL_CONFIG_DIR:=${TMP_DIR}/config
PLUGIN_TARGET_DIR:=${TMP_DIR}/plugins
INSTALL_INC_DIR:=${TMP_DIR}/include
# NB: THE SPEC FILE CALLS BACK THIS MAKEFILE!!!
all: package-sources
${MAKE} PACKAGE_FILE="${PACKAGE_FILE}" STREAMS_VERSION="${STREAMS_VERSION}" FUNNY="${FUNNY}" \
-C packaging/RPMS/Fedora clean rpms
package-sources:
mkdir -p ${TMP_DIR}
rm -rf -- ${TMP_DIR}/*
@test -z "${FUNNY}" || \
(read -p "The repo is funny (${FUNNY}), do you really want to continue? (yes/No)? " ans; \
[ "$${ans}" = yes ] || (echo "ABORTING!"; exit 1))
hg clone -r $(CURRENT_BRANCH) . ${TMP_DIR}/${PACKAGE}
(cd ${TMP_DIR}; tar zcf ${PACKAGE_FILE} ${PACKAGE} \
--exclude='*.tar.gz' --exclude='.hg*' --exclude=.svn)
clean:
rm -rf -- ${TARGET_DIR} ${TMP_DIR} ${PACKAGE_FILE}
prepare: prepare-build-dirs prepare-install-dirs
prepare-build-dirs:
mkdir -p ${TARGET_DIR}/config
mkdir -p ${TARGET_DIR}/examples
mkdir -p ${TARGET_DIR}/harness/{java,python}
mkdir -p ${TARGET_DIR}/lib/{erlang/orchestrator,java,python}
prepare-install-dirs:
mkdir -p ${LIB_TARGET_DIR}/{scripts,harness}
mkdir -p ${SBIN_TARGET_DIR}
mkdir -p ${INSTALL_CONFIG_DIR}
mkdir -p ${PLUGIN_TARGET_DIR}
build: build-libs build-orchestrator build-plugins build-other
build-libs: prepare
cp -rpf harness/python/lib/* ${TARGET_DIR}/lib/python
cp -p harness/java/plugin/target/plugin-1.0-SNAPSHOT.jar \
${TARGET_DIR}/harness/java/feedshub_harness.jar
cp -p harness/java/run_plugin.sh ${TARGET_DIR}/harness/java
#FIXME there is some duplication here
cp -pr harness/python/* ${TARGET_DIR}/harness/python
### Build erlang libraries ###
build-orchestrator: build-libs
cp -rp orchestrator/{ebin,include,priv,scripts} ${TARGET_DIR}/lib/erlang/orchestrator
cp -rpL orchestrator/deps/ ${TARGET_DIR}/lib/erlang/orchestrator
#### Package everything else ####
# python dirs get copied whole, for everything else we just copy plugin.js and
# lib FIXME: we should seperate out src and target directories or have some
# other convention that would allow us to automatically copy just the right
# stuff, irrespective of language. Also, packaging tests as well would be
# better.
build-plugins:
for p in plugins/*/; do \
mkdir -p ${TARGET_DIR}/$$p; \
if [ -n "`find \"$$p\" -regex '.*.py'`" ]; then \
cp -rf $$p ${TARGET_DIR}/plugins; \
else \
cp -p $$p/plugin.js ${TARGET_DIR}/$$p; \
cp -prf $$p/lib ${TARGET_DIR}/$$p; \
fi; \
done
build-other:
cp -prf {examples,sbin} ${TARGET_DIR}
install: prepare build
cp -prf ${TARGET_DIR}/lib/* ${LIB_TARGET_DIR}
cp -prf ${TARGET_DIR}/plugins/* ${PLUGIN_TARGET_DIR}
cp -prf ${TARGET_DIR}/sbin/* ${LIB_TARGET_DIR}/scripts
cp -prf ${TARGET_DIR}/examples ${LIB_TARGET_DIR}
cp -prf ${TARGET_DIR}/harness ${LIB_TARGET_DIR}
cd ${LIB_TARGET_DIR}/erlang; ln -s ../harness; ln -s ../plugins;