Makefile 7.35 KB
Newer Older
Albert Gräf's avatar
Albert Gräf committed
1
2
3
4
5
6

# 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
Albert Gräf's avatar
Albert Gräf committed
7
8
9
10
11
12
# putting together a staging area with a complete Pd-l2ork installation and
# then building installers for the supported platforms from that, pulling
# together a bunch of separate packages, each with their own build system.
# Compiling sources is just one of the tasks that the builder does. Therefore
# you'll notice that, unlike with other less complicated source packages,
# `make` will rebuild lots of things even if you just finished another build.
Albert Gräf's avatar
Albert Gräf committed
13
14
15
16
17
18
19
20
21
22
23

# 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

Albert Gräf's avatar
Albert Gräf committed
24
25
26
27
# light: like `incremental`, but does a light build (equivalent to
# `tar_em_up.sh -tkl`) which only includes the most essential externals;
# please check the tar_em_up.sh script for details

Albert Gräf's avatar
Albert Gräf committed
28
# checkout: convenience target to check out all submodules in preparation for
Albert Gräf's avatar
Albert Gräf committed
29
# a subsequent build (the `all`, `incremental` and `dist` targets also do this
Albert Gräf's avatar
Albert Gräf committed
30
31
32
33
34
35
36
37
# 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
Albert Gräf's avatar
Albert Gräf committed
38
39
40
41
42

# dist: create a self-contained distribution tarball of the source

# NOTES:

Albert Gräf's avatar
Albert Gräf committed
43
44
45
46
47
48
49
# The incremental and light builds assume an existing staging area
# (packages/*/build directory) which is *not* cleaned before installing. This
# makes it possible to update the existing staging area after recompiling just
# a part of the system (all but Gem in the case of "incremental", only the
# Pd core and a few essential externals in the case of "light"). Use `make
# clean` beforehand if you want to install into a clean staging area.

Albert Gräf's avatar
Albert Gräf committed
50
51
52
53
54
55
56
57
58
59
# The realclean and dist targets use git commands and thus only work in a
# working copy of the git repo, not in the static tarball snapshots produced
# by the dist target.

# On Linux systems running `make` will try to produce a Debian package. On
# Linux distributions like Arch which are no Debian derivatives, the Debian
# packaging tools are not available. In this case, `make` will stop right
# before creating the actual package and leave the ready-made staged
# installation tree under `packages/linux_make/build` from where it can be
# copied or packaged up in any desired way.
Albert Gräf's avatar
Albert Gräf committed
60

61
62
.PHONY: all incremental checkout clean realclean dist

63
# Installation prefix under which Pd-l2ork is installed (Linux only). If this
64
65
66
# isn't set, a default location will be used (usually /usr/local). NOTE: We
# *always* assume that this variable is set properly in the install targets
# (see below).
67
68
69
70
71
72
prefix = /usr

ifneq ($(prefix),)
env = inst_dir="$(prefix)"
endif

Albert Gräf's avatar
Albert Gräf committed
73
all:
74
	cd l2ork_addons && $(env) ./tar_em_up.sh -Tk
Albert Gräf's avatar
Albert Gräf committed
75
76

incremental:
77
	cd l2ork_addons && $(env) ./tar_em_up.sh -tk
Albert Gräf's avatar
Albert Gräf committed
78

Albert Gräf's avatar
Albert Gräf committed
79
80
81
light:
	cd l2ork_addons && $(env) ./tar_em_up.sh -tkl

Albert Gräf's avatar
Albert Gräf committed
82
83
84
85
checkout:
	git submodule update --init

clean:
Albert Gräf's avatar
Albert Gräf committed
86
	test "$(shell uname -s)" = "Darwin" && make -C packages/darwin_app clean || true
Albert Gräf's avatar
Albert Gräf committed
87
88
89
	cd pd/src && aclocal && autoconf && make clean || true
	cd externals/miXed && make clean || true
	cd Gem/src/ && test -f Makefile && make distclean || true
90
	cd Gem/src/ && rm -rf ./.libs && rm -rf ./*/.libs || true
Albert Gräf's avatar
Albert Gräf committed
91
	cd Gem/ && test -f Makefile && make distclean || true
92
	cd Gem/ && rm -f gemglutwindow.pd_linux Gem.pd_linux || true
93
	rm -rf packages/*/build/
Albert Gräf's avatar
Albert Gräf committed
94
95

realclean:
96
# This requires a working copy of the git repo.
Albert Gräf's avatar
Albert Gräf committed
97
	@test -d .git || (echo "Not a git repository, bailing out." && false)
98
99
	git submodule deinit --all -f
	git checkout .
100
	git clean -dffx
101

102
103
104
105
106
107
108
109
# Installation targets. These don't work on Mac and Windows right now, you
# should use the generated installers on these systems instead. Also,
# $(prefix) must be set. $(DESTDIR) is supported as well, so you can do staged
# installs (but then again presumably you already have a staged install
# sitting in packages/*/build, so you might as well use that instead).

# Note that these targets simply (un)install whatever is in the
# packages/*/build directory at the time they're invoked, so you need to run
110
111
# `make` (or `make incremental`, etc.) first. Also note that some old cruft
# under build/etc (all but the bash auto-completions) isn't installed as it
112
113
114
115
116
117
118
119
# isn't needed on modern Linux systems any more.

builddir = $(firstword $(wildcard packages/*/build))
manifest = etc/bash_completion.d/pd-l2ork $(prefix:/%=%)/include/pd-l2ork $(prefix:/%=%)/lib/pd-l2ork $(patsubst $(builddir)/%,%, $(wildcard $(builddir)/$(prefix:/%=%)/bin/*) $(shell find $(builddir)/usr/share -type f))

install:
	test -z "$(DESTDIR)" || (rm -rf "$(DESTDIR)" && mkdir -p "$(DESTDIR)")
	tar -c -C $(builddir) $(manifest) | tar -x -C $(DESTDIR)/
120
121
122
# Edit the library paths in the default user.settings file so that it matches
# our installation prefix.
	test -f "$(DESTDIR)"$(prefix)/lib/pd-l2ork/default.settings && cd "$(DESTDIR)"$(prefix)/lib/pd-l2ork && sed -e "s!/usr/lib/pd-l2ork!$(prefix)/lib/pd-l2ork!g" -i default.settings || true
123
124
125
126

uninstall:
	rm -rf $(addprefix $(DESTDIR)/, $(manifest))

127
128
129
130
131
# 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
Albert Gräf's avatar
Albert Gräf committed
132
# commit.
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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):
Albert Gräf's avatar
Albert Gräf committed
148
	@test -d .git || (echo "Not a git repository, bailing out." && false)
149
150
151
152
153
154
155
156
157
158
159
160
161
	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)