13544: Makefile massive cleanup, more specialized targets
[arvados-workbench2.git] / Makefile
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 APP_NAME?=arvados-workbench2
6
7 # GIT_TAG is the last tagged stable release (i.e. 1.2.0)
8 GIT_TAG?=$(shell git describe --abbrev=0)
9
10 # TS_GIT is the timestamp in the current directory (i.e. 1528815021).
11 # Note that it will only change if files change.
12 TS_GIT?=$(shell git log -n1 --first-parent "--format=format:%ct" .)
13
14 # DATE_FROM_TS_GIT is the human(ish)-readable version of TS_GIT
15 # 1528815021 -> 20180612145021
16 DATE_FROM_TS_GIT?=$(shell date -ud @$(TS_GIT) +%Y%m%d%H%M%S)
17
18 # NIGHTLY_VERSION uses all the above to produce X.Y.Z.timestamp
19 # something in the lines of 1.2.0.20180612145021, this will be the package version
20 NIGHTLY_VERSION?=$(GIT_TAG).$(DATE_FROM_TS_GIT)
21
22 DESCRIPTION=Arvados Workbench2 - Arvados is a free and open source platform for big data science.
23 MAINTAINER=Ward Vandewege <wvandewege@veritasgenetics.com>
24
25 # DEST_DIR will have the build package copied.
26 DEST_DIR=/var/www/arvados-workbench2/workbench2/
27
28 export WORKSPACE?=$(shell pwd)
29
30 .PHONY: help clean* yarn-install test build packages packages-with-version 
31
32 help:
33         @echo >&2
34         @echo >&2 "There is no default make target here.  Did you mean 'make test'?"
35         @echo >&2
36         @echo >&2 "More info:"
37         @echo >&2 "  Installing              --> http://doc.arvados.org/install"
38         @echo >&2 "  Developing/contributing --> https://dev.arvados.org"
39         @echo >&2 "  Project home            --> https://arvados.org"
40         @echo >&2
41         @false
42
43 clean-deb:
44         rm -f $(WORKSPACE)/*.deb
45
46 clean-rpm:
47         rm -f $(WORKSPACE)/*.rpm
48
49 clean-node-modules:
50         rm -rf $(WORKSPACE)/node_modules
51
52 clean: clean-rpm clean-deb clean-node-modules
53
54 yarn-install:
55         yarn install
56
57 test: yarn-install
58         yarn test       --no-watchAll --bail --ci
59
60 build: yarn-install test
61         yarn build
62
63 # use FPM to create DEB and RPM with a version (usually triggered from CI to make a release)
64 packages-with-version: build
65         fpm \
66          -s dir \
67          -t deb \
68          -n "$(APP_NAME)" \
69          -v "$(VERSION)" \
70          --maintainer="$(MAINTAINER)" \
71          --description="$(DESCRIPTION)" \
72          --deb-no-default-config-files \
73         $(WORKSPACE)/build/=DEST_DIR
74         fpm \
75          -s dir \
76          -t rpm \
77          -n "$(APP_NAME)" \
78          -v "$(VERSION)" \
79          --maintainer="$(MAINTAINER)" \
80          --description="$(DESCRIPTION)" \
81          $(WORKSPACE)/build/=DEST_DIR
82
83 # use FPM to create DEB and RPM
84 packages: build
85         fpm \
86          -s dir \
87          -t deb \
88          -n "$(APP_NAME)" \
89          -v "$(NIGHTLY_VERSION)" \
90          --maintainer="$(MAINTAINER)" \
91          --description="$(DESCRIPTION)" \
92          --deb-no-default-config-files \
93         $(WORKSPACE)/build/=DEST_DIR
94         fpm \
95          -s dir \
96          -t rpm \
97          -n "$(APP_NAME)" \
98          -v "$(NIGHTLY_VERSION)" \
99          --maintainer="$(MAINTAINER)" \
100          --description="$(DESCRIPTION)" \
101          $(WORKSPACE)/build/=DEST_DIR