aboutsummaryrefslogtreecommitdiff
path: root/externals/extra/0.43.3/Makefile
blob: e3b0e63efacb181671cdb7f9adcea1b8a7f03f57 (plain)
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
# To use this Makefile for your project, first put the name of your library in
# LIBRARY_NAME variable. The folder for your project should have the same name
# as your library.
LIBRARY_NAME = extra

# Next, add your source files to the SOURCES variable.
SOURCES = bonk~/bonk~.c choice/choice.c fiddle~/fiddle~.c loop~/loop~.c lrshift~/lrshift~.c pique/pique.c sigmund~/sigmund~.c stdout/stdout.c

# For objects that only build on certain platforms, add those to the SOURCES
# line for the right platforms.
SOURCES_Darwin = pd~/pd~.c
SOURCES_Linux = pd~/pd~.c

# include these abstractions with their help patches  
PD_OBJECTS = complex-mod~.pd hilbert~.pd rev1~.pd rev2~.pd rev3~.pd

# these are meant to be customizable
CFLAGS = -Wall -W -g
LDFLAGS = 

#------------------------------------------------------------------------------#
#
# you shouldn't need to edit anything below here, if we did it right :)
#
#------------------------------------------------------------------------------#

# where Pd lives
PD_PATH = ../../pd
# where to install the library
prefix = /usr/local
libdir = $(prefix)/lib
pkglibdir = $(libdir)/pd-externals
objectsdir = $(pkglibdir)

ALL_CFLAGS = -DPD -I$(PD_PATH)/src
ALL_LDFLAGS =  
LIBS = 

LN_S = ln -s

INSTALL = install
INSTALL_PROGRAM = $(INSTALL) -p -m 644
INSTALL_DATA = $(INSTALL) -p -m 644
INSTALL_DIR     = $(INSTALL) -p -m 755 -d

UNAME := $(shell uname -s)
ifeq ($(UNAME),Darwin)
  SOURCES += $(SOURCES_Darwin)
  EXTENSION = pd_darwin
  OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
  FAT_FLAGS = -arch i386 -arch ppc -mmacosx-version-min=10.4
  ALL_CFLAGS += -fPIC $(FAT_FLAGS)
  ALL_LDFLAGS += -bundle -undefined dynamic_lookup $(FAT_FLAGS)
  LIBS += -lc -lm
  STRIP = strip -x
 endif
ifeq ($(UNAME),Linux)
  SOURCES += $(SOURCES_Linux)
  EXTENSION = pd_linux
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
  ALL_CFLAGS += -fPIC
  ALL_LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
  LIBS += -lc
  STRIP = strip --strip-unneeded -R .note -R .comment
endif
ifeq ($(UNAME),GNU)
  # GNU/Hurd, should work like GNU/Linux for basically all externals
  SOURCES += $(SOURCES_linux)
  EXTENSION = pd_linux
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
  ALL_CFLAGS += -fPIC
  ALL_LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
  LIBS += -lc
  STRIP = strip --strip-unneeded -R .note -R .comment
endif
ifeq ($(UNAME),GNU/kFreeBSD)
  # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals
  SOURCES += $(SOURCES_linux)
  EXTENSION = pd_linux
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
  ALL_CFLAGS += -fPIC
  ALL_LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
  LIBS += -lc
  STRIP = strip --strip-unneeded -R .note -R .comment
endif
ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
#  SOURCES += $(SOURCES_Linux)
  EXTENSION = dll
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
  ALL_CFLAGS += -fPIC
  ALL_LDFLAGS += -L$(PD_PATH)/src -Wl,--export-dynamic  -shared -fPIC
  LIBS += -lc -lpd
  STRIP = strip --strip-unneeded -R .note -R .comment
endif
ifeq (MINGW,$(findstring MINGW,$(UNAME)))
  SOURCES += $(SOURCES_Windows)
  EXTENSION = dll
  CC=gcc
  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer -march=i686 -mtune=pentium4
  WINDOWS_HACKS = -D'O_NONBLOCK=1'
  ALL_CFLAGS += -mms-bitfields $(WINDOWS_HACKS)
  ALL_LDFLAGS += -s -shared -Wl,--enable-auto-import
  LIBS += -L$(PD_PATH)/src -lpd -lwsock32 -lkernel32 -luser32 -lgdi32
  STRIP = strip --strip-unneeded -R .note -R .comment
endif

ALL_CFLAGS += $(OPT_CFLAGS)


