Makefile 4.29 KB
Newer Older
Albert Gräf's avatar
Albert Gräf committed
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

# Toplevel Makefile for Purr Data. Please note that at present this is just a
# thin wrapper around l2ork_addons/tar_em_up.sh, the traditional Pd-l2ork
# build script.

# The Pd-l2ork build system is very arcane and intricate. Its main purpose is
# building installers for the supported platforms, compiling sources is just a
# byproduct. Therefore `make` will most likely rebuild lots of things even if
# you just finished another build.

# The available build targets are:

# all: produce a native installer for the host platform (equivalent to
# `tar_em_up.sh -Tk`); note that in order to force a complete rebuild (like
# what `tar_em_up.sh -T` does), you'll have to run `make clean` first

# incremental: like `all`, but does an "incremental build" (equivalent to
# `tar_em_up.sh -tk`), bypassing Gem which takes an eternity to compile; please
# check the tar_em_up.sh script for details

# checkout: convenience target to check out all submodules in preparation for
# a subsequent build (the `all` and `rebuild` targets also do this
# automatically when needed)

# clean: does something similar to what `tar_em_up.sh` does in order to start
# from a clean slate, so that a subsequent build starts from scratch again

# realclean: put the sources into pristine state again (WARNING: this will get
# rid of any uncommitted source changes, too); use this as a last resort to
# get the sources into a compilable state again after things have gone awry
31
32
# NOTE: this target only works in a working copy of the git repo, not in
# static tarball snapshots of the source
Albert Gräf's avatar
Albert Gräf committed
33

34
35
.PHONY: all incremental checkout clean realclean dist

Albert Gräf's avatar
Albert Gräf committed
36
37
38
39
40
41
42
43
44
45
all:
	cd l2ork_addons && ./tar_em_up.sh -Tk

incremental:
	cd l2ork_addons && ./tar_em_up.sh -tk

checkout:
	git submodule update --init

clean:
Albert Gräf's avatar
Albert Gräf committed
46
	test "$(shell uname -s)" = "Darwin" && make -C packages/darwin_app clean || true
Albert Gräf's avatar
Albert Gräf committed
47
48
49
50
51
52
53
54
55
56
57
	cd pd/src && aclocal && autoconf && make clean || true
	cd externals/miXed && make clean || true
	cd Gem/src/ && test -f Makefile && make distclean || true
	cd Gem/src/ && rm -rf ./.libs && rm -rf ./*/.libs
	cd Gem/ && test -f Makefile && make distclean || true
	cd Gem/ && rm -f gemglutwindow.pd_linux Gem.pd_linux

realclean:
# git clean doesn't see these, but we need to get rid of them to prevent
# subsequent mysterious build failures
	rm -rf pd/lib $(addprefix externals/disis/, flext/configure stk/configure)
58
59
60
61
62
# The rest require a working copy of the git repo.
	test -d .git || (echo "Not a git repository, bailing out." && false)
	git submodule deinit --all -f
	git checkout .
	git clean -dff
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

# Build a self-contained distribution tarball (snapshot). This is pretty much
# the same as in debuild/Makefile and must be run in a working copy of the git
# repo.

# The Debian version gets derived from the date and serial number of the last
# commit. You can print it with 'make debversion'.
debversion = $(shell grep PD_L2ORK_VERSION pd/src/m_pd.h | sed 's|^.define *PD_L2ORK_VERSION *"\(.*\)".*|\1|')+git$(shell test -d .git && git rev-list --count HEAD)+$(shell test -d .git && git rev-parse --short HEAD)
# Source tarball and folder.
debsrc = purr-data_$(debversion).orig.tar.gz
debdist = purr-data-$(debversion)

# Submodules (Gem, etc.).
submodules = $(sort $(shell test -d .git && (git config --file .gitmodules --get-regexp path | awk '{ print $$2 }')))

dist: $(debsrc)

# 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 test -d .git && (git log -1 --format=%cd --date=short | sed -e 's/-//g'))-rev.$(shell test -d .git && git rev-parse --short HEAD)

$(debsrc):
	test -d .git || (echo "Not a git repository, bailing out." && false)
	rm -rf $(debdist)
# Make sure that the submodules are initialized.
	git submodule update --init
# Grab the main source.
	git 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
# Pre-generate and put s_stuff.h into the tarball (see above; the build
# version is generated using git which can't be done outside the git repo).
	sed 's|^\(#define PD_BUILD_VERSION "\).*"|\1$(PD_BUILD_VERSION)"|' pd/src/s_stuff.h.in > $(debdist)/pd/src/s_stuff.h
# Create the source tarball.
	tar cfz $(debsrc) $(debdist)
	rm -rf $(debdist)