Makefile 5.38 KB
Newer Older
1
# This is a GNU Makefile. Special tools needed: GNU make and awk, git.
Albert Gräf's avatar
Albert Gräf committed
2
3
4

# Make Debian packages. This builds a package from the current HEAD in a
# subdirectory named $(debdist). It also creates the source archive that goes
5
# along with it. All files will be created in the debuild directory.
Albert Gräf's avatar
Albert Gräf committed
6
7

# To make this work, you need to have the Debian package toolchain (debuild
8
9
10
11
12
13
14
# and friends) installed. You should also set the DEBEMAIL environment (or
# make) variable to your full name and email address as explained in the
# debchange(1) manual page, e.g.: DEBEMAIL="John Doe <johndoe@mail.com>"
# This information is used to create changelog entries with 'make debchange',
# which in turn are used to sign the Debian packages created with 'make deb'
# and 'make debsrc'. (Otherwise some generic information supplied by the
# system will be used, and you may not be able to sign the package.)
Albert Gräf's avatar
Albert Gräf committed
15
16
17
18

# The typical workflow is as follows:

# 1. Run 'make debchange' once to create a new debian/changelog entry. You
19
20
# *must* do this once after changes in the source repository so that debuild
# knows about the proper version number of the package.
Albert Gräf's avatar
Albert Gräf committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34

# 2. Run 'make deb' to build a signed binary package. Or 'make deb-us' for an
# unsigned one.

# If you only need the binary package for local deployment then you're done.
# Otherwise proceed to step 3.

# 3. Run 'make debsrc' to create a signed Debian source package which can be
# uploaded, e.g, to Launchpad using 'dput'. Or 'make debsrc-us' for an
# unsigned package.

# 4. Run 'make debclean' to get rid of any files that were created in steps 2
# and 3.

35
# The Debian version gets derived from the date and serial number of the last
36
# commit. You can print it with 'make debversion'.
37
debversion = $(shell grep PD_L2ORK_VERSION ../pd/src/m_pd.h | sed 's|^.define *PD_L2ORK_VERSION *"\(.*\)".*|\1|')+git$(shell git rev-list --count HEAD)+$(shell git rev-parse --short HEAD)
Albert Gräf's avatar
Albert Gräf committed
38
39
40
# Debian revision number of the package.
debrevision = 1
# Source tarball and folder.
41
42
43
44
debsrc = purr-data_$(debversion).orig.tar.gz
debdist = purr-data-$(debversion)

# nw.js sdk
45
46
# NOTE: arm packages need some special-casing, since they are released
# separately, and the version numbers do not always match up.
Albert Gräf's avatar
Albert Gräf committed
47
nwjsver = 0.28.1
48
nwjspkg = nwjs-sdk-v$(nwjsver)-linux
Albert Gräf's avatar
Albert Gräf committed
49
nwjsver_arm = 0.27.6
50
nwjspkg_arm = nwjs-sdk-v$(nwjsver_arm)-linux
51
52
53
nwjsver_arm64 = 0.23.7
nwjspkg_arm64 = nwjs-sdk-without-nacl-v$(nwjsver_arm64)-linux
nwjs = $(nwjspkg)-ia32.tar.gz $(nwjspkg)-x64.tar.gz $(nwjspkg_arm)-arm.tar.gz $(nwjspkg_arm64)-arm64.tar.gz
Albert Gräf's avatar
Albert Gräf committed
54

55
56
57
# Submodules (Gem, etc.). You can list them with 'make submodules'.
#submodules = Gem externals/miXed $(addprefix l2ork_addons/, cwiid fftease3.0-32bit lyonpotpourri rtcmix-in-pd)
submodules = $(sort $(shell git -C .. config --file .gitmodules --get-regexp path | awk '{ print $$2 }'))
Albert Gräf's avatar
Albert Gräf committed
58
59
60
61
62
63

# This is used for automatically generated debian/changelog entries (cf. 'make
# debchange'). Adjust as needed.
debmsg = "Build from latest upstream source."
debprio = "low"

64
65
66
67
.PHONY: submodules debversion debchange debclean deb debsrc deb-us debsrc-us

submodules:
	@echo $(submodules)
