forked from libpd/libpd
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile-Bela
170 lines (144 loc) · 7.68 KB
/
Makefile-Bela
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
NAME = $(shell uname)
SOLIB_PREFIX = lib
CC?=arm-linux-gnueabihf-gcc
CROSS_COMPILE_FLAGS= -march=armv7-a
COMPILER_SPECIFIC_FLAGS = -ffast-math -fsingle-precision-constant
#CC = clang-mp-3.8
#U = /Users/Giulio/arm/usr
#CROSS_COMPILE_FLAGS = -target armv7l-unknown-linux-gnueabihf -I$U/include/c++/4.9 -I$U/include/arm-linux-gnueabihf/c++/4.9 -I$U/include/c++/4.9/backward -I$U/local/include -I$U/local/lib/clang/3.8.0/include -I$U/include/arm-linux-gnueabihf -I$U/include -c
#COMPILER_SPECIFIC_FLAGS =
# Assume Linux
SOLIB_EXT = so.1
PDNATIVE_PLATFORM = linux
PDNATIVE_ARCH = $(shell $(CC) -dumpmachine | sed -e 's,-.*,,' -e 's,i[3456]86,x86,' -e 's,amd64,x86_64,')
PLATFORM_CFLAGS = -DHAVE_LIBDL -Wno-int-to-pointer-cast \
-Wno-pointer-to-int-cast -fPIC -I"$(JAVA_HOME)/include" -fPIC
# below we define the -wrap flags to be passed to the compiler.
# this is a dirty trick to have the shell generate them for you:
# printf "%s" "-Wl"; for a in `grep -RhIo "\w*pthread_\w*" pure-data/src pure-data/extra libpd_wrapper | grep -v _t | sort -u`; do printf ",-wrap,$a";
# A more orthodox way would be to use xeno-config
XENO_PATH?=/usr/local/linaro/arm-linux-gnueabihf/xenomai/
#XENO_POSIX_CFLAGS:=$(shell DESTDIR=$(XENO_DESTDIR) $(XENO_CONFIG) --skin=posix --cflags)
XENO_POSIX_CFLAGS:=`/usr/xenomai/bin/xeno-config --skin=posix --cflags`
#XENO_POSIX_LIBS:=$(shell DESTDIR=$(XENO_DESTDIR) $(XENO_CONFIG) --skin=posix --ldflags)
#XENO_POSIX_LIBS:=-Wl,@$(XENO_PATH)/lib/posix.wrappers -L$(XENO_PATH)/lib `/usr/xenomai/bin/xeno-config --native --ldflags`
XENO_POSIX_LIBS:=$(shell /usr/xenomai/bin/xeno-config --skin=posix --ldflags --no-auto-init 2>/dev/null || /usr/xenomai/bin/xeno-config --skin=posix --ldflags)
XENO_LIB_PATH ?= $(XENO_PATH)/lib/
#LD_XENO_WRAP_FLAGS := -Wl$(shell for a in `grep -RhIo "\w*pthread_\w*" pure-data/src pure-data/extra libpd_wrapper | grep -v "_t" | grep -v pthread_join | sort -u`; do printf ",-wrap,$$a"; done) -lpthread_rt -L$(XENO_LIB_PATH)
LDFLAGS = -lm -ldl -Wl,-Bsymbolic $(XENO_POSIX_LIBS) -Wl,-soname,libpd.$(SOLIB_EXT) -shared
CPP_LDFLAGS = $(LDFLAGS)
PDNATIVE_SOLIB_EXT ?= $(SOLIB_EXT)
PD_FILES = \
pure-data/src/d_arithmetic.c pure-data/src/d_array.c pure-data/src/d_ctl.c \
pure-data/src/d_dac.c pure-data/src/d_delay.c pure-data/src/d_fft.c \
pure-data/src/d_fft_fftsg.c \
pure-data/src/d_filter.c pure-data/src/d_global.c pure-data/src/d_math.c \
pure-data/src/d_misc.c pure-data/src/d_osc.c pure-data/src/d_resample.c \
pure-data/src/d_soundfile.c pure-data/src/d_ugen.c \
pure-data/src/g_all_guis.c pure-data/src/g_array.c pure-data/src/g_bang.c \
pure-data/src/g_canvas.c pure-data/src/g_editor.c pure-data/src/g_graph.c \
pure-data/src/g_guiconnect.c pure-data/src/g_hdial.c \
pure-data/src/g_hslider.c pure-data/src/g_io.c pure-data/src/g_mycanvas.c \
pure-data/src/g_numbox.c pure-data/src/g_readwrite.c \
pure-data/src/g_rtext.c pure-data/src/g_scalar.c pure-data/src/g_template.c \
pure-data/src/g_text.c pure-data/src/g_toggle.c pure-data/src/g_traversal.c \
pure-data/src/g_vdial.c pure-data/src/g_vslider.c pure-data/src/g_vumeter.c \
pure-data/src/m_atom.c pure-data/src/m_binbuf.c pure-data/src/m_class.c \
pure-data/src/m_conf.c pure-data/src/m_glob.c pure-data/src/m_memory.c \
pure-data/src/m_obj.c pure-data/src/m_pd.c pure-data/src/m_sched.c \
pure-data/src/s_audio.c pure-data/src/s_audio_dummy.c \
pure-data/src/g_clone.c pure-data/src/s_inter.c \
pure-data/src/s_loader.c pure-data/src/s_main.c pure-data/src/s_path.c \
pure-data/src/s_print.c pure-data/src/s_utf8.c pure-data/src/x_acoustics.c \
pure-data/src/x_arithmetic.c pure-data/src/x_array.c pure-data/src/x_connective.c \
pure-data/src/x_gui.c pure-data/src/x_interface.c pure-data/src/x_list.c \
pure-data/src/x_midi.c pure-data/src/x_misc.c pure-data/src/x_net.c \
pure-data/src/x_scalar.c pure-data/src/x_text.c pure-data/src/x_time.c \
pure-data/src/x_vexp.c pure-data/src/x_vexp_fun.c pure-data/src/x_vexp_if.c \
libpd_wrapper/s_libpdmidi.c libpd_wrapper/x_libpdreceive.c \
libpd_wrapper/z_hooks.c libpd_wrapper/z_libpd.c
PD_EXTRA_FILES_ORIG = \
pure-data/extra/bob~/bob~.c pure-data/extra/bonk~/bonk~.c \
pure-data/extra/choice/choice.c pure-data/extra/expr~/vexp_fun.c \
pure-data/extra/expr~/vexp_if.c pure-data/extra/expr~/vexp.c \
pure-data/extra/fiddle~/fiddle~.c pure-data/extra/loop~/loop~.c \
pure-data/extra/lrshift~/lrshift~.c pure-data/extra/pique/pique.c \
pure-data/extra/sigmund~/sigmund~.c pure-data/extra/stdout/stdout.c
# a subset of the PD_EXTRA_FILES_ORIG: only those that do not cause troubles on Bela
# If you ever wnat to reactivate fiddle~ and sigmund~, make sure you uncomment the lines
# in libpd_wrapper/z_libpd.c as well.
PD_EXTRA_FILES= \
pure-data/extra/bob~/bob~.c pure-data/extra/bonk~/bonk~.c \
pure-data/extra/choice/choice.c \
pure-data/extra/fiddle~/fiddle~.c pure-data/extra/loop~/loop~.c \
pure-data/extra/lrshift~/lrshift~.c pure-data/extra/pique/pique.c \
pure-data/extra/sigmund~/sigmund~.c pure-data/extra/stdout/stdout.c
LIBPD_UTILS = \
libpd_wrapper/util/z_print_util.c \
libpd_wrapper/util/z_queued.c \
libpd_wrapper/util/ringbuffer.c
CPP_FILES = \
cpp/PdBase.cpp \
cpp/PdTypes.cpp
# conditional libpd_wrapper/util compilation
UTIL?=true
ifeq ($(UTIL), true)
UTIL_FILES = $(LIBPD_UTILS)
endif
# conditional pure-data/extra externals compilation
EXTRA?=true
ifeq ($(EXTRA), true)
EXTRA_FILES = $(PD_EXTRA_FILES)
EXTRA_CFLAGS = -I./pure-data/extra/expr~ -DLIBPD_EXTRA -I/usr/local/linaro/arm-linux-gnueabihf/xenomai/include/ -I/usr/xenomai/include
endif
# conditional optimizations or debug settings
OPT_CFLAGS = -mtune=cortex-a8 -mfloat-abi=hard -mfpu=neon -ftree-vectorize -O2 $(COMPILER_SPECIFIC_FLAGS)
ifeq ($(DEBUG), true)
OPT_CFLAGS = -Wall -g -O0
endif
# object files which are somehow generated but not from sources listed above,
# there is probably a better fix but this works for now
PD_EXTRA_OBJS = \
pure-data/src/d_fft_fft_fftsg.o pure-data/src/d_fft_fftw.o \
pure-data/src/d_fft_fftsg_h.o pure-data/src/x_qlist.o
# default install location
prefix=/usr/local
LIBPD = libs/libpd.$(SOLIB_EXT)
PDCPP = libs/libpdcpp.$(SOLIB_EXT)
CFLAGS = -DPD -DHAVE_UNISTD_H -DUSEAPI_DUMMY -I./pure-data/src -I./libpd_wrapper \
-I./libpd_wrapper/util $(EXTRA_CFLAGS) $(PLATFORM_CFLAGS) $(OPT_CFLAGS) $(XENO_CFLAGS) $(CROSS_COMPILE_FLAGS)
CXXFLAGS = $(CFLAGS) $(CPP_FLAGS)
.PHONY: libpd cpplib install uninstall clean clobber copy
libpd: $(LIBPD)
$(LIBPD): ${PD_FILES:.c=.o} ${UTIL_FILES:.c=.o} ${EXTRA_FILES:.c=.o}
$(CC) -o $(LIBPD) $^ $(LDFLAGS)
cpplib: $(PDCPP)
$(PDCPP): ${PD_FILES:.c=.o} ${UTIL_FILES:.c=.o} ${EXTRA_FILES:.c=.o} ${CPP_FILES:.cpp=.o}
g++ -o $(PDCPP) $^ $(CPP_LDFLAGS)
clean:
rm -f ${PD_FILES:.c=.o} ${PD_EXTRA_OBJS} ${CPP_FILES:.cpp=.o} ${JNI_FILE:.c=.o}
rm -f ${UTIL_FILES:.c=.o} ${EXTRA_FILES:.c=.o}
clobber: clean
rm -f $(LIBPD) $(PDCPP)
install:
mkdir -p $(prefix)/include/libpd
install libpd_wrapper/z_libpd.h $(prefix)/include/libpd
install pure-data/src/m_pd.h $(prefix)/include/libpd
install pure-data/src/s_stuff.h $(prefix)/include/libpd
mkdir -p $(prefix)/include/libpd/util
install libpd_wrapper/util/z_print_util.h $(prefix)/include/libpd/util
install libpd_wrapper/util/z_queued.h $(prefix)/include/libpd/util
install libpd_wrapper/util/ringbuffer.h $(prefix)/include/libpd/
install $(LIBPD) $(prefix)/lib/ && cd $(prefix)/lib && rm -rf libpd.so && ln -s `basename $(LIBPD)` libpd.so
ldconfig || true
if [ -e $(PDCPP) ]; then \
install cpp/*.hpp $(prefix)/include/libpd; \
install $(PDCPP) $(prefix)/lib; \
fi
copy: libpd
rsync $(LIBPD) [email protected]:/usr/local/lib/
uninstall:
rm -rf $(prefix)/include/libpd
rm -f $(prefix)/lib/libpd.so # this should be the symlink
rm -f $(prefix)/lib/`basename $(LIBPD)`
rm -f $(prefix)/lib/`basename $(PDCPP)`