-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (51 loc) · 2.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
NAME=phoenix-shell
VERSION=$(shell sed -n -e 's/^const VERSION = "\(.*\)"/\1/p' src/${NAME}.go)
RPMREV=$(shell awk '/%define release/ { print $$3;}' rpm/${NAME}.spec.in)
UNAME=$(shell uname)
.PHONY: test
PREFIX?=/usr/local
help:
@echo "The following targets are available:"
@echo "build build the executable"
@echo "clean remove temporary build files"
@echo "install install ${NAME} into ${PREFIX}"
@echo "rpm build an RPM of ${NAME}-${VERSION}-${RPMREV} on ${BUILDHOST}"
@echo "sign sign the RPM package"
@echo "test run all tests under tests/"
@echo "uninstall uninstall ${NAME} from ${PREFIX}"
rpm: spec buildrpm
spec: rpm/${NAME}.spec
rpm/${NAME}.spec: rpm/${NAME}.spec.in
cat $< CHANGES | sed -e "s/VERSION/${VERSION}/" >$@
build: src/${NAME}
src/${NAME}: src/${NAME}.go
if [ ${UNAME} = "Darwin" ]; then \
CC=clang; \
fi; \
CC=$${CC} go build -o src/${NAME} src/${NAME}.go
buildrpm: packages/rpms/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm
linux_binary:
ssh ${BUILDHOST} "mkdir -p ${NAME}"
rsync -e ssh -avz --exclude packages/ --exclude .git/ . ${BUILDHOST}:${NAME}/.
ssh ${BUILDHOST} "cd ${NAME}/src && rm -f ${NAME} && GOROOT=~/go ~/go/bin/go build ${NAME}.go"
packages/rpms/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm: spec linux_binary
ssh ${BUILDHOST} "cd ${NAME}/rpm && sh mkrpm.sh ${NAME}.spec"
scp ${BUILDHOST}:redhat/RPMS/*/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm packages/rpms/
ls packages/rpms/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm;
sign: packages/rpms/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm.asc
packages/rpms/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm.asc: packages/rpms/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm
gpg -b -a packages/rpms/${NAME}-${VERSION}-${RPMREV}.x86_64.rpm
version:
echo ${VERSION} > packages/version
install: build
mkdir -p ${PREFIX}/bin ${PREFIX}/share/man/man1
install -c -m 0555 src/${NAME} ${PREFIX}/bin/${NAME}
install -c -m 0555 doc/${NAME}.1 ${PREFIX}/share/man/man1/${NAME}.1
uninstall:
rm -f ${PREFIX}/bin/${NAME} ${PREFIX}/share/man/man1/${NAME}.1
test: src/${NAME}
@cd tests && for t in *.sh; do \
sh $${t}; \
done
clean:
rm -f src/${NAME} rpm/${NAME}.spec