Albert Gräf's avatar
Albert Gräf committed
68
69
70
71
72
73
74
75
76

debversion:
	@echo $(debversion)

debchange:
	dch -u $(debprio) -v $(debversion)-$(debrevision) $(debmsg) && dch -r ""

debclean:
	rm -rf $(debdist)
77
	rm -f purr-data_*+git* purr-data-dbgsym_*+git*
Albert Gräf's avatar
Albert Gräf committed
78

79
deb: $(debsrc) $(addprefix debian/nwjs/, $(nwjs))
80
# Unpack the source into our temporary build directory.
Albert Gräf's avatar
Albert Gräf committed
81
82
	rm -rf $(debdist)
	tar xfz $(debsrc)
83
84
# Add the NW.js binaries to the source package.
	cd debian/source && rm -f include-binaries && for x in $(addprefix debian/nwjs/, $(nwjs)); do echo "$$x" >> include-binaries; done
85
86
# Make sure to copy the Debian files which may have uncommitted changes.
# Then run debuild to create the package.
Albert Gräf's avatar
Albert Gräf committed
87
	cd $(debdist) && cp -R ../debian . && debuild $(DEBUILD_FLAGS)
88
# Get rid of the temporary build directory.
Albert Gräf's avatar
Albert Gräf committed
89
90
91
	rm -rf $(debdist)

debsrc:
Albert Gräf's avatar
Albert Gräf committed
92
	$(MAKE) deb DEBUILD_FLAGS="-S -d"
Albert Gräf's avatar
Albert Gräf committed
93
94
95
96
97

deb-us:
	$(MAKE) deb DEBUILD_FLAGS="-us -uc"

debsrc-us:
Albert Gräf's avatar
Albert Gräf committed
98
	$(MAKE) deb DEBUILD_FLAGS="-S -d -us -uc"
Albert Gräf's avatar
Albert Gräf committed
99

Albert Gräf's avatar
Albert Gräf committed
100
101
102
103
# Determine the build version which needs git to be computed, so we can't do
# it in a stand-alone build from a tarball.
PD_BUILD_VERSION := $(shell git log -1 --format=%cd --date=short | sed -e 's/-//g')-rev.$(shell git rev-parse --short HEAD)

Albert Gräf's avatar
Albert Gräf committed
104
$(debsrc):
105
106
107
108
109
110
111
	rm -rf $(debdist)
# Make sure that the submodules are initialized.
	git -C .. submodule update --init
# Grab the main source.
	git -C .. archive --format=tar.gz --prefix=$(debdist)/ HEAD | tar xfz -
# Grab the submodules.
	for x in $(submodules); do (cd $(debdist) && rm -rf $$x && git -C ../../$$x archive --format=tar.gz --prefix=$$x/ HEAD | tar xfz -); done
112
# Pre-generate and put s_version.h into the tarball (see above; the build
Albert Gräf's avatar
Albert Gräf committed
113
# version is generated using git which can't be done outside the git repo).
114
	sed 's|^\(#define PD_BUILD_VERSION "\).*"|\1$(PD_BUILD_VERSION)"|' ../pd/src/s_version.h.in > $(debdist)/pd/src/s_version.h
115
116
117
# Create the source tarball.
	tar cfz $(debsrc) $(debdist)
	rm -rf $(debdist)
118

119
120
121
debian/nwjs/$(nwjspkg_arm)-arm.tar.gz:
	mkdir -p debian/nwjs &&	cd debian/nwjs && wget https://github.com/LeonardLaszlo/nw.js-armv7-binaries/releases/download/v$(nwjsver_arm)/$(notdir $@)

122
123
124
debian/nwjs/$(nwjspkg_arm64)-arm64.tar.gz:
	mkdir -p debian/nwjs &&	cd debian/nwjs && wget https://github.com/LeonardLaszlo/nw.js-armv7-binaries/releases/download/v$(nwjsver_arm64)/$(notdir $@)

125
126
debian/nwjs/$(nwjspkg)-%.tar.gz:
	mkdir -p debian/nwjs &&	cd debian/nwjs && wget http://dl.nwjs.io/v$(nwjsver)/$(notdir $@)