This URL has Read-Only access.

Statistics
| Branch: | Tag: | Revision:

root / src / nsreceive~ / Makefile @ 93c40d57

History | View | Annotate | Download (12.4 kB)

1
## Pd library template version 1.0.9
2
# For instructions on how to use this template, see:
3
#  http://puredata.info/docs/developer/MakefileTemplate
4
LIBRARY_NAME = pdsheefa
5

    
6
# add your .c source files, one object per file, to the SOURCES
7
# variable, help files will be included automatically, and for GUI
8
# objects, the matching .tcl file too
9
SOURCES = nsreceive~.c
10

    
11
# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will
12
# be included automatically
13
PDOBJECTS = 
14

    
15
# example patches and related files, in the 'examples' subfolder
16
EXAMPLES =
17

    
18
# manuals and related files, in the 'manual' subfolder
19
MANUAL = 
20

    
21
# if you want to include any other files in the source and binary tarballs,
22
# list them here.  This can be anything from header files, test patches,
23
# documentation, etc.  README.txt and LICENSE.txt are required and therefore
24
# automatically included
25
EXTRA_DIST = 
26

    
27

    
28

    
29
#------------------------------------------------------------------------------#
30
#
31
# things you might need to edit if you are using other C libraries
32
#
33
#------------------------------------------------------------------------------#
34

    
35
# -I"$(PD_INCLUDE)/pd" supports the header location for 0.43
36
CFLAGS = -I"$(PD_INCLUDE)/pd" -W -g
37
LDFLAGS =  
38
LIBS = 
39

    
40
#------------------------------------------------------------------------------#
41
#
42
# you shouldn't need to edit anything below here, if we did it right :)
43
#
44
#------------------------------------------------------------------------------#
45

    
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)
48

    
49
CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"'
50

    
51
PD_INCLUDE = $(PD_PATH)/include
52
# where to install the library, overridden below depending on platform
53
prefix = /usr/local
54
libdir = $(prefix)/lib
55
pkglibdir = $(libdir)/pd-externals
56
objectsdir = $(pkglibdir)
57

    
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
62

    
63
ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \
64
	         $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows)
65

    
66
DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION)
67
ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)
68

    
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 -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 i386 -arch x86_64 -mmacosx-version-min=10.4
100
      SOURCES += $(SOURCES_iphoneos)
101
    endif
102
    CFLAGS += $(FAT_FLAGS) -fPIC
103
    LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup
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
# Tho Android uses Linux, we use this fake uname to provide an easy way to
114
# setup all this things needed to cross-compile for Android using the NDK
115
ifeq ($(UNAME),ANDROID)
116
  CPU := arm
117
  SOURCES += $(SOURCES_android)
118
  EXTENSION = pd_linux
119
  OS = android
120
  PD_PATH = /usr
121
  NDK_BASE := /usr/local/android-ndk
122
  NDK_PLATFORM_VERSION := 5
123
  NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_VERSION)/arch-arm
124
  NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]')
125
  NDK_TOOLCHAIN_BASE=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(NDK_UNAME)-x86
126
  CC := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-gcc --sysroot=$(NDK_SYSROOT)
127
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
128
  CFLAGS += 
129
  LDFLAGS += -Wl,--export-dynamic -shared
130
  LIBS += -lc
131
  STRIP := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-strip \
132
	--strip-unneeded -R .note -R .comment
133
  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
134
endif
135
ifeq ($(UNAME),Linux)
136
  CPU := $(shell uname -m)
137
  SOURCES += $(SOURCES_linux)
138
  EXTENSION = pd_linux
139
  OS = linux
140
  PD_PATH = /usr
141
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
142
  CFLAGS += -fPIC
143
  LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
144
  LIBS += -lc
145
  STRIP = strip --strip-unneeded -R .note -R .comment
146
  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
147
endif
148
ifeq ($(UNAME),GNU)
149
  # GNU/Hurd, should work like GNU/Linux for basically all externals
150
  CPU := $(shell uname -m)
151
  SOURCES += $(SOURCES_linux)
152
  EXTENSION = pd_linux
153
  OS = linux
154
  PD_PATH = /usr
155
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
156
  CFLAGS += -fPIC
157
  LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
