updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / pd-plugin / Makefile
blobe9fb94ba3e65c52c0357b6e083ba62fc3367fcac
1 ## Pd library template version 1.0.4
2 # For instructions on how to use this template, see:
3 # http://puredata.info/docs/developer/MakefileTemplate
4 LIBRARY_NAME = plugin~
6 # add your .c source files, one object per file, to the SOURCES
7 # variable, help files will be included automatically
8 SOURCES = plugin~.c
10 # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will
11 # be included automatically
12 PDOBJECTS =
14 # example patches and related files, in the 'examples' subfolder
15 EXAMPLES =
17 # manuals and related files, in the 'manual' subfolder
18 MANUAL =
20 # if you want to include any other files in the source and binary tarballs,
21 # list them here. This can be anything from header files, test patches,
22 # documentation, etc. README.txt and LICENSE.txt are required and therefore
23 # automatically included
24 EXTRA_DIST = plugin~-gui.pd ChangeLog SConstruct jutils.h plugin~.h
26 # NOTE: modified to build jload.c and jsearch.c and link it into plugin~
27 EXTRA_SOURCES = jsearch.c jload.c
30 #------------------------------------------------------------------------------#
32 # things you might need to edit if you are using other C libraries
34 #------------------------------------------------------------------------------#
36 CFLAGS = -DPD -I"$(PD_INCLUDE)" -Wall -W -g
37 LDFLAGS =
38 LIBS =
40 #------------------------------------------------------------------------------#
42 # you shouldn't need to edit anything below here, if we did it right :)
44 #------------------------------------------------------------------------------#
46 # get library version from meta file
47 LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd)
49 CFLAGS += -DVERSION='"$(LIBRARY_VERSION)"'
51 PD_INCLUDE = $(PD_PATH)/include
52 # where to install the library, overridden below depending on platform
53 prefix = /usr/
54 libdir = $(prefix)/lib
55 pkglibdir = $(libdir)/pd/extra
56 objectsdir = $(pkglibdir)
58 INSTALL = install
59 INSTALL_PROGRAM = $(INSTALL) -p -m 644
60 INSTALL_DATA = $(INSTALL) -p -m 644
61 INSTALL_DIR = $(INSTALL) -p -m 755 -d
63 ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \
64 $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows)
66 DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION)
67 ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)
69 UNAME := $(shell uname -s)
70 ifeq ($(UNAME),Darwin)
71 CPU := $(shell uname -p)
72 ifeq ($(CPU),arm) # iPhone/iPod Touch
73 SOURCES += $(SOURCES_iphoneos)
74 EXTENSION = pd_darwin
75 OS = iphoneos
76 PD_PATH = /Applications/Pd-extended.app/Contents/Resources
77 IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
78 CC=$(IPHONE_BASE)/gcc
79 CPP=$(IPHONE_BASE)/cpp
80 CXX=$(IPHONE_BASE)/g++
81 ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk
82 IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6
83 OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer
84 CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS)
85 LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT)
86 LIBS += -lc
87 STRIP = strip -x
88 DISTBINDIR=$(DISTDIR)-$(OS)
89 else # Mac OS X
90 SOURCES += $(SOURCES_macosx)
91 EXTENSION = pd_darwin
92 OS = macosx
93 PD_PATH = /Applications/Pd-extended.app/Contents/Resources
94 OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast
95 # build universal 32-bit on 10.4 and 32/64 on newer
96 ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8)
97 FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4
98 else
99 FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
100 SOURCES += $(SOURCES_iphoneos)
101 endif
102 CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
103 LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
104 # if the 'pd' binary exists, check the linking against it to aid with stripping
105 LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
106 LIBS += -lc
107 STRIP = strip -x
108 DISTBINDIR=$(DISTDIR)-$(OS)
109 # install into ~/Library/Pd on Mac OS X since /usr/local isn't used much
110 pkglibdir=$(HOME)/Library/Pd
111 endif
112 endif
113 ifeq ($(UNAME),Linux)
114 CPU := $(shell uname -m)
115 SOURCES += $(SOURCES_linux)
116 EXTENSION = pd_linux
117 OS = linux
118 PD_PATH = /usr
119 OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
120 CFLAGS += -fPIC
121 LDFLAGS += -Wl,--export-dynamic -shared -fPIC
122 LIBS += -lc
123 STRIP = strip --strip-unneeded -R .note -R .comment
124 DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
125 endif
126 ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
127 CPU := $(shell uname -m)
128 SOURCES += $(SOURCES_cygwin)
129 EXTENSION = dll
130 OS = cygwin
131 PD_PATH = $(cygpath $(PROGRAMFILES))/pd
132 OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
133 CFLAGS +=
134 LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
135 LIBS += -lc -lpd
136 STRIP = strip --strip-unneeded -R .note -R .comment
137 DISTBINDIR=$(DISTDIR)-$(OS)
138 endif
139 ifeq (MINGW,$(findstring MINGW,$(UNAME)))
140 CPU := $(shell uname -m)
141 SOURCES += $(SOURCES_windows)
142 EXTENSION = dll
143 OS = windows
144 PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd)
145 OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer -march=i686 -mtune=pentium4
146 CFLAGS += -mms-bitfields
147 LDFLAGS += -s -shared -Wl,--enable-auto-import
148 LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" -lpd -lwsock32 -lkernel32 -luser32 -lgdi32
149 STRIP = strip --strip-unneeded -R .note -R .comment
150 DISTBINDIR=$(DISTDIR)-$(OS)
151 endif
153 # in case somebody manually set the HELPPATCHES above
154 HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.c=-help.pd)
156 CFLAGS += $(OPT_CFLAGS)
159 .PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME)
161 all: $(SOURCES:.c=.$(EXTENSION))
163 %.o: %.c
164 $(CC) $(CFLAGS) -o "$*.o" -c "$*.c"
166 plugin~.$(EXTENSION): plugin~.o $(EXTRA_SOURCES:.c=.o)
167 $(CC) $(LDFLAGS) -o plugin~.$(EXTENSION) plugin~.o $(EXTRA_SOURCES:.c=.o) $(LIBS)
168 chmod a-x plugin~.$(EXTENSION)
170 # this links everything into a single binary file
171 $(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o
172 $(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS)
173 chmod a-x $(LIBRARY_NAME).$(EXTENSION)
175 install: libdir_install
177 # The meta and help files are explicitly installed to make sure they are
178 # actually there. Those files are not optional, then need to be there.
179 libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual
180 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
181 $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \
182 $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
183 test -z "$(strip $(SOURCES))" || (\
184 $(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \
185 $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION))))
186 test -z "$(strip $(PDOBJECTS))" || \
187 $(INSTALL_DATA) $(PDOBJECTS) \
188 $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
190 # install library linked as single binary
191 single_install: $(LIBRARY_NAME) install-doc install-exec
192 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
193 $(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
194 $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION)
196 install-doc:
197 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
198 test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \
199 $(INSTALL_DATA) $(HELPPATCHES) \
200 $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
201 $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt
202 $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt
204 install-examples:
205 test -z "$(strip $(EXAMPLES))" || \
206 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \
207 for file in $(EXAMPLES); do \
208 $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \
209 done
211 install-manual:
212 test -z "$(strip $(MANUAL))" || \
213 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \
214 for file in $(MANUAL); do \
215 $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \
216 done
219 clean:
220 -rm -f -- $(EXTRA_SOURCES:.c=.o)
221 -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o)
222 -rm -f -- $(SOURCES:.c=.$(EXTENSION))
223 -rm -f -- $(LIBRARY_NAME).o
224 -rm -f -- $(LIBRARY_NAME).$(EXTENSION)
226 distclean: clean
227 -rm -f -- $(DISTBINDIR).tar.gz
228 -rm -rf -- $(DISTBINDIR)
229 -rm -f -- $(DISTDIR).tar.gz
230 -rm -rf -- $(DISTDIR)
231 -rm -f -- $(ORIGDIR).tar.gz
232 -rm -rf -- $(ORIGDIR)
235 $(DISTBINDIR):
236 $(INSTALL_DIR) $(DISTBINDIR)
238 libdir: all $(DISTBINDIR)
239 $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR)
240 $(INSTALL_DATA) $(SOURCES) $(DISTBINDIR)
241 $(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR)
242 test -z "$(strip $(EXTRA_DIST))" || \
243 $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR)
244 # tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR)
246 $(DISTDIR):
247 $(INSTALL_DIR) $(DISTDIR)
249 $(ORIGDIR):
250 $(INSTALL_DIR) $(ORIGDIR)
252 dist: $(DISTDIR)
253 $(INSTALL_DATA) Makefile $(DISTDIR)
254 $(INSTALL_DATA) README.txt $(DISTDIR)
255 $(INSTALL_DATA) LICENSE.txt $(DISTDIR)
256 $(INSTALL_DATA) $(EXTRA_SOURCES) $(DISTDIR)
257 $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR)
258 test -z "$(strip $(ALLSOURCES))" || \
259 $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR)
260 test -z "$(strip $(PDOBJECTS))" || \
261 $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR)
262 test -z "$(strip $(HELPPATCHES))" || \
263 $(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR)
264 test -z "$(strip $(EXTRA_DIST))" || \
265 $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR)
266 test -z "$(strip $(EXAMPLES))" || \
267 $(INSTALL_DIR) $(DISTDIR)/examples && \
268 for file in $(EXAMPLES); do \
269 $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \
270 done
271 test -z "$(strip $(MANUAL))" || \
272 $(INSTALL_DIR) $(DISTDIR)/manual && \
273 for file in $(MANUAL); do \
274 $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \
275 done
276 tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR)
278 # make a Debian source package
279 dpkg-source:
280 debclean
281 make distclean dist
282 mv $(DISTDIR) $(ORIGDIR)
283 tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR)
284 rm -f -- $(DISTDIR).tar.gz
285 rm -rf -- $(DISTDIR) $(ORIGDIR)
286 cd .. && dpkg-source -b $(LIBRARY_NAME)
288 etags:
289 etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h
291 showsetup:
292 @echo "CFLAGS: $(CFLAGS)"
293 @echo "LDFLAGS: $(LDFLAGS)"
294 @echo "LIBS: $(LIBS)"
295 @echo "PD_INCLUDE: $(PD_INCLUDE)"
296 @echo "PD_PATH: $(PD_PATH)"
297 @echo "objectsdir: $(objectsdir)"
298 @echo "LIBRARY_NAME: $(LIBRARY_NAME)"
299 @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)"
300 @echo "SOURCES: $(SOURCES)"
301 @echo "PDOBJECTS: $(PDOBJECTS)"
302 @echo "ALLSOURCES: $(ALLSOURCES)"
303 @echo "UNAME: $(UNAME)"
304 @echo "CPU: $(CPU)"
305 @echo "pkglibdir: $(pkglibdir)"
306 @echo "DISTDIR: $(DISTDIR)"
307 @echo "ORIGDIR: $(ORIGDIR)"