-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
63 lines (51 loc) · 3.04 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
SHELL ?= /bin/bash -e
#BINARY ?= cmd/server/mendel-web-ui
BINARY ?= mendel-web-ui
# Set these 2 vars before building the pkg, and set Requires in pkg/rpm/mendel-web-ui.spec if necessary
export VERSION ?= 1.2.3
# Release is only needed for the rpm, and only needs to be incremented if you have to rebuild/reinstall this version multiple times due to packaging fixes
export RELEASE ?= 1
# rpmbuild does not give us a good way to set topdir, so use the default location
RPMROOT ?= $(HOME)/rpmbuild
RPMNAME ?= mendel-web-ui
MAC_PKG_IDENTIFIER ?= com.github.genetic-algorithms.pkg.mendel-web-ui
MAC_PKG_INSTALL_DIR ?= /Users/Shared/mendel-web-ui
default: runserver
cmd/server/$(BINARY): cmd/server/*.go cmd/server/*/*.go Makefile
echo 'package main; const MENDEL_UI_VERSION = "$(VERSION)-$(RELEASE)"' > cmd/server/version.go
scripts/build_go
tools/mendel-chg-pw: tools/mendel-chg-pw.go cmd/server/*/*.go
go build -o $@ $<
runserver: cmd/server/$(BINARY) tools/mendel-chg-pw
scripts/stop-mendel-ui.sh || true
scripts/start-mendel-ui.sh dev
# Remember to up VERSION above. If building the rpm on mac, first: brew install rpm
# Note: during rpmbuild, get this benign msg: error: Couldn't exec /usr/local/Cellar/rpm/4.14.1_1/lib/rpm/elfdeps: No such file or directory
rpmbuild:
echo 'package main; const MENDEL_UI_VERSION = "$(VERSION)-$(RELEASE)"' > cmd/server/version.go
mkdir -p $(RPMROOT)/{SOURCES,SRPMS,SRPMS}
rm -f $(RPMNAME)-$(VERSION); ln -s . $(RPMNAME)-$(VERSION) # so the tar file files can have this prefix
rm -f $(RPMROOT)/SOURCES/$(RPMNAME)-*.tar.gz
tar --exclude '.git*' -X .tarignore -H -czf $(RPMROOT)/SOURCES/$(RPMNAME)-$(VERSION).tar.gz $(RPMNAME)-$(VERSION)
rm -rf $(RPMROOT)/BUILD/mendel-web-ui-*
rm -f $(RPMROOT)/SRPMS/$(RPMNAME)*rpm $(RPMROOT)/RPMS/x86_64/$(RPMNAME)*rpm $(RPMROOT)/RPMS/x86_64/$(RPMNAME)*rpm.gz
GOOS=linux rpmbuild --target x86_64-linux -ba pkg/rpm/$(RPMNAME).spec
@#gzip --keep $(RPMROOT)/RPMS/x86_64/$(RPMNAME)-$(VERSION)-$(RELEASE).x86_64.rpm # so we can upload it to the github release
rm -f $(RPMNAME)-$(VERSION) # remove the sym link
# Remember to up VERSION above.
macpkg: cmd/server/$(BINARY) tools/mendel-chg-pw
pkg/mac/populate-pkg-files.sh pkg/mac/mendel-web-ui
pkgbuild --root pkg/mac/$(BINARY) --scripts pkg/mac/scripts --identifier $(MAC_PKG_IDENTIFIER) --version $(VERSION) --install-location $(MAC_PKG_INSTALL_DIR) pkg/mac/build/$(BINARY)-$(VERSION).pkg
@#rm -f pkg/mac/build/$(BINARY)-$(VERSION).pkg.zip
@#cd pkg/mac/build; zip $(BINARY)-$(VERSION).pkg.zip $(BINARY)-$(VERSION).pkg; cd ../../.. # need to be in the same dir to zip
macinstall: macpkg
sudo installer -pkg pkg/mac/build/$(BINARY)-$(VERSION).pkg -target '/Volumes/Macintosh HD'
macpkginfo:
pkgutil --pkg-info $(MAC_PKG_IDENTIFIER)
pkgutil --only-files --files $(MAC_PKG_IDENTIFIER)
upload-release:
#TODO: create target for creating a release: https://developer.github.com/v3/repos/releases/#create-a-release
release: rpmbuild macpkg upload-release
clean:
go clean
.PHONY: default runserver rpmbuild macpkg macinstall macpkginfo upload-release release clean