158
  LIBS += -lc
159
  STRIP = strip --strip-unneeded -R .note -R .comment
160
  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
161
endif
162
ifeq ($(UNAME),GNU/kFreeBSD)
163
  # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals
164
  CPU := $(shell uname -m)
165
  SOURCES += $(SOURCES_linux)
166
  EXTENSION = pd_linux
167
  OS = linux
168
  PD_PATH = /usr
169
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
170
  CFLAGS += -fPIC
171
  LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
172
  LIBS += -lc
173
  STRIP = strip --strip-unneeded -R .note -R .comment
174
  DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
175
endif
176
ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
177
  CPU := $(shell uname -m)
178
  SOURCES += $(SOURCES_cygwin)
179
  EXTENSION = dll
180
  OS = cygwin
181
  PD_PATH = $(cygpath $(PROGRAMFILES))/pd
182
  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
183
  CFLAGS += 
184
  LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
185
  LIBS += -lc -lpd
186
  STRIP = strip --strip-unneeded -R .note -R .comment
187
  DISTBINDIR=$(DISTDIR)-$(OS)
188
endif
189
ifeq (MINGW,$(findstring MINGW,$(UNAME)))
190
  CPU := $(shell uname -m)
191
  SOURCES += $(SOURCES_windows)
192
  EXTENSION = dll
193
  OS = windows
194
  PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd)
195
  OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer
196
  CFLAGS += -mms-bitfields
197
  LDFLAGS += -s -shared -Wl,--enable-auto-import
198
  LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" -lpd -lwsock32 -lkernel32 -luser32 -lgdi32
199
  STRIP = strip --strip-unneeded -R .note -R .comment
200
  DISTBINDIR=$(DISTDIR)-$(OS)
201
endif
202

    
203
# in case somebody manually set the HELPPATCHES above
204
HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd)
205

    
206
CFLAGS += $(OPT_CFLAGS)
207

    
208

    
209
.PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME)
210

    
211
all: $(SOURCES:.c=.$(EXTENSION))
212

    
213
%.o: %.c
214
	$(CC) $(CFLAGS) -o "$*.o" -c "$*.c"
