1DLL = .pd_linux
2shared = -shared
3
4# Try to guess the host system type and figure out platform specifics.
5host = $(shell ../../config.guess)
6ifneq "$(findstring -mingw,$(host))" ""
7# Windows
8DLL = .dll
9PDLIB = -Wl,--enable-auto-import -lpd
10endif
11ifneq "$(findstring -darwin,$(host))" ""
12# OSX
13DLL = .pd_darwin
14shared = -dynamiclib -Wl,-undefined -Wl,dynamic_lookup
15endif
16ifneq "$(findstring x86_64-,$(host))" ""
17# 64 bit, needs -fPIC flag
18EXTRA_CFLAGS += -fPIC
19endif
20ifneq "$(findstring x86,$(host))" ""
21# architecture-specific options for x86 and x86_64
22EXTRA_CFLAGS += -msse -ffast-math
23endif
24
25EXTRA_CFLAGS += -I ../../pd
26
27dspsrc  := $(wildcard *.dsp)
28cppsrc  := $(dspsrc:.dsp=.cpp)
29mods	:= $(dspsrc:%.dsp=%~$(DLL))
30svg 	:= $(dspsrc:.dsp=.svg)
31xml 	:= $(dspsrc:.dsp=.dsp.xml)
32pd 	:= $(dspsrc:.dsp=.pd)
33libs    := $(wildcard *.lib)
34
35ARCH     = puredata.cpp
36#FAUST2PD = faust2pd
37FAUST2PD = ../../faust2pd
38F2PDFLAGS = -s
39
40all: $(mods)
41
42cpp: $(cppsrc)
43
44svg: $(svg)
45
46xml: $(xml)
47
48%~$(DLL): %.cpp
49	$(CXX) $(shared) $(EXTRA_CFLAGS) $(CFLAGS) -Dmydsp=$(@:%~$(DLL)=%) $(LDFLAGS) $< -o $@ $(PDLIB)
50
51%.cpp: %.dsp
52	faust $(VEC) -a $(ARCH) $< -o $@
53
54%.svg: %.dsp
55	faust -svg $< -o /dev/null >/dev/null
56
57%.dsp.xml: %.dsp
58	faust -xml $< -o /dev/null
59
60%.pd: %.dsp.xml
61	$(FAUST2PD) $(F2PDFLAGS) $<
62
63clean:
64	rm -f $(mods) *~ *.a *.o
65
66distclean:
67	rm -f $(mods) $(cppsrc) *~ *.a *.o
68
69clean-cpp:
70	rm -f $(cppsrc)
71
72clean-xml:
73	rm -f $(xml)
74
75clean-pd:
76	rm -f $(pd)
77
78clean-svg:
79	rm -rf *-svg
80
81realclean:
82	rm -f $(mods) $(cppsrc) $(xml) $(pd) *~ *.a *.o
83	rm -rf *-svg
84