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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
|
# next line has to be edited manually
PD_DIR = $(ROOT_DIR)/../../pd/src
# remove this restriction LATER, when TCL_LIB is ./configured
ifeq ($(shell whoami),krzYszcz)
# TCL_LIB should be set (or not) before "include Makefile.sources"
TCL_LIB = -l$(shell grep -osm1 'tcl8\.[345]' $(PD_DIR)/makefile)
endif
OS_NAME = $(shell uname -s)
ifneq ($(OS_NAME),Linux)
ifneq ($(OS_NAME),Darwin)
# FIXME
endif
endif
TILDE = ~
-include Makefile.dirs
include Makefile.sources
include Makefile.objects
default: define_build all
ifeq ($(OS_NAME),Linux)
# FIXME
CC = gcc-2.95
X_SUFFIX = pd_linux
DEFINES = -DUNIX
OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
LFLAGS = -export_dynamic -shared
endif
ifeq ($(OS_NAME),MINGW32_NT-5.2)
CC = gcc
X_SUFFIX = dll
DEFINES = -DNT
OPT_CFLAGS = -funroll-loops
LFLAGS = -shared $(PD_DIR)/../bin/pd.dll
endif
ifeq ($(OS_NAME),Darwin)
CC = gcc2
X_SUFFIX = pd_darwin
DEFINES = -DUNIX -DMACOSX
OPT_CFLAGS = -O2 -funroll-loops -fomit-frame-pointer
# perhaps "-undefined suppress" would be a better choice, when we go dynamic
# with our own common code? (not likely to happen soon...)
LFLAGS = -bundle -bundle_loader $(PD_DIR)/../bin/pd -flat_namespace
endif
SHARED_DIR = $(ROOT_DIR)/shared
OBJ_DIR = .
OUT_DIR = $(ROOT_DIR)/bin
# for current versions, $(BASE_DIR) equals $(BASE_NAME), for prior versions,
# $(BASE_DIR) equals $(BASE_NAME)-$(VERSION)
BASE_DIR = $(shell basename `pwd`)
BASE_NAME = $(shell basename `pwd` | awk -F - '{print $$1}')
# CX: control external's main file
# AX: audio (tilde) external's main file
# LX: alias external's main file
# (if alias external is tilde-only, use OTHER_SOURCES and AX_CLASSES)
CX_NAMES = $(notdir $(CX_SOURCES))
AX_NAMES = $(notdir $(AX_SOURCES))
TYPES_NAMES = $(notdir $($1_SOURCES))
ifdef LX_SOURCES
LX_NAMES = $(subst _,.,$(notdir $(LX_SOURCES)))
LX_CLASSES = $(LX_NAMES:.c=)
endif
CX_DIR = $(dir $(firstword $(CX_SOURCES)))
AX_DIR = $(dir $(firstword $(AX_SOURCES)))
TYPES_DIR = $(dir $(firstword $($1_SOURCES)))
TYPES_EXTERNS = \
$(patsubst %.c,%$($1_TILDE).$(X_SUFFIX),$(call TYPES_NAMES,$1))
SOURCES = $(CX_SOURCES) $(AX_SOURCES) $(LX_SOURCES) $(OTHER_SOURCES) \
$(foreach type,$(TYPES),$($(type)_SOURCES)) \
$(foreach type,$(TYPES),$($(type)_PRIVATEOBJECTS:.o=.c))
INCLUDES = -I. -I$(PD_DIR) -I$(SHARED_DIR)
WARN_CFLAGS = -Wall -W -Wstrict-prototypes -Werror \
-Wno-unused -Wno-parentheses -Wno-switch
DBG_CFLAGS =
CFLAGS = $(WARN_CFLAGS) $(OPT_CFLAGS) $(DEFINES) $(INCLUDES)
EXTERNS = $(foreach fn,$(CX_NAMES:.c=.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \
$(foreach fn,$(AX_NAMES:.c=~.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \
$(foreach fn,$(CX_CLASSES:=.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \
$(foreach fn,$(AX_CLASSES:=~.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \
$(foreach fn,$(LX_CLASSES:=.$(X_SUFFIX)),$(OUT_DIR)/$(fn)) \
$(if $(LX_STUBCLASS),$(OUT_DIR)/$(LX_STUBCLASS:=.$(X_SUFFIX))) \
$(foreach type,$(TYPES),\
$(foreach fn,$(call TYPES_EXTERNS,$(type)),$(OUT_DIR)/$(fn)))
TYPES_RULE = $(foreach fn,$(call TYPES_EXTERNS,$1),$(OUT_DIR)/$(fn)): \
$(OUT_DIR)/%$($1_TILDE).$(X_SUFFIX) \
: $(call TYPES_DIR,$1)%.o $($1_PRIVATEOBJECTS) \
$(foreach obj,$($1_OBJECTS),$(SHARED_DIR)/$(obj)) \
; $(CC) -o $$@ $(CFLAGS) $(LFLAGS) $($1_LIBS) $$+
# LATER find a better way...
$(if $(word 1,$(TYPES)),$(call TYPES_RULE,$(word 1,$(TYPES))))
$(if $(word 2,$(TYPES)),$(call TYPES_RULE,$(word 2,$(TYPES))))
$(if $(word 3,$(TYPES)),$(call TYPES_RULE,$(word 3,$(TYPES))))
$(if $(word 4,$(TYPES)),$(call TYPES_RULE,$(word 4,$(TYPES))))
$(if $(word 5,$(TYPES)),$(call TYPES_RULE,$(word 5,$(TYPES))))
$(if $(word 6,$(TYPES)),$(call TYPES_RULE,$(word 6,$(TYPES))))
$(if $(word 7,$(TYPES)),$(call TYPES_RULE,$(word 7,$(TYPES))))
$(if $(word 8,$(TYPES)),$(call TYPES_RULE,$(word 8,$(TYPES))))
$(if $(word 9,$(TYPES)),$(call TYPES_RULE,$(word 9,$(TYPES))))
$(if $(word 10,$(TYPES)),$(call TYPES_RULE,$(word 10,$(TYPES))))
$(if $(word 11,$(TYPES)),$(call TYPES_RULE,$(word 11,$(TYPES))))
$(if $(word 12,$(TYPES)),$(call TYPES_RULE,$(word 12,$(TYPES))))
$(if $(word 13,$(TYPES)),$(call TYPES_RULE,$(word 13,$(TYPES))))
$(if $(word 14,$(TYPES)),$(call TYPES_RULE,$(word 14,$(TYPES))))
$(if $(word 15,$(TYPES)),$(call TYPES_RULE,$(word 15,$(TYPES))))
$(if $(word 16,$(TYPES)),$(call TYPES_RULE,$(word 16,$(TYPES))))
$(if $(word 17,$(TYPES)),$(call TYPES_RULE,$(word 17,$(TYPES))))
$(if $(word 18,$(TYPES)),$(call TYPES_RULE,$(word 18,$(TYPES))))
$(if $(word 19,$(TYPES)),$(call TYPES_RULE,$(word 19,$(TYPES))))
$(if $(word 20,$(TYPES)),$(call TYPES_RULE,$(word 20,$(TYPES))))
$(if $(word 21,$(TYPES)),$(call TYPES_RULE,$(word 21,$(TYPES))))
$(if $(word 22,$(TYPES)),$(call TYPES_RULE,$(word 22,$(TYPES))))
$(if $(word 23,$(TYPES)),$(call TYPES_RULE,$(word 23,$(TYPES))))
$(if $(word 24,$(TYPES)),$(call TYPES_RULE,$(word 24,$(TYPES))))
SHOBJECTS = $(foreach fn,$(SHARED_OBJECTS),$(SHARED_DIR)/$(fn))
LXSHOBJECTS = $(foreach fn,$(LXSHARED_OBJECTS),$(SHARED_DIR)/$(fn))
OBJECTS = $(foreach fn,$(OTHER_SOURCES:.c=.o),$(OBJ_DIR)/$(fn)) \
$(foreach fn,$(LX_SOURCES:.c=.o),$(OBJ_DIR)/$(fn)) \
$(SHOBJECTS)
# lame...
.PRECIOUS: %.o
# library stub equals $(BASE_NAME) by default, otherwise
# it has to be declared explicitly in $(BASE_DIR)/Makefile.sources
ifdef LX_STUBCLASS
$(OUT_DIR)/$(LX_STUBCLASS).$(X_SUFFIX): $(BASE_NAME)_loader.c $(LXSHOBJECTS)
$(CC) -o $@ -Xlinker -defsym \
-Xlinker $(LX_STUBCLASS)_setup=$(BASE_NAME)_loader_setup \
$(CFLAGS) $(LFLAGS) $(LXSHOBJECTS) $<
ifndef LX_STUB
LX_STUB = $(LX_STUBCLASS)
endif
else
ifndef LX_STUB
LX_STUB = $(BASE_NAME)
endif
endif
# rules for aliases must precede generic extern rules
$(OUT_DIR)/$(LX_STUB).%~.$(X_SUFFIX): $(BASE_NAME)_loader.c $(LXSHOBJECTS)
$(CC) -o $@ -Xlinker -defsym \
-Xlinker $(LX_STUB).$(*F)_tilde_setup=$(BASE_NAME)_loader_setup \
$(CFLAGS) $(LFLAGS) $(LXSHOBJECTS) $<
$(OUT_DIR)/$(LX_STUB).%.$(X_SUFFIX): $(BASE_NAME)_loader.c $(LXSHOBJECTS)
$(CC) -o $@ -Xlinker -defsym \
-Xlinker $(LX_STUB).$(*F)_setup=$(BASE_NAME)_loader_setup \
$(CFLAGS) $(LFLAGS) $(LXSHOBJECTS) $<
# generic rule for audio externals
$(OUT_DIR)/%~.$(X_SUFFIX): $(AX_DIR)%.c $(OBJECTS)
$(CC) -o $@ $(CFLAGS) $(LFLAGS) $(OBJECTS) $<
# generic rule for control externals
$(OUT_DIR)/%.$(X_SUFFIX): $(CX_DIR)%.c $(OBJECTS)
$(CC) -o $@ $(CFLAGS) $(LFLAGS) $(OBJECTS) $<
SUBDIRS = @for i in $(MIXED_DIRS) and_in_case_it_is_null ; \
do ( if [ -d $$i ] ; then \
cd $$i; $(MAKE) $@ ; fi ) ; done
SUBDIRS_DEFAULT = @for i in $(MIXED_DIRS) and_in_case_it_is_null ; \
do ( if [ -d $$i ] ; then \
cd $$i; $(MAKE) ; fi ) ; done
define_build:
@if [[ -f build_counter && `whoami` == krzYszcz && \
`date -r build_counter +%j` != `date +%j` ]] ; then \
mv build_counter build_counter~ ; \
echo -n 'increment build counter (y/n)? [n]' ; read doit ; \
if [ $$doit ] && [ $$doit == 'y' ] ; then \
head -3 build_counter~ | \
awk '{if (index($$2,"BUILD")) print $$1, $$2, $$3+1; else print}' \
> build_temporary ; \
cat build_temporary | \
awk 'BEGIN {printf "\n#if 0\n"; \
printf toupper("$(BASE_NAME)_SNAPSHOT = ")} \
{gsub("\"","",$$3); printf $$3; if (NR==1) printf "-"} \
END {printf "\n#endif\n" }' | \
cat build_temporary - > build_counter ; \
rm -f build_temporary ; \
else cat build_counter~ > build_counter ; fi \
fi
all$(BASE_NAME)s.c: Makefile.sources
$(ROOT_DIR)/dumpsetups > $@
all: $(EXTERNS)
$(SUBDIRS_DEFAULT)
clean: emptydeps
# remove all objects and externs that are contained in current directory
-rm -f *.o *.$(X_SUFFIX)
$(SUBDIRS)
cleanall: clean
# remove default target externs
-rm -f $(EXTERNS)
$(SUBDIRS)
# added by Hans-Christoph Steiner <hans@eds.org> to remove
# files created when making MacOS X packages
-rm -Rf ../installroot
OLDROOT_DIR = $(shell ls -d -1 ../../Mixed-* | tail -1)
diff:
@echo -n > diff.out ; \
for f in {*.h,*.c} ; do \
if [ -f $$f ] ; then \
diff -u $(OLDROOT_DIR)/$(BASE_DIR)/$$f $$f >> diff.out ; \
fi \
done
VERSION = $(shell awk \
'{if (index($$2,"VERSION")) print substr($$3,2,length($$3)-2)}' \
build_counter)
RELEASE = $(shell awk \
'{if (index($$2,"RELEASE")) print substr($$3,2,length($$3)-2)}' \
build_counter)
BUILD = $(shell awk '{if (index($$2,"BUILD")) print $$3}' build_counter)
RELEASE_STUB = release/$(BASE_NAME)-$(VERSION)-$(RELEASE)$(BUILD)
SRC_TAR = $(RELEASE_STUB)-src.tar
BIN_TAR = $(RELEASE_STUB)-bin.tar
LIB_TAR = $(RELEASE_STUB)-lib.tar
DOC_TAR = $(RELEASE_STUB)-doc.tar
ALL_TAR = $(RELEASE_STUB)-all.tar
REL_BINDIR = bin
REL_LIBNAMES = $(foreach fn,$(RELEASE_LIBS:=.$(X_SUFFIX)),$(REL_BINDIR)/$(fn))
REL_EXTERNS = $(foreach fn,$(CX_NAMES:.c=.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) \
$(foreach fn,$(AX_NAMES:.c=~.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) \
$(foreach fn,$(CX_CLASSES:=.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) \
$(foreach fn,$(AX_CLASSES:=~.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) \
$(foreach fn,$(LX_CLASSES:=.$(X_SUFFIX)),$(REL_BINDIR)/$(fn)) \
$(if $(LX_STUBCLASS),$(REL_BINDIR)/$(LX_STUBCLASS:=.$(X_SUFFIX))) \
$(REL_LIBNAMES) $(foreach fn,$(RELEASE_APPS),$(REL_BINDIR)/$(fn)) \
$(foreach type,$(TYPES),\
$(foreach fn,$(call TYPES_EXTERNS,$(type)),$(REL_BINDIR)/$(fn)))
REL_ROOTSRC = LICENSE.txt Makefile.common dumpsetups
srelease: emptydeps define_build
cd $(ROOT_DIR)/shared; $(MAKE) emptydeps
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \
$(SRC_TAR) $(BASE_DIR)/* $(REL_ROOTSRC)
cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \
$(SRC_TAR)
cd $(ROOT_DIR); gzip -f $(SRC_TAR)
stestrelease: emptydeps define_build
cd $(ROOT_DIR)/shared; $(MAKE) emptydeps
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \
$(SRC_TAR) $(BASE_DIR)/* $(REL_ROOTSRC)
cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \
$(SRC_TAR)
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-test.exclude -rf \
$(SRC_TAR) test/$(BASE_NAME)/*
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-vicious.exclude -rf \
$(SRC_TAR) ViCious/$(BASE_DIR)/*
cd $(ROOT_DIR); tar -rf $(SRC_TAR) bin/keepme
cd $(ROOT_DIR); gzip -f $(SRC_TAR)
brelease: define_build
cd $(ROOT_DIR); tar zcf \
$(BIN_TAR).gz $(REL_EXTERNS)
btestrelease: define_build
cd $(ROOT_DIR); tar -cf $(BIN_TAR) $(REL_EXTERNS)
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-test.exclude -rf \
$(BIN_TAR) test/$(BASE_NAME)/*
cd $(ROOT_DIR); gzip -f $(BIN_TAR)
rellibs:
cd $(ROOT_DIR); tar zcf \
$(LIB_TAR).gz $(REL_LIBNAMES)
drelease: define_build
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-doc.exclude -zcf \
$(DOC_TAR).gz doc/examples/$(BASE_NAME)/*
release: srelease brelease drelease
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \
$(ALL_TAR) $(BASE_DIR)/* $(REL_ROOTSRC) $(REL_EXTERNS)
cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \
$(ALL_TAR)
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-doc.exclude -rf \
$(ALL_TAR) doc/examples/$(BASE_NAME)/*
cd $(ROOT_DIR); gzip -f $(ALL_TAR)
testrelease: stestrelease btestrelease
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-all.exclude -cf \
$(ALL_TAR) $(BASE_DIR)/* $(REL_ROOTSRC) $(REL_EXTERNS)
cd $(ROOT_DIR); tar -T $(BASE_DIR)/$(BASE_NAME)-shared.include -rf \
$(ALL_TAR)
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-test.exclude -rf \
$(ALL_TAR) test/$(BASE_NAME)/*
cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-vicious.exclude -rf \
$(ALL_TAR) ViCious/$(BASE_DIR)/*
cd $(ROOT_DIR); gzip -f $(ALL_TAR)
snap: emptyalldeps stestrelease btestrelease
depend:
$(CC) $(CFLAGS) -M $(SOURCES) > Makefile.deps
$(SUBDIRS)
emptydeps:
-rm -f Makefile.deps
touch Makefile.deps
chmod 666 Makefile.deps
emptyalldeps: emptydeps
$(SUBDIRS)
Makefile.deps:
touch Makefile.deps
chmod 666 Makefile.deps
-include Makefile.deps
# added by Hans-Christoph Steiner <hans@eds.org>
# to generate MacOS X packages
# krzYszcz:
# LATER try making cyclone-specifics abstracted out ala linux release
# keep cyclone libs, because they offer the max->pd import facility
PACKAGE_PREFIX = pd-mixed
PACKAGE_NAME = $(PACKAGE_PREFIX)-$(VERSION)-$(RELEASE)$(BUILD)
darwin_pkg_license:
# generate HTML version of License
echo "<HTML><BODY><FONT SIZE="-1">" > License.html
cat $(ROOT_DIR)/LICENSE.txt | sed -e 's/^$$/\<P\>/g' >> License.html
echo "</FONT></BODY></HTML>" >> License.html
darwin_pkg_clean:
-sudo rm -Rf installroot/ pd-*.pkg/
-rm -f $(PACKAGE_PREFIX)-*.info *~ 1 License.html
# install into MSP's default: /usr/local/lib
darwin_pkg: darwin_pkg_clean darwin_pkg_license
# compile externals
# cd $(ROOT_DIR)/toxy && make
cd $(ROOT_DIR)/cyclone && make
# set up installroot dir
test -d installroot/lib/pd/doc/5.reference || mkdir -p installroot/lib/pd/doc/5.reference
cp $(ROOT_DIR)/test/cyclone/*.* $(ROOT_DIR)/test/toxy/*.* \
installroot/lib/pd/doc/5.reference
test -d installroot/lib/pd/extra || mkdir -p installroot/lib/pd/extra
install -m444 $(ROOT_DIR)/bin/*.pd_darwin installroot/lib/pd/extra
test -d installroot/bin || mkdir -p installroot/bin
install -m555 $(ROOT_DIR)/bin/cyclist installroot/bin
cp -f pd-cyclone.info $(PACKAGE_NAME).info
# delete cruft
-find installroot -name .DS_Store -delete
-rm -f 1
# set proper permissions
sudo chown -R root:staff installroot
package installroot $(PACKAGE_NAME).info -d . -ignoreDSStore
# install pkg docs
install -m 644 License.html Welcome.html $(PACKAGE_NAME).pkg/Contents/Resources
sudo chown -R root:staff $(PACKAGE_NAME).pkg/Contents/Resources
|