forked from basho/node_package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (69 loc) · 2.22 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
70
71
72
73
74
75
76
77
78
79
80
81
82
##
## Export all variables to sub-invocation
##
export
OS = $(shell uname -s)
ERLANG_BIN ?= $(shell dirname $(shell which erl))
##
## Support RPM and Debian based linux systems
##
ifeq ($(OS),Linux)
ARCH = $(shell uname -m)
ISRPM = $(shell cat /etc/redhat-release 2> /dev/null)
ISDEB = $(shell cat /etc/debian_version 2> /dev/null)
ifneq ($(ISRPM),)
OSNAME= RedHat
PKGERDIR = rpm
BUILDDIR = rpmbuild
else
ifneq ($(ISDEB),)
OSNAME = Debian
PKGERDIR = deb
BUILDDIR = debuild
endif # deb
endif # rpm
endif # linux
ifeq ($(OS),Darwin) # OSX
OSNAME = OSX
ARCH = $(shell file `which erlc` | grep -c x86_64 2> /dev/null | awk \
'{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
PKGERDIR = osx
BUILDDIR = osxbuild
endif
ifeq ($(OS),FreeBSD)
OSNAME = FreeBSD
ARCH = $(shell uname -m)
PKGERDIR = fbsd
BUILDDIR = fbsdbuild
endif
ifeq ($(OS),SunOS) # Solaris flavors
KERNELVER = $(shell uname -v | grep -c joyent 2> /dev/null)
ARCH = $(shell file `which erlc` | grep -c 64-bit 2> /dev/null | awk \
'{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
ifneq ($(KERNELVER),0) # SmartOS
OSNAME = SmartOS
PKGERDIR = smartos
BUILDDIR = smartosbuild
else # Solaris / OmniOS
DISTRO = $(shell head -1 /etc/release|awk \
'{if ($$1 == "OmniOS") {print $$1} else {print "Solaris"}}')
OSNAME = ${DISTRO}
PKGERDIR = solaris
BUILDDIR = solarisbuild
endif
endif
DATE = $(shell date +%Y-%m-%d)
# Default the package build version to 1 if not already set
PKG_BUILD ?= 1
.PHONY: ostype varcheck
## Call platform dependent makefile
ostype: varcheck setversion
$(if $(PKGERDIR),,$(error "Operating system '$(OS)' not supported by node_package"))
$(MAKE) -f $(PKG_ID)/deps/node_package/priv/templates/$(PKGERDIR)/Makefile.bootstrap
## Set app version
setversion: varcheck
echo "{app_version, \"$(PKG_VERSION)\"}." >> $(PKG_ID)/deps/node_package/priv/templates/$(PKGERDIR)/vars.config
## Check required settings before continuing
varcheck:
$(if $(PKG_VERSION),,$(error "Variable PKG_VERSION must be set and exported, see basho/node_package readme"))
$(if $(PKG_ID),,$(error "Variable PKK_ID must be set and exported, see basho/node_package readme"))