215

    
216
%.$(EXTENSION): %.o
217
	$(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o"  $(LIBS)
218
	chmod a-x "$*.$(EXTENSION)"
219

    
220
# this links everything into a single binary file
221
$(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o
222
	$(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS)
223
	chmod a-x $(LIBRARY_NAME).$(EXTENSION)
224

    
225
install: libdir_install
226

    
227
# The meta and help files are explicitly installed to make sure they are
228
# actually there.  Those files are not optional, then need to be there.
229
libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual
230
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
231
	$(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \
232
		$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
233
	test -z "$(strip $(SOURCES))" || (\
234
		$(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \
235
		$(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION))))
236
	test -z "$(strip $(shell ls $(SOURCES:.c=.tcl)))" || \
237
		$(INSTALL_DATA) $(shell ls $(SOURCES:.c=.tcl)) \
238
			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
239
	test -z "$(strip $(PDOBJECTS))" || \
240
		$(INSTALL_DATA) $(PDOBJECTS) \
241
			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
242

    
243
# install library linked as single binary
244
single_install: $(LIBRARY_NAME) install-doc install-exec
245
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
246
	$(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
247
	$(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION)
248

    
249
install-doc:
250
	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
251
	test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \
252
		$(INSTALL_DATA) $(HELPPATCHES) \
253
			$(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
254
	$(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt
255
	$(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt
256

    
257
install-examples:
258
	test -z "$(strip $(EXAMPLES))" || \
259
		$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \
260
		for file in $(EXAMPLES); do \
261
			$(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \
262
		done
263

    
264
install-manual:
265
	test -z "$(strip $(MANUAL))" || \
266
		$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \
267
		for file in $(MANUAL); do \
268
			$(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \
269
		done
270

    
271

    
272
clean:
273
	-rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o)
274
	-rm -f -- $(SOURCES:.c=.$(EXTENSION))
275
	-rm -f -- $(LIBRARY_NAME).o
276
	-rm -f -- $(LIBRARY_NAME).$(EXTENSION)
277

    
278
distclean: clean
279
	-rm -f -- $(DISTBINDIR).tar.gz
280
	-rm -rf -- $(DISTBINDIR)
281
	-rm -f -- $(DISTDIR).tar.gz
282
	-rm -rf -- $(DISTDIR)
283
	-rm -f -- $(ORIGDIR).tar.gz
284
	-rm -rf -- $(ORIGDIR)
285

    
286

    
287
$(DISTBINDIR):
288
	$(INSTALL_DIR) $(DISTBINDIR)
289

    
290
libdir: all $(DISTBINDIR)
291
	$(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd  $(DISTBINDIR)
292
	$(INSTALL_DATA) $(SOURCES)  $(DISTBINDIR)
293
	$(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR)
294
	test -z "$(strip $(EXTRA_DIST))" || \
295
		$(INSTALL_DATA) $(EXTRA_DIST)    $(DISTBINDIR)
296
#	tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR)
297

    
298
$(DISTDIR):
299
	$(INSTALL_DIR) $(DISTDIR)
300

    
301
$(ORIGDIR):
302
	$(INSTALL_DIR) $(ORIGDIR)
303

    
304
dist: $(DISTDIR)
305
	$(INSTALL_DATA) Makefile  $(DISTDIR)
306
	$(INSTALL_DATA) README.txt $(DISTDIR)
307
	$(INSTALL_DATA) LICENSE.txt $(DISTDIR)
308
	$(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd  $(DISTDIR)
309
	test -z "$(strip $(ALLSOURCES))" || \
310
		$(INSTALL_DATA) $(ALLSOURCES)  $(DISTDIR)
311
	test -z "$(strip $(shell ls $(ALLSOURCES:.c=.tcl)))" || \
312
		$(INSTALL_DATA) $(shell ls $(ALLSOURCES:.c=.tcl))  $(DISTDIR)
313
	test -z "$(strip $(PDOBJECTS))" || \
314
		$(INSTALL_DATA) $(PDOBJECTS)  $(DISTDIR)
315
	test -z "$(strip $(HELPPATCHES))" || \
316
		$(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR)
317
	test -z "$(strip $(EXTRA_DIST))" || \
318
		$(INSTALL_DATA) $(EXTRA_DIST)    $(DISTDIR)
319
	test -z "$(strip $(EXAMPLES))" || \
320
		$(INSTALL_DIR) $(DISTDIR)/examples && \
321
		for file in $(EXAMPLES); do \
322
			$(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \
323
		done
324
	test -z "$(strip $(MANUAL))" || \
325
		$(INSTALL_DIR) $(DISTDIR)/manual && \
326
		for file in $(MANUAL); do \
327
			$(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \
328
		done
329
	tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR)
330

    
331
# make a Debian source package
332
dpkg-source:
333
	debclean
334
	make distclean dist
335
	mv $(DISTDIR) $(ORIGDIR)
336
	tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR)
337
	rm -f -- $(DISTDIR).tar.gz
338
	rm -rf -- $(DISTDIR) $(ORIGDIR)
339
	cd .. && dpkg-source -b $(LIBRARY_NAME)
340

    
341
etags:
342
	etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h
343

    
344
showsetup:
345
	@echo "CFLAGS: $(CFLAGS)"
346
	@echo "LDFLAGS: $(LDFLAGS)"
347
	@echo "LIBS: $(LIBS)"
348
	@echo "PD_INCLUDE: $(PD_INCLUDE)"
349
	@echo "PD_PATH: $(PD_PATH)"
350
	@echo "objectsdir: $(objectsdir)"
351
	@echo "LIBRARY_NAME: $(LIBRARY_NAME)"
352
	@echo "LIBRARY_VERSION: $(LIBRARY_VERSION)"
353
	@echo "SOURCES: $(SOURCES)"
354
	@echo "PDOBJECTS: $(PDOBJECTS)"
355
	@echo "ALLSOURCES: $(ALLSOURCES)"
356
	@echo "UNAME: $(UNAME)"
357
	@echo "CPU: $(CPU)"
358
	@echo "pkglibdir: $(pkglibdir)"
359
	@echo "DISTDIR: $(DISTDIR)"
360
	@echo "ORIGDIR: $(ORIGDIR)"