.PHONY = install libdir_install single_install install-doc install-exec clean dist etags

# kludges for objects with strange build requirements
EXPR_OBJECTS = expr~/expr~.$(EXTENSION) fexpr~.$(EXTENSION) expr.$(EXTENSION)
# special cases, where there are multiple .c files for a single class
EXPR_SOURCES = expr~/vexp.c expr~/vexp_fun.c expr~/vexp_if.c


# get library version from meta file
LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd)
DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION)
ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)


all: $(SOURCES:.c=.$(EXTENSION)) $(EXPR_OBJECTS) pd~/pdsched.$(EXTENSION)

%.o: %.c
	$(CC) $(ALL_CFLAGS) $(CFLAGS) -o "$*.o" -c "$*.c"

%.$(EXTENSION): %.o
	$(CC) $(ALL_LDFLAGS) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o"  $(LIBS)
	chmod a-x "$*.$(EXTENSION)"


expr~/expr~.$(EXTENSION): $(EXPR_SOURCES:.c=.o)
	$(CC) $(ALL_LDFLAGS) $(LDFLAGS) -o expr~/expr~.$(EXTENSION) $(EXPR_SOURCES:.c=.o) $(LIBS)
	chmod a-x expr~/expr~.$(EXTENSION)

expr.$(EXTENSION): expr~/expr~.$(EXTENSION)
	test -e expr.$(EXTENSION) || \
		$(LN_S) expr~/expr~.$(EXTENSION) expr.$(EXTENSION)

fexpr~.$(EXTENSION): expr~/expr~.$(EXTENSION)
	test -e fexpr~.$(EXTENSION) || \
		$(LN_S) expr~/expr~.$(EXTENSION) fexpr~.$(EXTENSION)

install: all install-doc install-exec install-special

# install all the weird old kludgey build stuff here
install-special:
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) extra-meta.pd $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) $(EXPR_OBJECTS) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) $(SOURCES:.c=-help.pd) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) rev1-final.pd rev1-stage.pd $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) expr-help.pd $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/*.$(EXTENSION)

install-doc:
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) $(SOURCES:.c=-help.pd) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) $(PD_OBJECTS:.pd=-help.pd) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) pd~/pd~-subprocess.pd pd~/z.pd $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt

install-exec:
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) $(PD_OBJECTS) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
	$(INSTALL_DATA) pd~/pdsched.$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)

dist:
	$(INSTALL_DIR) $(DISTDIR)
	$(INSTALL_DATA) Makefile $(DISTDIR)
	$(INSTALL_DATA) README.txt $(DISTDIR)
	$(INSTALL_DATA) LICENSE.txt $(DISTDIR)
	$(INSTALL_DATA) extra-meta.pd $(DISTDIR)
	$(INSTALL_DATA) complex-mod~-help.pd $(DISTDIR)
	$(INSTALL_DATA) complex-mod~.pd $(DISTDIR)
	$(INSTALL_DATA) hilbert~-help.pd $(DISTDIR)
	$(INSTALL_DATA) hilbert~.pd $(DISTDIR)
	$(INSTALL_DATA) rev1-final.pd $(DISTDIR)
	$(INSTALL_DATA) rev1~-help.pd $(DISTDIR)
	$(INSTALL_DATA) rev1~.pd $(DISTDIR)
	$(INSTALL_DATA) rev1-stage.pd $(DISTDIR)
	$(INSTALL_DATA) rev2~-help.pd $(DISTDIR)
	$(INSTALL_DATA) rev2~.pd $(DISTDIR)
	$(INSTALL_DATA) rev3~-help.pd $(DISTDIR)
	$(INSTALL_DATA) rev3~.pd $(DISTDIR)
	$(INSTALL_DATA) expr-help.pd $(DISTDIR)
	$(INSTALL_DIR) $(DISTDIR)/expr~
	$(INSTALL_DATA) expr~/fts_to_pd.h $(DISTDIR)/expr~
	$(INSTALL_DATA) expr~/LICENSE.txt $(DISTDIR)/expr~
	$(INSTALL_DATA) expr~/README.txt $(DISTDIR)/expr~
	$(INSTALL_DATA) expr~/vexp.c $(DISTDIR)/expr~
	$(INSTALL_DATA) expr~/vexp_fun.c $(DISTDIR)/expr~
	$(INSTALL_DATA) expr~/vexp.h $(DISTDIR)/expr~
	$(INSTALL_DATA) expr~/vexp_if.c $(DISTDIR)/expr~
	$(INSTALL_DIR) $(DISTDIR)/bonk~
	$(INSTALL_DATA) bonk~/bonk~.c $(DISTDIR)/bonk~
	$(INSTALL_DATA) bonk~/bonk~-help.pd $(DISTDIR)/bonk~
	$(INSTALL_DATA) bonk~/templates.txt $(DISTDIR)/bonk~
	$(INSTALL_DIR) $(DISTDIR)/choice
	$(INSTALL_DATA) choice/choice.c $(DISTDIR)/choice
	$(INSTALL_DATA) choice/choice-help.pd $(DISTDIR)/choice
	$(INSTALL_DIR) $(DISTDIR)/fiddle~
	$(INSTALL_DATA) fiddle~/fiddle~.c $(DISTDIR)/fiddle~
	$(INSTALL_DATA) fiddle~/fiddle~-help.pd $(DISTDIR)/fiddle~
	$(INSTALL_DIR) $(DISTDIR)/loop~
	$(INSTALL_DATA) loop~/loop~.c $(DISTDIR)/loop~
	$(INSTALL_DATA) loop~/loop~-help.pd $(DISTDIR)/loop~
	$(INSTALL_DATA) loop~/test-loop~.pd $(DISTDIR)/loop~
	$(INSTALL_DIR) $(DISTDIR)/lrshift~
	$(INSTALL_DATA) lrshift~/lrshift~.c $(DISTDIR)/lrshift~
	$(INSTALL_DATA) lrshift~/lrshift~-help.pd $(DISTDIR)/lrshift~
	$(INSTALL_DIR) $(DISTDIR)/pd~
	$(INSTALL_DATA) pd~/notes.txt $(DISTDIR)/pd~
	$(INSTALL_DATA) pd~/pd~.c $(DISTDIR)/pd~
	$(INSTALL_DATA) pd~/pd~-help.pd $(DISTDIR)/pd~
	$(INSTALL_DATA) pd~/pdsched.c $(DISTDIR)/pd~
	$(INSTALL_DATA) pd~/pd~-subprocess.pd $(DISTDIR)/pd~
	$(INSTALL_DATA) pd~/z.pd $(DISTDIR)/pd~
	$(INSTALL_DIR) $(DISTDIR)/pique
	$(INSTALL_DATA) pique/pique.c $(DISTDIR)/pique
	$(INSTALL_DATA) pique/pique-help.pd $(DISTDIR)/pique
	$(INSTALL_DIR) $(DISTDIR)/sigmund~
	$(INSTALL_DATA) sigmund~/sigmund~.c $(DISTDIR)/sigmund~
	$(INSTALL_DATA) sigmund~/sigmund~-help.pd $(DISTDIR)/sigmund~
	$(INSTALL_DIR) $(DISTDIR)/stdout
	$(INSTALL_DATA) stdout/stdout.c $(DISTDIR)/stdout
	$(INSTALL_DATA) stdout/stdout-help.pd $(DISTDIR)/stdout
	tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR)

distclean: clean
	-rm -f -- $(DISTBINDIR).tar.gz
	-rm -rf -- $(DISTBINDIR)
	-rm -f -- $(DISTDIR).tar.gz
	-rm -rf -- $(DISTDIR)
	-rm -f -- $(ORIGDIR).tar.gz
	-rm -rf -- $(ORIGDIR)

# make a Debian source package
dpkg-source:
	debclean
	make distclean dist
	mv $(DISTDIR) $(ORIGDIR)
	tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR)
	rm -f -- $(DISTDIR).tar.gz
	rm -rf -- $(DISTDIR) $(ORIGDIR)
	cd .. && dpkg-source -b $(LIBRARY_NAME)

clean:
	-rm -f -- $(SOURCES:.c=.o)
	-rm -f -- $(SOURCES:.c=.$(EXTENSION))
	-rm -f -- $(LIBRARY_NAME).$(EXTENSION)
	-rm -f -- $(EXPR_SOURCES:.c=.o)
	-rm -f -- $(EXPR_OBJECTS) pd~/pdsched.$(EXTENSION)

showpaths:
	@echo "PD_PATH: $(PD_PATH)"
	@echo "objectsdir: $(objectsdir)"
	@echo "LIBRARY_NAME: $(LIBRARY_NAME)"
	@echo "SOURCES: $(SOURCES)"