Codebase list pd-iemnet / upstream/0.2.2+git20191112.895d985
Import upstream version 0.2.2+git20191112.895d985, md5 d99bda6e8080372d57ebc06bca0dcc3c Debian Janitor 4 years ago
10 changed file(s) with 1913 addition(s) and 428 deletion(s). Raw diff Collapse all Expand all
0 #######################################################################
1 ### .git-ci/gitlab-iem.yml for Pd externals: v1.2
2 ###
3 ### this can be used for any external with a build system like:
4 ### - 'make' builds the external
5 ### - 'make install' installs the external to be used by Pd
6 ### the following make variables must be honoured:
7 ### - extension: filename extension for externals
8 ### - DESTDIR: base directory for 'make install'
9 ### - pkglibdir: directory to put externals into (relative to DESTDIR)
10 ###
11 ### one well known build-system that can be used straight away is
12 ### "pd-lib-builder" -> https://github.com/pure-data/pd-lib-builder/
13 #######################################################################
14
15 variables:
16 PDVERSION: 0.49-0
17
18 #######################################################################
19 ### configuration templates (to be used for snapshot and release builds)
20 .build:snapshot: &snapshot
21 except:
22 - tags
23 artifacts: &snapshot_artifacts
24 name: ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}_${CI_JOB_NAME%_*}
25 paths:
26 - "${CI_JOB_NAME}/${CI_PROJECT_NAME}"
27 expire_in: 1 week
28
29 .build:release: &release
30 only:
31 - tags
32 artifacts: &release_artifacts
33 name: ${CI_PROJECT_NAME}_${CI_COMMIT_REF_NAME}_${CI_JOB_NAME%_*}
34 paths:
35 - "${CI_JOB_NAME}/${CI_PROJECT_NAME}"
36
37 .build:linux: &build_linux
38 image: gcc
39 stage: build
40 before_script:
41 - apt-get update && apt-get install -y --no-install-recommends make puredata-dev puredata
42 - export PD=/usr/bin/pd
43 script:
44 - make
45 - make install DESTDIR=$(pwd) pkglibdir=/${CI_JOB_NAME}
46
47 .build:macos: &build_macos
48 tags:
49 - osx
50 stage: build
51 before_script:
52 - wget -q -O Pd.tgz http://msp.ucsd.edu/Software/pd-${PDVERSION}.mac.tar.gz
53 - rm -rf /Applications/Pd*.app/
54 - tar xvf Pd.tgz -C /Applications/
55 - rm -f Pd.tgz
56 - export PD=$(find /Applications/Pd*.app/Contents/Resources/bin/ type f -name pd -print -quit)
57 script:
58 - make
59 - make install DESTDIR=$(pwd) pkglibdir=/${CI_JOB_NAME}
60
61 .build:w32: &build_w32
62 stage: build
63 tags:
64 - windows
65 variables:
66 IEMCI_CONFIGURATIONS: mingw32
67 before_script:
68 - wget -q -O Pd.zip http://msp.ucsd.edu/Software/pd-${PDVERSION}-i386.msw.zip
69 - rm -rf "${PROGRAMFILESX86}/pd"; mkdir -p "${PROGRAMFILESX86}/pd"
70 - unzip -q Pd.zip -d "${PROGRAMFILESX86}/pd"
71 - mv -v "${PROGRAMFILESX86}/pd"/*/* "${PROGRAMFILESX86}/pd"
72 - export PD="${PROGRAMFILESX86}/pd/bin/pd.com"
73 script:
74 - make
75 - make install DESTDIR=$(pwd) pkglibdir=/${CI_JOB_NAME}
76
77 .build:w64: &build_w64
78 stage: build
79 tags:
80 - windows
81 variables:
82 IEMCI_CONFIGURATIONS: mingw64
83 before_script:
84 - wget -q -O Pd.zip http://msp.ucsd.edu/Software/pd-${PDVERSION}.msw.zip
85 - rm -rf "${PROGRAMFILES}/pd"; mkdir -p "${PROGRAMFILES}/pd"
86 - unzip -q Pd.zip -d "${PROGRAMFILES}/pd"
87 - mv -v "${PROGRAMFILES}/pd"/*/* "${PROGRAMFILES}/pd"
88 - export PD="${PROGRAMFILES}/pd/bin/pd.com"
89 script:
90 - make extension=m_amd64
91 - make install extension=m_amd64 DESTDIR=$(pwd) pkglibdir=/${CI_JOB_NAME}
92
93 #######################################################################
94 ### the actual jobs: (linux,macos,windows)*(release,snapshot)
95
96 Linux:
97 <<: *build_linux
98 <<: *release
99 Darwin:
100 <<: *build_macos
101 <<: *release
102 w32:
103 <<: *build_w32
104 <<: *release
105 w64:
106 <<: *build_w64
107 <<: *release
108
109
110 Linux_snapshot:
111 <<: *build_linux
112 <<: *snapshot
113 Darwin_snapshot:
114 <<: *build_macos
115 <<: *snapshot
116 w32_snapshot:
117 <<: *build_w32
118 <<: *snapshot
119 w64_snapshot:
120 <<: *build_w64
121 <<: *snapshot
122
123 #######################################################################
124 ### create deken packages and (optionally) upload them
125 deken:
126 stage: deploy
127 image: debian:buster
128 only:
129 - tags
130 variables:
131 DEKEN_ROOT: "yes"
132 before_script:
133 - apt-get update && apt-get --no-install-recommends -y install deken git
134 script:
135 - chmod -R go-w .
136 - git archive --format=tar --prefix=tmp/${CI_PROJECT_NAME}/ HEAD | tar xf -
137 - deken package --version="${CI_COMMIT_TAG#v}" */"${CI_PROJECT_NAME}"
138 - ls ./*.dek
139 - test -z "${DEKEN_USERNAME}" || test -z "${DEKEN_PASSWORD}" || deken upload --no-source-error ./*.dek
00 language: c
1 sudo: false
12
23 env:
34 global:
45 - secure: "H+FS0KWYGx4JBMcPdhhJus9LgFhh5luIU4rfWl6Fsh4q0VJmT1tSO3KYlEQYkenS4xX/sUtN/Yus1b8L0MkuM3akEEPAA26Up9leFsarIQrD3dGYmoNQ4R2eG1Et8hoNwQwXQ1f30wrqfykVK+83rzqSlpoz+nhTBKZNYC7tfn0="
5 - COVERITY_SCAN_BRANCH_PATTERN="coverity_scan"
6 - COVERITY_SCAN_BRANCH_PATTERN="(master|coverity_scan)"
67 - COVERITY_SCAN_NOTIFICATION_EMAIL="zmoelnig@users.sourceforge.net"
78 - COVERITY_SCAN_BUILD_COMMAND="make"
89
1314 env:
1415 - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG"
1516
16 before_install:
17 - sudo apt-get update -qq
18 - sudo apt-get install -qq puredata-dev
17 addons:
18 apt:
19 packages:
20 - puredata-dev
21
22 #before_install:
23 #- sudo apt-get update -qq
24 #- sudo apt-get install -qq puredata-dev
1925
2026 before_script:
2127 # implement Coverity Scan with before_script instead of addons.coverity_scan
0 ## Pd library template version 1.0.11
1 # For instructions on how to use this template, see:
2 # http://puredata.info/docs/developer/MakefileTemplate
3 LIBRARY_NAME = iemnet
0 # Makefile for iemnet
41
5 # add your .c source files, one object per file, to the SOURCES
6 # variable, help files will be included automatically, and for GUI
7 # objects, the matching .tcl file too
8 SOURCES = tcpserver.c tcpclient.c tcpsend.c tcpreceive.c udpreceive.c udpsend.c udpclient.c udpserver.c
2 lib.name = iemnet
93
10 SHARED_SOURCES = iemnet.c iemnet_data.c iemnet_receiver.c iemnet_sender.c
11 SHARED_HEADERS = iemnet_data.h iemnet.h
4 class.sources = \
5 tcpserver.c \
6 tcpclient.c \
7 tcpsend.c \
8 tcpreceive.c \
9 udpreceive.c \
10 udpsend.c \
11 udpclient.c \
12 udpserver.c
1213
13 # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will
14 # be included automatically
15 PDOBJECTS = udpsndrcv.pd
14 shared.sources = \
15 iemnet.c \
16 iemnet_data.c \
17 iemnet_receiver.c \
18 iemnet_sender.c
1619
17 # example patches and related files, in the 'examples' subfolder
18 #EXAMPLES = bothtogether.pd
20 datafiles = \
21 iemnet-meta.pd \
22 tcpclient-help.pd \
23 tcpreceive-help.pd \
24 tcpsend-help.pd \
25 tcpserver-help.pd \
26 udpclient-help.pd \
27 udpreceive-help.pd \
28 udpsend-help.pd \
29 udpserver-help.pd \
30 udpsndrcv-help.pd \
31 udpsndrcv.pd \
32 LICENSE.txt \
33 README.txt
1934
20 # manuals and related files, in the 'manual' subfolder
21 #MANUAL = manual.txt
35 cflags = -DVERSION='"$(lib.version)"'
2236
23 # if you want to include any other files in the source and binary tarballs,
24 # list them here. This can be anything from header files, test patches,
25 # documentation, etc. README.txt and LICENSE.txt are required and therefore
26 # automatically included
27 EXTRA_DIST = ChangeLog FEATURES.txt NOTES.txt
37 define forWindows
38 ldlibs = -lwsock32 -lpthread
39 endef
2840
29 LIBS_windows=-lpthread
41 # This Makefile is based on the Makefile from pd-lib-builder written by
42 # Katja Vetter. You can get it from:
43 # https://github.com/pure-data/pd-lib-builder
3044
31 #overriding the datestring
32 # run `make CPPFLAGS="-DBUILD_DATE='\"somewhen in August\"'"`
33
34
35 #------------------------------------------------------------------------------#
36 #
37 # things you might need to edit if you are using other C libraries
38 #
39 #------------------------------------------------------------------------------#
40
41 ALL_CFLAGS = -I"$(PD_INCLUDE)"
42 ALL_LDFLAGS =
43 SHARED_LDFLAGS =
44 ALL_LIBS =
45
46
47 #------------------------------------------------------------------------------#
48 #
49 # you shouldn't need to edit anything below here, if we did it right :)
50 #
51 #------------------------------------------------------------------------------#
52
53 # these can be set from outside without (usually) breaking the build
54 CFLAGS := -Wall -Wno-unused -W -g
55
56 # get library version from meta file
57 LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd)
58
59 ALL_CFLAGS += -DPD -DVERSION='"$(LIBRARY_VERSION)"'
60
61 PD_INCLUDE = $(PD_PATH)/include/pd
62 # where to install the library, overridden below depending on platform
63 prefix = /usr/local
64 libdir = $(prefix)/lib
65 pkglibdir = $(libdir)/pd-externals
66 objectsdir = $(pkglibdir)
67
68 INSTALL = install
69 INSTALL_PROGRAM = $(INSTALL) -p -m 644
70 INSTALL_DATA = $(INSTALL) -p -m 644
71 INSTALL_DIR = $(INSTALL) -p -m 755 -d
72
73 ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \
74 $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows)
75
76 DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION)
77 ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION)
78
79 UNAME := $(shell uname -s)
80 ifeq ($(UNAME),Darwin)
81 CPU := $(shell uname -p)
82 ifeq ($(CPU),arm) # iPhone/iPod Touch
83 SOURCES += $(SOURCES_iphoneos)
84 EXTENSION = pd_darwin
85 SHARED_EXTENSION = dylib
86 OS = iphoneos
87 PD_PATH = /Applications/Pd-extended.app/Contents/Resources
88 IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
89 CC=$(IPHONE_BASE)/gcc
90 CPP=$(IPHONE_BASE)/cpp
91 CXX=$(IPHONE_BASE)/g++
92 ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk
93 IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6
94 OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer
95 ALL_CFLAGS := $(IPHONE_CFLAGS) $(ALL_CFLAGS)
96 ALL_LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT)
97 SHARED_LDFLAGS += -arch armv6 -dynamiclib -undefined dynamic_lookup $(ISYSROOT)
98 ALL_LIBS += -lc $(LIBS_iphoneos)
99 STRIP = strip -x
100 DISTBINDIR=$(DISTDIR)-$(OS)
101 else # Mac OS X
102 SOURCES += $(SOURCES_macosx)
103 EXTENSION = pd_darwin
104 SHARED_EXTENSION = dylib
105 OS = macosx
106 PD_PATH = /Applications/Pd-extended.app/Contents/Resources
107 OPT_CFLAGS = -ftree-vectorize
108 # build universal 32-bit on 10.4 and 32/64 on newer
109 ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8)
110 FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4
111 else
112 FAT_FLAGS = -arch i386 -arch x86_64 -mmacosx-version-min=10.4
113 SOURCES += $(SOURCES_iphoneos)
114 endif
115 ALL_CFLAGS += $(FAT_FLAGS) -fPIC
116 ifneq ($(strip $(realpath /sw/include)),)
117 ALL_CFLAGS += -I/sw/include
118 endif
119 # if the 'pd' binary exists, check the linking against it to aid with stripping
120 BUNDLE_LOADER = $(shell test ! -e $(PD_PATH)/bin/pd || echo -bundle_loader $(PD_PATH)/bin/pd)
121 ALL_LDFLAGS += $(FAT_FLAGS) -bundle $(BUNDLE_LOADER) -undefined dynamic_lookup
122 ifneq ($(strip $(realpath /sw/lib)),)
123 ALL_LDFLAGS += -L/sw/lib
124 endif
125 SHARED_LDFLAGS += $(FAT_FLAGS) -dynamiclib -undefined dynamic_lookup \
126 -install_name @loader_path/$(SHARED_LIB) -compatibility_version 1 -current_version 1.0
127 ALL_LIBS += -lc $(LIBS_macosx)
128 STRIP = strip -x
129 DISTBINDIR=$(DISTDIR)-$(OS)
130 # install into ~/Library/Pd on Mac OS X since /usr/local isn't used much
131 pkglibdir=$(HOME)/Library/Pd
132 endif
133 endif
134 # Tho Android uses Linux, we use this fake uname to provide an easy way to
135 # setup all this things needed to cross-compile for Android using the NDK
136 ifeq ($(UNAME),ANDROID)
137 CPU := arm
138 SOURCES += $(SOURCES_android)
139 EXTENSION = pd_linux
140 SHARED_EXTENSION = so
141 OS = android
142 PD_PATH = /usr
143 NDK_BASE := /usr/local/android-ndk
144 NDK_PLATFORM_VERSION := 5
145 NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_VERSION)/arch-arm
146 NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]')
147 NDK_TOOLCHAIN_BASE=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(NDK_UNAME)-x86
148 CC := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-gcc --sysroot=$(NDK_SYSROOT)
149 OPT_CFLAGS = -O2 -funroll-loops -fomit-frame-pointer
150 CFLAGS +=
151 LDFLAGS += -rdynamic -shared
152 SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared
153 LIBS += -lc $(LIBS_android)
154 STRIP := $(NDK_TOOLCHAIN_BASE)/bin/arm-linux-androideabi-strip \
155 --strip-unneeded -R .note -R .comment
156 DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
157 endif
158 ifeq ($(UNAME),Linux)
159 CPU := $(shell uname -m)
160 SOURCES += $(SOURCES_linux)
161 EXTENSION = pd_linux
162 SHARED_EXTENSION = so
163 OS = linux
164 PD_PATH = /usr
165 OPT_CFLAGS = -O2 -funroll-loops -fomit-frame-pointer
166 ALL_CFLAGS += -fPIC
167 ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
168 SHARED_LDFLAGS += -Wl,-soname,$(SHARED_LIB) -shared
169 ALL_LIBS += -lc $(LIBS_linux)
170 STRIP = strip --strip-unneeded -R .note -R .comment
171 DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
172 endif
173 ifeq ($(UNAME),GNU)
174 # GNU/Hurd, should work like GNU/Linux for basically all externals
175 CPU := $(shell uname -m)
176 SOURCES += $(SOURCES_linux)
177 EXTENSION = pd_linux
178 SHARED_EXTENSION = so
179 OS = linux
180 PD_PATH = /usr
181 OPT_CFLAGS = -O2 -funroll-loops -fomit-frame-pointer
182 ALL_CFLAGS += -fPIC
183 ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
184 SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
185 ALL_LIBS += -lc $(LIBS_linux)
186 STRIP = strip --strip-unneeded -R .note -R .comment
187 DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
188 endif
189 ifeq ($(UNAME),GNU/kFreeBSD)
190 # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals
191 CPU := $(shell uname -m)
192 SOURCES += $(SOURCES_linux)
193 EXTENSION = pd_linux
194 SHARED_EXTENSION = so
195 OS = linux
196 PD_PATH = /usr
197 OPT_CFLAGS = -O2 -funroll-loops -fomit-frame-pointer
198 ALL_CFLAGS += -fPIC
199 ALL_LDFLAGS += -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
200 SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB)
201 ALL_LIBS += -lc $(LIBS_linux)
202 STRIP = strip --strip-unneeded -R .note -R .comment
203 DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m)
204 endif
205 ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
206 CPU := $(shell uname -m)
207 SOURCES += $(SOURCES_cygwin)
208 EXTENSION = dll
209 SHARED_EXTENSION = dll
210 OS = cygwin
211 PD_PATH = $(shell cygpath $$PROGRAMFILES)/pd
212 OPT_CFLAGS = -O2 -funroll-loops -fomit-frame-pointer
213 ALL_CFLAGS +=
214 ALL_LDFLAGS += -rdynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
215 SHARED_LDFLAGS += -shared -Wl,-soname,$(SHARED_LIB) -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
216 ALL_LIBS += -lc -lpd $(LIBS_cygwin)
217 STRIP = strip --strip-unneeded -R .note -R .comment
218 DISTBINDIR=$(DISTDIR)-$(OS)
219 endif
220 ifeq (MINGW,$(findstring MINGW,$(UNAME)))
221 CPU := $(shell uname -m)
222 SOURCES += $(SOURCES_windows)
223 EXTENSION = dll
224 SHARED_EXTENSION = dll
225 OS = windows
226 PD_PATH = $(shell cd "$$PROGRAMFILES/pd" && pwd)
227 # MinGW doesn't seem to include cc so force gcc
228 CC=gcc
229 OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer
230 ALL_CFLAGS += -mms-bitfields
231 ALL_LDFLAGS += -s -shared -Wl,--enable-auto-import -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj"
232 SHARED_LDFLAGS += -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj"
233 ALL_LIBS += -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 $(LIBS_windows)
234 STRIP = strip --strip-unneeded -R .note -R .comment
235 DISTBINDIR=$(DISTDIR)-$(OS)
236 endif
237
238 -include Makefile.local
239
240 # in case somebody manually set the HELPPATCHES above
241 HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd)
242
243 ALL_CFLAGS := $(CPPFLAGS) $(ALL_CFLAGS) $(OPT_CFLAGS) $(CFLAGS)
244 ALL_LDFLAGS := $(ALL_LDFLAGS) $(LDFLAGS)
245 ALL_LIBS := $(ALL_LIBS) $(LIBS)
246
247 SHARED_SOURCES ?= $(shell test ! -e lib$(LIBRARY_NAME).c || \
248 echo lib$(LIBRARY_NAME).c )
249 SHARED_HEADERS ?= $(shell test ! -e $(LIBRARY_NAME).h || echo $(LIBRARY_NAME).h)
250 SHARED_LIB ?= lib$(LIBRARY_NAME:=.$(SHARED_EXTENSION))
251
252 .PHONY = all clean distclean install dist \
253 etags dpkg-source showsetup \
254 libdir_install install-objects \
255 single_install install-libobject \
256 install-doc install-examples install-manual \
257 libdir $(LIBRARY_NAME)
258
259 all: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB)
260
261 %.o: %.c $(SHARED_HEADERS)
262 $(CC) $(ALL_CFLAGS) -o $@ -c $<
263
264 %.$(EXTENSION): %.o $(SHARED_LIB)
265 $(CC) $(ALL_LDFLAGS) -o $@ $^ $(ALL_LIBS)
266 chmod a-x $@
267
268 # this links everything into a single binary file
269 $(LIBRARY_NAME): $(LIBRARY_NAME).$(EXTENSION)
270
271 $(LIBRARY_NAME).$(EXTENSION): $(SOURCES:.c=.o) $(LIBRARY_NAME).o
272 $(CC) $(ALL_LDFLAGS) -o $@ $^ $(ALL_LIBS)
273 chmod a-x $@
274
275 $(SHARED_LIB): $(SHARED_SOURCES:.c=.o)
276 $(CC) $(SHARED_LDFLAGS) $(LDFLAGS) -o $@ $^ $(ALL_LIBS)
277
278 install: libdir_install
279
280 # The meta and help files are explicitly installed to make sure they are
281 # actually there. Those files are not optional, then need to be there.
282 install-objects: $(SOURCES:.c=.$(EXTENSION)) $(SHARED_LIB) $(PDOBJECTS) $(SHARED_TCL_LIB)
283 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
284 $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \
285 $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
286 $(INSTALL_DATA) $^ \
287 $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
288 test -z "$(strip $(wildcard $(SOURCES:.c=.tcl)))" || \
289 $(INSTALL_DATA) $(wildcard $(SOURCES:.c=.tcl)) \
290 $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
291 libdir_install: install-objects install-doc install-examples install-manual
292
293 # install library linked as single binary
294 install-libobject: $(LIBRARY_NAME).$(EXTENSION)
295 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
296 $(INSTALL_PROGRAM) $^ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
297 -$(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION)
298
299 single_install: install-libobject install-doc install-examples install-manual
300
301 install-doc:
302 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
303 test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \
304 $(INSTALL_DATA) $(HELPPATCHES) \
305 $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)
306 $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt
307 $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt
308 $(INSTALL_DATA) ChangeLog $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/CHANGES.txt
309
310 install-examples:
311 test -z "$(strip $(EXAMPLES))" || \
312 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \
313 for file in $(EXAMPLES); do \
314 $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \
315 done
316
317 install-manual:
318 test -z "$(strip $(MANUAL))" || \
319 $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \
320 for file in $(MANUAL); do \
321 $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \
322 done
323
324
325 clean:
326 -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) $(SHARED_SOURCES:.c=.o)
327 -rm -f -- $(SOURCES:.c=.$(EXTENSION))
328 -rm -f -- $(LIBRARY_NAME).o
329 -rm -f -- $(LIBRARY_NAME).$(EXTENSION)
330 -rm -f -- $(SHARED_LIB)
331
332 distclean: clean
333 -rm -f -- $(DISTBINDIR).tar.gz
334 -rm -rf -- $(DISTBINDIR)
335 -rm -f -- $(DISTDIR).tar.gz
336 -rm -rf -- $(DISTDIR)
337 -rm -f -- $(ORIGDIR).tar.gz
338 -rm -rf -- $(ORIGDIR)
339
340
341 $(DISTBINDIR):
342 $(INSTALL_DIR) $(DISTBINDIR)
343
344 libdir: all $(DISTBINDIR)
345 $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR)
346 $(INSTALL_DATA) $(SOURCES) $(SHARED_SOURCES) $(SHARED_HEADERS) $(DISTBINDIR)
347 $(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR)
348 test -z "$(strip $(EXTRA_DIST))" || \
349 $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR)
350 # tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR)
351
352 $(DISTDIR):
353 $(INSTALL_DIR) $(DISTDIR)
354
355 $(ORIGDIR):
356 $(INSTALL_DIR) $(ORIGDIR)
357
358 dist: $(DISTDIR)
359 $(INSTALL_DATA) Makefile $(DISTDIR)
360 $(INSTALL_DATA) README.txt $(DISTDIR)
361 $(INSTALL_DATA) LICENSE.txt $(DISTDIR)
362 $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR)
363 test -z "$(strip $(ALLSOURCES))" || \
364 $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR)
365 test -z "$(strip $(wildcard $(ALLSOURCES:.c=.tcl)))" || \
366 $(INSTALL_DATA) $(wildcard $(ALLSOURCES:.c=.tcl)) $(DISTDIR)
367 test -z "$(strip $(SHARED_HEADERS))" || \
368 $(INSTALL_DATA) $(SHARED_HEADERS) $(DISTDIR)
369 test -z "$(strip $(SHARED_SOURCES))" || \
370 $(INSTALL_DATA) $(SHARED_SOURCES) $(DISTDIR)
371 test -z "$(strip $(PDOBJECTS))" || \
372 $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR)
373 test -z "$(strip $(HELPPATCHES))" || \
374 $(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR)
375 test -z "$(strip $(EXTRA_DIST))" || \
376 $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR)
377 test -z "$(strip $(EXAMPLES))" || \
378 $(INSTALL_DIR) $(DISTDIR)/examples && \
379 for file in $(EXAMPLES); do \
380 $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \
381 done
382 test -z "$(strip $(MANUAL))" || \
383 $(INSTALL_DIR) $(DISTDIR)/manual && \
384 for file in $(MANUAL); do \
385 $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \
386 done
387 tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR)
388
389 # make a Debian source package
390 dpkg-source:
391 debclean
392 make distclean dist
393 mv $(DISTDIR) $(ORIGDIR)
394 tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR)
395 rm -f -- $(DISTDIR).tar.gz
396 rm -rf -- $(DISTDIR) $(ORIGDIR)
397 cd .. && dpkg-source -b $(LIBRARY_NAME)
398
399 etags:
400 etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h
401
402 showsetup:
403 @echo "CC: $(CC)"
404 @echo "CFLAGS: $(CFLAGS)"
405 @echo "LDFLAGS: $(LDFLAGS)"
406 @echo "LIBS: $(LIBS)"
407 @echo "ALL_CFLAGS: $(ALL_CFLAGS)"
408 @echo "ALL_LDFLAGS: $(ALL_LDFLAGS)"
409 @echo "ALL_LIBS: $(ALL_LIBS)"
410 @echo "PD_INCLUDE: $(PD_INCLUDE)"
411 @echo "PD_PATH: $(PD_PATH)"
412 @echo "objectsdir: $(objectsdir)"
413 @echo "LIBRARY_NAME: $(LIBRARY_NAME)"
414 @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)"
415 @echo "SOURCES: $(SOURCES)"
416 @echo "SHARED_HEADERS: $(SHARED_HEADERS)"
417 @echo "SHARED_SOURCES: $(SHARED_SOURCES)"
418 @echo "SHARED_LIB: $(SHARED_LIB)"
419 @echo "PDOBJECTS: $(PDOBJECTS)"
420 @echo "ALLSOURCES: $(ALLSOURCES)"
421 @echo "ALLSOURCES TCL: $(wildcard $(ALLSOURCES:.c=.tcl))"
422 @echo "UNAME: $(UNAME)"
423 @echo "CPU: $(CPU)"
424 @echo "pkglibdir: $(pkglibdir)"
425 @echo "DISTDIR: $(DISTDIR)"
426 @echo "ORIGDIR: $(ORIGDIR)"
45 PDLIBBUILDER_DIR=pd-lib-builder/
46 include $(firstword $(wildcard $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder Makefile.pdlibbuilder))
00 #N canvas 169 49 432 242 10;
1 #X text 47 84 iemnet: high performance networking with Pd;
2 #X text 41 134 (c) 2010 IOhannes m zmölnig \, Institute of Electronic
1 #X text 41 134 (c) 2010 IOhannes m zmölnig \, Institute of Electronic
32 Music and Acoustics (IEM) \, University of Music and Performing Arts
43 \, Graz \, Austria;
54 #N canvas 25 49 420 300 META 0;
6 #X text 10 10 VERSION 0.2.1;
5 #X text 10 10 VERSION 0.2.2;
76 #X text 10 30 AUTHOR IOhannes m zmoelnig <zmoelnig@iem.at>;
87 #X text 10 50 NAME iemnet;
98 #X text 10 70 LICENSE GPL-2;
9 #X text 9 91 DESCRIPTION high performance networking with Pd;
1010 #X restore 20 20 pd META;
11 #X text 47 84 iemnet: high performance networking with Pd;
0 Changelog for Makefile.pdlibbuilder.
1
2 v0.5.1, dated 2018-03-15
3 Fixes and improvements for Windows builds:
4 - properly evaluate variables 'PDDIR' and 'PDBINDIR' to find pd.dll
5 - define default path of 32 bit Pd on 64 bit Windows
6 - link C++ externals with standard C libs on Windows, they don't load otherwise
7 - strip installed Windows binaries by default
8 (issues #34, #39, #41, #42 respectively)
9 Warning for all platforms: variable 'PD_PATH' is no longer supported, use the
10 equivalent 'PDDIR'.
11
12 v0.5.0, dated 2018-01-23
13 Implement target architecture detection for Windows builds,
14 and set appropriate options for 32 and 64 bit (used to be for 32 bit only).
15 (feature, issue #37 #38, merge commit 215bf3e)
16
17 v0.4.4, dated 2016-11-22
18 Use variable 'system' when evaluating 'for{Linux,Darwin,Windows}'
19 (bugfix, issue #31, commit 2c14110)
20
21 v0.4.3, dated 2016-11-02
22 Replace flags '-fpic' by 'fPIC'.
23 (bugfix, issue #29, commit 426b38b)
24
25 v0.4.2, dated 2016-10-30
26 Fix issue where incorrect message about m_pd.h is given.
27 (bugfix, commit 2e13d8f)
28
29 v0.4.1, dated 2016-10-27
30 Respect cflag for minimum OSX version when defined by lib makefile.
31 (bugfix, pull request #22, commit 48c4127)
32
33 v0.4.0, dated 2016-10-14
34 Introduced path variables PDDIR, PDINCLUDEDIR, PDBINDIR, PDLIBDIR which can
35 also be defined in environment.
36 (feature, issue #27, commit b0dab72)
37
38 v0.3.1, dated 2016-10-13
39 Fix bug where pd.dll wouldn't be found.
40 (bugfix, commit a0c87be)
41
42 v0.3.0, dated 2016-10-09
43 Variable 'PD_PATH' introduced for pd-extended / pd-l2ork compatibility.
44 (feature, issue #26, commit 41e9743)
45
46 v0.2.8, dated 2016-10-09
47 Allow installed files to contain weird characters (notably '$').
48 (bugfix, pull request #20, commit 5b920b1)
49
50 v0.2.7, dated 2016-10-04
51 Remove all default pd search paths except vanilla's.
52 (discussion, issue #25, commit a6a89dc)
53
54 v0.2.6, dated 2016-09-20
55 Redefined dependency checking so it won't stall rebuilds on OSX.
56 (bugfix, issue #16, commit 9fd1795)
57
58 v0.2.5, dated 2016-06-26
59 Fixed dependency checking for object files in other directories.
60 (bugfix, commit f06e550)
61
62 v0.2.4, dated 2016-06-25
63 Fixed regression bug that disabled all dependency checking.
64 (bugfix, commit 1d7bb5e)
65
66 v0.2.3, dated 2016-03-29
67 Disabled dependency checking for OSX <= 10.5 because it stalled rebuilds.
68 (bugfix, issue #16, commit eb614fd)
69
70 v0.2.2, dated 2016-03-28
71 Removed target 'pre' because it forced rebuild of everything in 'all'.
72 (bugfix, issue #17, commit c989c8e)
73
74 v0.2.1, dated 2015-12-27
75 Implement / respect 'CPPFLAGS','CFLAGS'and 'LDFLAGS'.
76 (bugfix, issue #5, commit 98f3582)
77
78 v0.2.0, dated 2015-12-19
79 Added per-platform multiline defines 'forLinux', 'forDarwin', 'forWindows'.
80 (feature, pull request #9, commit 3946ea5)
81
82 v0.1.0, dated 2015-12-08
83 Added targets 'pre' and 'post' to automatically run before and after 'all'.
84 (feature, pull request #4, commit a5678ac)
85
86 v0.0.2, dated 2015-12-06
87 Improved methods for searching pd paths.
88 (bugfix, commit ed37e6b)
89
90 v0.0.1, dated 2015-10-31
91 Fixed expansion of variable 'lib.version'.
92 (bugfix, issue #1, commit 974b617)
93
94 v0.0.0, dated 2015-06-24
95 Initial version.
96 (commit 16517a2)
0 # Makefile.pdlibbuilder dated 2018-03-15
1 version = 0.5.1
2
3 # Helper makefile for Pure Data external libraries.
4 # Written by Katja Vetter March-June 2015 for the public domain. No warranties.
5 # Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's
6 # ShakeNMake.
7 #
8 # Grab the newest version of Makefile.pdlibbuilder from
9 # https://github.com/pure-data/pd-lib-builder/
10 #
11 # GNU make version >= 3.81 required.
12 #
13 #
14 #=== characteristics ===========================================================
15 #
16 #
17 # - defines build settings based on autodetected OS and architecture
18 # - defines rules to build Pd class- or lib executables from C or C++ sources
19 # - defines rules for libdir installation
20 # - defines convenience targets for developer and user
21 # - evaluates implicit dependencies for non-clean builds
22 #
23 #
24 #=== basic usage ===============================================================
25 #
26 #
27 # In your Makefile, define your Pd lib name and class files, and include
28 # Makefile.pdlibbuilder at the end of the Makefile. Like so:
29 #
30 # ________________________________________________________________________
31 #
32 # # Makefile for mylib
33 #
34 # lib.name = mylib
35 #
36 # class.sources = myclass1.c myclass2.c
37 #
38 # datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt
39 #
40 # include Makefile.pdlibbuilder
41 # ________________________________________________________________________
42 #
43 #
44 # For files in class.sources it is assumed that class basename == source file
45 # basename. The default target builds all classes as individual executables
46 # with Pd's default extension for the platform. For anything more than the
47 # most basic usage, continue reading.
48 #
49 #
50 #=== list of Makefile.pdlibbuilder API variables ===============================
51 #
52 #
53 # Variables available for definition in your library Makefile:
54 #
55 # - lib.name
56 # - lib.setup.sources
57 # - class.sources
58 # - common.sources
59 # - shared.sources
60 # - <classname>.class.sources
61 # - <classname>.class.ldflags
62 # - <classname>.class.ldlibs
63 # - cflags
64 # - ldflags
65 # - ldlibs
66 # - datafiles
67 # - datadirs
68 # - makefiles
69 # - makefiledirs
70 # - externalsdir
71 #
72 # Optional multiline defines evaluated per operating system:
73 #
74 # - forLinux
75 # - forDarwin
76 # - forWindows
77 #
78 # Variables available for your makefile or make command line:
79 #
80 # - make-lib-executable
81 # - suppress-wunused
82 #
83 # Path variables for make command line or environment:
84 #
85 # - PDDIR
86 # - PDINCLUDEDIR
87 # - PDBINDIR
88 # - PDLIBDIR
89 #
90 # Standard make variables for make command line or environment:
91 #
92 # - CPPFLAGS
93 # - CFLAGS
94 # - LDFLAGS
95 # - CC
96 # - CXX
97 # - INSTALL
98 # - STRIP
99 # - DESTDIR
100 #
101 # Deprecated path variables:
102 #
103 # - pdincludepath
104 # - pdbinpath
105 # - objectsdir
106 #
107 #
108 #=== descriptions of Makefile.pdlibbuilder API variables =======================
109 #
110 #
111 # lib.name:
112 # Name of the library directory as it will be installed / distributed. Also the
113 # name of the lib executable in the case where all classes are linked into
114 # a single binary.
115 #
116 # lib.setup.sources:
117 # Source file(s) (C or C++) which must be compiled only when linking all classes
118 # into a single lib binary.
119 #
120 # class.sources:
121 # All sources files (C or C++) for which the condition holds that
122 # class name == source file basename.
123 #
124 # <classname>.class.sources:
125 # Source file(s) (C or C++) specific to class <classname>. Use this for
126 # multiple-source classes or when class name != source file basename.
127 #
128 # common.sources:
129 # Source file(s) which must be statically linked to each class in the library.
130 #
131 # shared.sources:
132 # Source file(s) (C or C++) to build a shared dynamic link lib, to be linked
133 # with all class executables.
134 #
135 # cflags, ldflags, ldlibs:
136 # Define cflags (preprocessor&compiler), ldflags (linker) and ldlibs (dynamic
137 # link libs) for the whole library. These flags are added to platform-specific
138 # flags defined by Makefile.pdlibbuilder.
139 #
140 # <classname>.class.ldflags and <classname>.class.ldlibs:
141 # Define ldflags resp. ldlibs specific to class <classname>. These flags are
142 # added to platform-specific flags defined by Makefile.pdlibbuilder, and flags
143 # defined in your Makefile for the whole library. Note: cflags can not be
144 # defined per class in the current implementation.
145 #
146 # datafiles and datadirs:
147 # All extra files you want to include in binary distributions of the
148 # library: abstractions and help patches, example patches, meta patch, readme
149 # and license texts, manuals, sound files, etcetera. Use 'datafiles' for all
150 # files that should go into your lib rootdir and 'datadirs' for complete
151 # directories you want to copy from source to distribution.
152 #
153 # forLinux, forDarwin, forWindows:
154 # Shorthand for 'variable definitions for Linux only' etc. Use like:
155 # define forLinux
156 # cflags += -DLINUX
157 # class.sources += linuxthing.c
158 # endef
159 #
160 # makefiles and makefiledirs:
161 # Extra makefiles or directories with makefiles that should be made in sub-make
162 # processes.
163 #
164 # make-lib-executable:
165 # When this variable is defined 'yes' in your makefile or as command argument,
166 # Makefile.pdlibbuilder will try to build all classes into a single library
167 # executable (but it will force exit if lib.setup.sources is undefined).
168 # If your makefile defines 'make-lib-executable=yes' as the library default,
169 # this can still be overridden with 'make-lib-executable=no' as command argument
170 # to build individual class executables (the Makefile.pdlibbuilder default.)
171 #
172 # suppress-wunused:
173 # When this variable is defined ('yes' or any other value), -Wunused-variable,
174 # -Wunused-parameter, -Wunused-value and -Wunused-function are suppressed,
175 # but the other warnings from -Wall are retained.
176 #
177 # PDDIR:
178 # Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and
179 # PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin.
180 #
181 # PDINCLUDEDIR:
182 # Directory where Pd API m_pd.h should be found, and other Pd header files.
183 # Overrides the default search path.
184 #
185 # PDBINDIR:
186 # Directory where pd.dll should be found for linking (Windows only). Overrides
187 # the default search path.
188 #
189 # PDLIBDIR:
190 # Root directory for installation of Pd library directories. Overrides the
191 # default install location.
192 #
193 # DESTDIR:
194 # Prepended path component for staged install.
195 #
196 # CPPFLAGS:
197 # Preprocessor flags which are not strictly required for building.
198 #
199 # CFLAGS:
200 # Compiler flags which are not strictly required for building. Compiler flags
201 # defined by Makefile.pdlibbuilder for warning, optimization and architecture
202 # specification are overriden by CFLAGS.
203 #
204 # LDFLAGS:
205 # Linker flags which are not strictly required for building. Linker flags
206 # defined by Makefile.pdlibbuilder for architecture specification are overriden
207 # by LDFLAGS.
208 #
209 # CC and CXX:
210 # C and C++ compiler programs as defined in your build environment.
211 #
212 # INSTALL
213 # Definition of install program.
214 #
215 # STRIP
216 # Name of strip program. Default 'strip' can be overridden in cross compilation
217 # environments.
218 #
219 # objectsdir:
220 # Root directory for installation of Pd library directories, like PDLIBDIR but
221 # not overridable by environment. Supported for compatibility with pd-extended
222 # central makefile, but deprecated otherwise.
223 #
224 # pdincludepath, pdbinpath:
225 # As PDINCLUDEDIR and PDBINDIR but not overridable by environment. Deprecated
226 # as user variables.
227 #
228 #
229 #=== paths =====================================================================
230 #
231 #
232 # Source files in directories other than current working directory must be
233 # prefixed with their relative path. Do not rely on VPATH or vpath.
234 # Object (.o) files are built in the directory of their source files.
235 # Executables are built in current working directory.
236 #
237 # Default search path for m_pd.h and other API header files is platform
238 # dependent, and overridable by PDINCLUDEDIR:
239 #
240 # Linux: /usr/include/pd
241 #
242 # OSX: /Applications/Pd*.app/Contents/Resources/src
243 #
244 # Windows: %PROGRAMFILES%/Pd/src
245 # %PROGRAMFILES(X86)%/Pd/src (32 bit builds on 64 bit Windows)
246 #
247 # Default search path for binary pd.dll (Windows), overridable by PDBINDIR
248 #
249 # %PROGRAMFILES%/Pd/bin
250 # %PROGRAMFILES(X86)%/Pd/bin (32 bit builds on 64 bit Windows)
251 #
252 # Default location to install pd libraries is platform dependent, and
253 # overridable by PDLIBDIR:
254 #
255 # Linux: /usr/local/lib/pd-externals
256 # OSX: ~/Library/Pd
257 # Windows: %APPDATA%/Pd
258 #
259 # https://puredata.info/docs/faq/how-do-i-install-externals-and-help-files
260 # The rationale for not installing to ~/pd-externals by default on Linux
261 # is that some people share the home dir between 32 and 64 bit installations.
262 #
263 #
264 #=== targets ===================================================================
265 #
266 #
267 # all: build $(executables) plus optional post target
268 # post: target to build after $(executables)
269 # alldebug: build all with -g option turned on for debug symbols
270 # <classname>: force clean build of an individual class
271 # <sourcefile>.pre: make preprocessor output file in current working directory
272 # <sourcefile>.lst: make asm/source output file in current working directory
273 #
274 # install: install executables and data files
275 # clean: remove build products from source tree
276 #
277 # help: print help text
278 # vars: print makefile variables
279 # allvars: print all variables
280 # depend: print generated prerequisites
281 # coffee: dummy target
282 #
283 # Variable $(executables) expands to class executables plus optional shared lib,
284 # or alternatively to single lib executable when make-lib-executable=true.
285 # Targets pre and post can be defined by library makefile. Make sure to include
286 # Makefile.pdlibbuilder first so default target all will not be redefined.
287 #
288 #
289 #=== Pd-extended libdir concept ================================================
290 #
291 #
292 # For libdir layout as conceived by Hans-Christoph Steiner, see:
293 #
294 # https://puredata.info/docs/developer/Libdir
295 #
296 # Files README.txt, LICENSE.txt and <lib.name>-meta.pd are part of the libdir
297 # convention. Help patches for each class and abstraction are supposed to be
298 # available. Makefile.pdlibbuilder does not force the presence of these files
299 # however. It does not automatically include such files in libdir installations.
300 # Data files you want to include in distributions must be defined explicitly in
301 # your Makefile.
302 #
303 #
304 #=== Makefile.pdlibbuilder syntax conventions ==================================
305 #
306 #
307 # Makefile.pdlibbuilder variable names are lower case. Default make variables,
308 # environment variables, and standard user variables (CC, CXX, CFLAGS, DESTDIR)
309 # are upper case. Use target 'allvars' to print all variables and their values.
310 #
311 # 'Fields' in data variables are separated by dots, like in 'foo.class.sources'.
312 # Words in variables expressing a function or command are separated by dashes,
313 # like in 'make-lib-executable'.
314 #
315 #
316 #=== useful make options =======================================================
317 #
318 #
319 # Use 'make -d <target>' to print debug details of the make process.
320 # Use 'make -p <target>' to print make's database.
321 #
322 #
323 #=== TODO ======================================================================
324 #
325 #
326 # - decide whether to use -static-libgcc or shared dll in MinGW
327 # - cygwin support
328 # - android support
329 # - figure out how to handle '$' in filenames
330 # - add makefile template targets dpkg-source dist libdir distclean tags?
331 #
332 #
333 #=== end of documentation sections =============================================
334 #
335 #
336 ################################################################################
337 ################################################################################
338 ################################################################################
339
340
341 # GNU make version 3.81 (2006) or higher is required because of the following:
342 # - function 'info'
343 # - variable '.DEFAULT_GOAL'
344
345 # force exit when make version is < 3.81
346 ifneq ($(firstword $(sort 3.81 $(MAKE_VERSION))), 3.81)
347 $(error GNU make version 3.81 or higher is required)
348 endif
349
350 # Relative path to externals root dir in multi-lib source tree like
351 # pd-extended SVN. Default is parent of current working directory. May be
352 # defined differently in including makefile.
353 externalsdir ?= ..
354
355 # variable you can use to check if Makefile.pdlibbuilder is already included
356 Makefile.pdlibbuilder = true
357
358
359 ################################################################################
360 ### variables: library name and version ########################################
361 ################################################################################
362
363
364 # strip possibles spaces from lib.name, they mess up calculated file names
365 lib.name := $(strip $(lib.name))
366
367 # if meta file exists, check library version
368 metafile := $(wildcard $(lib.name)-meta.pd)
369
370 ifdef metafile
371 lib.version := $(shell sed -n \
372 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \
373 $(metafile))
374 endif
375
376
377 ################################################################################
378 ### variables: files ###########################################################
379 ################################################################################
380
381
382 #=== sources ===================================================================
383
384
385 # (re)define <classname>.class.sources using file names in class.sources
386
387 define add-class-source
388 $(notdir $(basename $v)).class.sources += $v
389 endef
390
391 $(foreach v, $(class.sources), $(eval $(add-class-source)))
392
393 # derive class names from <classname>.class.sources variables
394 sourcevariables := $(filter %.class.sources, $(.VARIABLES))
395 classes := $(basename $(basename $(sourcevariables)))
396
397 # accumulate all source files specified in makefile
398 classes.sources := $(sort $(foreach v, $(sourcevariables), $($v)))
399 all.sources := $(classes.sources) $(lib.setup.sources) \
400 $(shared.sources) $(common.sources)
401
402
403 #=== object files ==============================================================
404
405
406 # construct object filenames from all C and C++ source file names
407 classes.objects := $(addsuffix .o, $(basename $(classes.sources)))
408 common.objects := $(addsuffix .o, $(basename $(common.sources)))
409 shared.objects := $(addsuffix .o, $(basename $(shared.sources)))
410 lib.setup.objects := $(addsuffix .o, $(basename $(lib.setup.sources)))
411 all.objects = $(classes.objects) $(common.objects) $(shared.objects) \
412 $(lib.setup.objects)
413
414
415 #=== executables ===============================================================
416
417
418 # use recursive variables here because executable extension is not yet known
419
420 # construct class executable names from class names
421 classes.executables = $(addsuffix .$(extension), $(classes))
422
423 # construct shared lib executable name if shared sources are defined
424 ifdef shared.sources
425 shared.lib = lib$(lib.name).$(shared.extension)
426 else
427 shared.lib =
428 endif
429
430
431 ################################################################################
432 ### platform detection #########################################################
433 ################################################################################
434
435
436 #=== operating system ==========================================================
437
438
439 # The following systems are defined: Linux, Darwin, Windows. GNU and
440 # GNU/kFreeBSD are treated as Linux to get the same options.
441
442 uname := $(shell uname)
443
444 ifeq ($(findstring $(uname), Linux GNU GNU/kFreeBSD), $(uname))
445 system = Linux
446 endif
447
448 ifeq ($(uname), Darwin)
449 system = Darwin
450 endif
451
452 ifeq ($(filter MINGW% MSYS%, $(uname)), $(uname))
453 system = Windows
454 endif
455
456 # Unfortunately not all Mingw versions provide a link cc > gcc, therefore
457 # gcc is hardcoded here (but not if CC is redefined).
458 ifeq ($(system), Windows)
459 ifeq ($(origin CC), default)
460 CC = gcc
461 endif
462 endif
463
464 # evaluate possible system-specific multiline defines from library makefile
465 $(eval $(for$(system)))
466
467
468 # TODO: Cygwin, Android
469
470
471 #=== architecture ==============================================================
472
473
474 # native architecture of the build machine
475 build.arch := $(shell uname -m)
476
477 # Target architecture as reported by compiler. Give precedence to eventual
478 # user-defined compiler. The first field of <cpu>-<vendor>-<os> is extracted.
479 ifneq ($(origin CXX), default)
480 dumpmachine.cpu = $(firstword $(subst -, ,$(shell $(CXX) -dumpmachine)))
481 else
482 dumpmachine.cpu = $(firstword $(subst -, ,$(shell $(CC) -dumpmachine)))
483 endif
484
485 # Target architecture as reported by compiler is only used for Windows at the
486 # moment. For other systems this still has to be tested.
487 ifeq ($(system), Windows)
488 target.arch = $(dumpmachine.cpu)
489 else
490 target.arch = $(build.arch)
491 endif
492
493
494 ################################################################################
495 ### variables per platform #####################################################
496 ################################################################################
497
498
499 #=== flags per architecture ====================================================
500
501
502 # Set architecture-dependent cflags, mainly for Linux. For Mac and Windows,
503 # arch.c.flags are overriden below.
504
505 # Raspberry Pi 1st generation
506 ifeq ($(target.arch), armv6l)
507 arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard
508
509 # Beagle, Udoo, RPi2 etc.
510 else ifeq ($(target.arch), armv7l)
511 arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard
512
513 # Intel 32 bit, build with SSE and SSE2 instructions
514 else ifeq ($(findstring $(target.arch), i386 i686), $(target.arch))
515 arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2
516
517 # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions
518 else ifeq ($(findstring $(target.arch), x86_64), $(target.arch))
519 arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3
520
521 # if none of the above architectures detected
522 else
523 arch.c.flags =
524 endif
525
526
527 #=== flags and paths for Linux =================================================
528
529
530 ifeq ($(system), Linux)
531 prefix = /usr/local
532 libdir := $(prefix)/lib
533 pkglibdir = $(libdir)/pd-externals
534 pdincludepath := $(wildcard /usr/include/pd)
535 extension = pd_linux
536 cpp.flags := -DUNIX
537 c.flags := -fPIC
538 c.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
539 c.ldlibs := -lc -lm
540 cxx.flags := -fPIC -fcheck-new
541 cxx.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags
542 cxx.ldlibs := -lc -lm -lstdc++
543 shared.extension = so
544 shared.ldflags := -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib)
545 endif
546
547
548 #=== flags and paths for Darwin ================================================
549
550
551 # On OSX we try to build fat binaries by default. It is assumed that OSX i386
552 # can build for ppc and OSX x86_64 can't. TODO: try to refine this condition.
553 # LLVM-clang doesn't support -fcheck-new, therefore this flag is omitted for
554 # OSX x86_64.
555
556
557 ifeq ($(system), Darwin)
558 pkglibdir = $(HOME)/Library/Pd
559 pdincludepath := $(firstword $(wildcard \
560 /Applications/Pd*.app/Contents/Resources/src))
561 extension = pd_darwin
562 cpp.flags := -DUNIX -DMACOSX -I /sw/include
563 c.flags :=
564 c.ldflags := -undefined suppress -flat_namespace -bundle
565 c.ldlibs := -lc
566 cxx.ldflags := -undefined suppress -flat_namespace -bundle
567 cxx.ldlibs := -lc
568 shared.extension = dylib
569 shared.ldflags = -dynamiclib -undefined dynamic_lookup \
570 -install_name @loader_path/$(shared.lib) \
571 -compatibility_version 1 -current_version 1.0
572 version.flag := $(filter $(cflags), -mmacosx-version-min=%)
573 ifeq ($(target.arch), i386)
574 cxx.flags := -fcheck-new
575 arch := ppc i386 x86_64
576 version.flag = -mmacosx-version-min=10.4
577 endif
578 ifeq ($(target.arch), x86_64)
579 arch := i386 x86_64
580 version.flag = -mmacosx-version-min=10.6
581 endif
582 ifneq ($(filter -mmacosx-version-min=%, $(cflags)),)
583 version.flag := $(filter -mmacosx-version-min=%, $(cflags))
584 endif
585 arch.c.flags := $(addprefix -arch , $(arch)) $(version.flag)
586 arch.ld.flags := $(arch.c.flags)
587 endif
588
589
590 #=== flags and paths for Windows ===============================================
591
592
593 # Standard paths on Windows contain spaces, and GNU make functions treat such
594 # paths as lists, with unintended effects. Therefore we must use shell function
595 # ls instead of make's wildcard when probing for a path, and use double quotes
596 # when specifying a path in a command argument.
597
598 # Default paths in Mingw / Mingw-w64 environments. 'PROGRAMFILES' is standard
599 # location for builds with native architecture, 'ProgramFiles(x86)' for i686
600 # builds on x86_64 Windows (detection method by Lucas Cordiviola). Curly braces
601 # required because of parentheses in variable name.
602 ifeq ($(system), Windows)
603 pkglibdir := $(APPDATA)/Pd
604 ifeq ($(MINGW_CHOST), i686-w64-mingw32)
605 programfiles := ${ProgramFiles(x86)}
606 else
607 programfiles := $(PROGRAMFILES)
608 endif
609 pdbinpath := $(programfiles)/Pd/bin
610 pdincludepath := $(programfiles)/Pd/src
611 endif
612
613 # Store default path to pd.dll in PDBINDIR if the latter is not user-defined.
614 # For include path this is done in the platform-independent paths section below,
615 # but for PDBINDIR it is done here so ld flags can be evaluated as immediate
616 # variables.
617 ifeq ($(system), Windows)
618 ifdef PDDIR
619 PDBINDIR := $(PDDIR)/bin
620 endif
621 PDBINDIR ?= $(pdbinpath)
622 endif
623
624 # TODO: decide whether -mms-bitfields should be specified.
625 ifeq ($(system), Windows)
626 cpp.flags := -DMSW -DNT
627 ifeq ($(filter i%86 mingw32, $(target.arch)), $(target.arch))
628 arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse
629 else ifeq (x86_64, $(target.arch))
630 cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64
631 arch.c.flags := -march=core2 -msse -msse2 -msse3 -mfpmath=sse
632 else
633 arch.c.flags =
634 endif
635 extension = dll
636 c.flags :=
637 c.ldflags := -static-libgcc -shared \
638 -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll"
639 c.ldlibs :=
640 cxx.flags := -fcheck-new
641 cxx.ldflags := -static-libgcc -static-libstdc++ -shared \
642 -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll"
643 cxx.ldlibs :=
644 shared.extension = dll
645 shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd.dll"
646 stripflags = --strip-all
647 endif
648
649
650 #=== paths =====================================================================
651
652
653 # Platform-dependent default paths are specified above, but overridable.
654 # Path variables in upper case can be defined as make command argument or in the
655 # environment. Variable 'objectsdir' is supported for compatibility with
656 # the build system that pd-l2ork has inherited from pd-extended.
657
658 PDINCLUDEDIR ?= $(pdincludepath)
659 PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir))
660
661 ifdef PDDIR
662 PDINCLUDEDIR := $(wildcard $(PDDIR)/src)
663 endif
664
665 # base path where all components of the lib will be installed by default
666 installpath := $(DESTDIR)$(PDLIBDIR)/$(lib.name)
667
668 # check if include path contains spaces (as is often the case on Windows)
669 # if so, store the path so we can later do checks with it
670 pdincludepathwithspaces := $(if $(word 2, $(PDINCLUDEDIR)), $(PDINCLUDEDIR))
671
672
673 #=== accumulated build flags ===================================================
674
675
676 # From GNU make docs: 'Users expect to be able to specify CFLAGS freely
677 # themselves.' So we use CFLAGS to define options which are not strictly
678 # required for compilation: optimizations, architecture specifications, and
679 # warnings. CFLAGS can be safely overriden using a make command argument.
680 # Variables cflags, ldflags and ldlibs may be defined in including makefile.
681
682 optimization.flags = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
683 warn.flags = -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing
684
685 # suppress -Wunused-variable & Co if you don't want to clutter a build log
686 ifdef suppress-wunused
687 warn.flags += $(addprefix -Wno-unused-, function parameter value variable)
688 endif
689
690 CFLAGS = $(warn.flags) $(optimization.flags) $(arch.c.flags)
691
692 # preprocessor flags
693 cpp.flags := -DPD -I "$(PDINCLUDEDIR)" $(cpp.flags) $(CPPFLAGS)
694
695 # flags for dependency checking (cflags from makefile may define -I options)
696 depcheck.flags := $(cpp.flags) $(cflags)
697
698 # architecture specifications for linker are overridable by LDFLAGS
699 LDFLAGS := $(arch.ld.flags)
700
701 # now add the same ld flags to shared dynamic lib
702 shared.ldflags := $(shared.ldflags) $(LDFLAGS)
703
704 # accumulated flags for C compiler / linker
705 c.flags := $(cpp.flags) $(c.flags) $(cflags) $(CFLAGS)
706 c.ldflags := $(c.ldflags) $(ldflags) $(LDFLAGS)
707 c.ldlibs := $(c.ldlibs) $(ldlibs)
708
709 # accumulated flags for C++ compiler / linker
710 cxx.flags := $(cpp.flags) $(cxx.flags) $(cflags) $(CFLAGS)
711 cxx.ldflags := $(cxx.ldflags) $(ldflags) $(LDFLAGS)
712 cxx.ldlibs := $(cxx.ldlibs) $(ldlibs)
713
714
715 ################################################################################
716 ### variables: tools ###########################################################
717 ################################################################################
718
719
720 # aliases so we can later define 'compile-$1' and set 'c' or 'cxx' as argument
721 compile-c := $(CC)
722 compile-cxx := $(CXX)
723
724
725 ################################################################################
726 ### checks #####################################################################
727 ################################################################################
728
729
730 # At this point most variables are defined. Now do some checks and info's
731 # before rules begin.
732
733 # 'forward declaration' of default target, needed to do checks
734 all:
735
736 # To avoid unpredictable results, make sure the default target is not redefined
737 # by including makefile.
738 ifneq ($(.DEFAULT_GOAL), all)
739 $(error Default target must be 'all'.)
740 endif
741
742 # find out which target(s) will be made
743 ifdef MAKECMDGOALS
744 goals := $(MAKECMDGOALS)
745 else
746 goals := all
747 endif
748
749 # store path to Pd API m_pd.h if it is found
750 ifdef PDINCLUDEDIR
751 mpdh := $(shell ls "$(PDINCLUDEDIR)/m_pd.h")
752 endif
753
754 # store path to pd.dll; if not found, ls will give a useful error
755 ifeq ($(system), Windows)
756 pddll := $(shell ls "$(PDBINDIR)/pd.dll")
757 endif
758
759 # print Makefile.pdlibbuilder version
760 $(info ++++ info: using Makefile.pdlibbuilder version $(version))
761
762 # when making target all, check if m_pd.h is found and print info about it
763 ifeq ($(goals), all)
764 $(if $(mpdh), \
765 $(info ++++ info: using Pd API $(mpdh)), \
766 $(warning Where is Pd API m_pd.h? Do 'make help' for info.))
767 endif
768
769 # print target info
770 $(info ++++ info: making target $(goals) $(if $(lib.name),in lib $(lib.name)))
771
772 # when installing, print installpath info
773 $(if $(filter install install-lib, $(goals)), $(info ++++ info: \
774 installpath is '$(installpath)'))
775
776
777 #=== define executables ========================================================
778
779
780 # By default we build class executables, and optionally a shared dynamic link
781 # lib. When make-lib-executable=yes we build all classes into a single lib
782 # executable, on the condition that variable lib.setup.sources is defined.
783
784 ifeq ($(make-lib-executable),yes)
785 $(if $(lib.setup.sources), ,\
786 $(error Can not build library blob because lib.setup.sources is undefined))
787 executables := $(lib.name).$(extension)
788 else
789 executables := $(classes.executables) $(shared.lib)
790 endif
791
792
793 ################################################################################
794 ### rules: special targets #####################################################
795 ################################################################################
796
797
798 # Disable built-in rules. If some target can't be built with the specified
799 # rules, it should not be built at all.
800 MAKEFLAGS += --no-builtin-rules
801
802 .PRECIOUS:
803 .SUFFIXES:
804 .PHONY: all post build-lib \
805 $(classes) $(makefiledirs) $(makefiles) \
806 install install-executables install-datafiles install-datadirs \
807 force clean vars allvars depend help
808
809
810 ################################################################################
811 ### rules: build targets #######################################################
812 ################################################################################
813
814
815 # Target all forces the build of targets [$(executables) post] in
816 # deterministic order. Target $(executables) builds class executables plus
817 # optional shared lib or alternatively a single lib executable when
818 # make-lib-executable=true. Target post is optionally defined by
819 # library makefile.
820
821 all: post
822 post: $(executables)
823
824 all:
825 $(info ++++info: target all in lib $(lib.name) completed)
826
827 # build all with -g option turned on for debug symbols
828 alldebug: c.flags += -g
829 alldebug: cxx.flags += -g
830 alldebug: all
831
832
833 #=== class executable ==========================================================
834
835
836 # recipe for linking objects in class executable
837 # argument $1 = compiler type (c or cxx)
838 # argument $2 = class basename
839 define link-class
840 $(compile-$1) \
841 $($1.ldflags) $($2.class.ldflags) \
842 -o $2.$(extension) \
843 $(addsuffix .o, $(basename $($2.class.sources))) \
844 $(addsuffix .o, $(basename $(common.sources))) \
845 $($1.ldlibs) $($2.class.ldlibs) $(shared.lib)
846 endef
847
848 # general rule for linking object files in class executable
849 %.$(extension): $(shared.lib)
850 $(info ++++ info: linking objects in $@ for lib $(lib.name))
851 $(if $(filter %.cc %.cpp, $($*.class.sources)), \
852 $(call link-class,cxx,$*), \
853 $(call link-class,c,$*))
854
855
856 #=== library blob ==============================================================
857
858
859 # build all classes into single executable
860 build-lib: $(lib.name).$(extension)
861 $(info ++++ info: library blob $(lib.name).$(extension) completed)
862
863 # recipe for linking objects in lib executable
864 # argument $1 = compiler type (c or cxx)
865 define link-lib
866 $(compile-$1) \
867 $($1.ldflags) $(lib.ldflags) \
868 -o $(lib.name).$(extension) $(all.objects) \
869 $($1.ldlibs) $(lib.ldlibs)
870 endef
871
872 # rule for linking objects in lib executable
873 # declared conditionally to avoid name clashes
874 ifeq ($(make-lib-executable),yes)
875 $(lib.name).$(extension): $(all.objects)
876 $(if $(filter %.cc %.cpp, $(all.sources)), \
877 $(call link-lib,cxx), \
878 $(call link-lib,c))
879 endif
880
881
882 #=== shared dynamic lib ========================================================
883
884
885 # recipe for linking objects in shared executable
886 # argument $1 = compiler type (c or cxx)
887 define link-shared
888 $(compile-$1) \
889 $(shared.ldflags) \
890 -o lib$(lib.name).$(shared.extension) $(shared.objects) \
891 $($1.ldlibs) $(shared.ldlibs)
892 endef
893
894 # rule for linking objects in shared executable
895 # build recipe is in macro 'link-shared'
896 lib$(lib.name).$(shared.extension): $(shared.objects)
897 $(info ++++ info: linking objects in shared lib $@)
898 $(if $(filter %.cc %.cpp, $(shared.sources)), \
899 $(call link-shared,cxx), \
900 $(call link-shared,c))
901
902
903 #=== object files ==============================================================
904
905
906 # recipe to make .o file from source
907 # argument $1 is compiler type (c or cxx)
908 define make-object-file
909 $(info ++++ info: making $@ in lib $(lib.name))
910 $(compile-$1) \
911 $($1.flags) \
912 -o $@ -c $<
913 endef
914
915 # Three rules to create .o files. These are double colon 'terminal' rules,
916 # meaning they are the last in a rules chain.
917
918 %.o:: %.c
919 $(call make-object-file,c)
920
921 %.o:: %.cc
922 $(call make-object-file,cxx)
923
924 %.o:: %.cpp
925 $(call make-object-file,cxx)
926
927
928 #=== explicit prerequisites for class executables ==============================
929
930
931 # For class executables, prerequisite rules are declared in run time. Target
932 # 'depend' prints these rules for debugging purposes.
933
934 # declare explicit prerequisites rule like 'class: class.extension'
935 # argument $v is class basename
936 define declare-class-target
937 $v: $v.$(extension)
938 endef
939
940 # declare explicit prerequisites rule like 'class.extension: object1.o object2.o'
941 # argument $v is class basename
942 define declare-class-executable-target
943 $v.$(extension): $(addsuffix .o, $(basename $($v.class.sources))) \
944 $(addsuffix .o, $(basename $(common.sources)))
945 endef
946
947 # evaluate explicit prerequisite rules for all classes
948 $(foreach v, $(classes), $(eval $(declare-class-target)))
949 $(foreach v, $(classes), $(eval $(declare-class-executable-target)))
950
951
952 #=== implicit prerequisites for class executables ==============================
953
954
955 # Evaluating implicit prerequisites (header files) with help from the
956 # preprocessor is 'expensive' so this is done conditionally and selectively.
957 # Note that it is also possible to trigger a build via install targets, in
958 # which case implicit prerequisites are not checked.
959
960 # When the Pd include path contains spaces it will mess up the implicit
961 # prerequisites rules.
962 disable-dependency-tracking := $(strip $(pdincludepathwithspaces))
963
964 ifndef disable-dependency-tracking
965 must-build-everything := $(filter all, $(goals))
966 must-build-class := $(filter $(classes), $(goals))
967 must-build-sources := $(foreach v, $(must-build-class), $($v.class.sources))
968 endif
969
970 # declare implicit prerequisites rule like 'object.o: header1.h header2.h ...'
971 # argument $1 is input source file(s)
972 # dir is explicitly added because option -MM strips it by default
973 define declare-object-target
974 $(dir $1)$(filter %.o: %.h, $(shell $(CPP) $(depcheck.flags) -MM $1)) $(MAKEFILE_LIST)
975 endef
976
977 # evaluate implicit prerequisite rules when rebuilding everything
978 ifdef must-build-everything
979 $(if $(wildcard $(all.objects)), \
980 $(info ++++ info: evaluating implicit prerequisites in lib $(lib.name).....) \
981 $(foreach v, $(all.sources), $(eval $(call declare-object-target, $v))))
982 endif
983
984 # evaluate implicit prerequisite rules when selectively building classes
985 ifdef must-build-class
986 $(foreach v, $(must-build-sources), \
987 $(eval $(call declare-object-target, $v)))
988 $(foreach v, $(shared.sources), \
989 $(eval $(call declare-object-target, $v)))
990 endif
991
992
993 ################################################################################
994 ### rules: preprocessor and assembly files #####################################
995 ################################################################################
996
997
998 # Preprocessor and assembly output files for bug tracing etc. They are not part
999 # of the build processes for executables. By default these files are created in
1000 # the current working directory. Dependency tracking is not performed, the build
1001 # is forced instead to make sure it's up to date.
1002
1003 force:
1004
1005
1006 #=== preprocessor file =========================================================
1007
1008
1009 # make preprocessor output file with extension .pre
1010 # argument $1 = compiler type (c or cxx)
1011 define make-preprocessor-file
1012 $(info ++++ info: making preprocessor output file $(notdir $*.pre) \
1013 in current working directory)
1014 $(compile-$1) -E $< $(c.flags) $($1.flags) -o $(notdir $*.pre)
1015 endef
1016
1017 %.pre:: %.c force
1018 $(call make-preprocessor-file,c)
1019
1020 %.pre:: %.cc force
1021 $(call make-preprocessor-file,cxx)
1022
1023 %.pre:: %.cpp force
1024 $(call make-preprocessor-file,cxx)
1025
1026
1027 #=== assembly file =============================================================
1028
1029
1030 # make C / assembly interleaved output file with extension .lst
1031 # argument $1 = compiler type (c or cxx)
1032 define make-assembly-file
1033 $(info ++++ info: making assembly output file $(notdir $*.lst) \
1034 in current working directory)
1035 $(compile-$1) \
1036 -c -Wa,-a,-ad -fverbose-asm \
1037 $($1.flags) \
1038 $< > $(notdir $*.lst)
1039 endef
1040
1041 %.lst:: %.c force
1042 $(call make-assembly-file,c)
1043
1044 %.lst:: %.cc force
1045 $(call make-assembly-file,cxx)
1046
1047 %.lst:: %.cpp force
1048 $(call make-assembly-file,cxx)
1049
1050
1051 ################################################################################
1052 ### rules: installation targets ################################################
1053 ################################################################################
1054
1055
1056 #=== strip =====================================================================
1057
1058
1059 # Stripping of installed binaries will only be done when variable 'stripflags'
1060 # is defined non-empty. No default definition is provided except for Windows
1061 # where the unstripped binaries are large, especially in the case of Mingw-w64.
1062
1063 # Note: while stripping all symbols ('-s' or '--strip-all') is possible for
1064 # Linux and Windows, in the case of OSX only non-global symbols can be stripped
1065 # (option '-x' or '--discard-all').
1066
1067 # Make definition of strip command overridable so it can be defined in an
1068 # environment for cross-compilation.
1069 STRIP ?= strip
1070
1071 # Commands in 'strip-executables' will be executed conditionally in the rule for
1072 # target 'install-executables'.
1073 strip-executables = cd "$(installpath)" && \
1074 $(foreach v, $(executables), $(STRIP) $(stripflags) '$v';)
1075
1076
1077 #=== install ===================================================================
1078
1079
1080 # Install targets depend on successful exit status of target all because nothing
1081 # must be installed in case of a build error.
1082
1083 # -p = preserve time stamps
1084 # -m = set permission mode (as in chmod)
1085 # -d = create all components of specified directories
1086 INSTALL = install
1087 INSTALL_PROGRAM := $(INSTALL) -p -m 644
1088 INSTALL_DATA := $(INSTALL) -p -m 644
1089 INSTALL_DIR := $(INSTALL) -m 755 -d
1090
1091 # strip spaces from file names
1092 executables := $(strip $(executables))
1093 datafiles := $(strip $(datafiles))
1094 datadirs := $(strip $(datadirs))
1095
1096 # Do not make any install sub-target with empty variable definition because the
1097 # install program would exit with an error.
1098 install: $(if $(executables), install-executables)
1099 install: $(if $(datafiles), install-datafiles)
1100 install: $(if $(datadirs), install-datadirs)
1101
1102 install-executables: all
1103 $(INSTALL_DIR) -v "$(installpath)"
1104 $(foreach v, $(executables), \
1105 $(INSTALL_PROGRAM) '$v' "$(installpath)";)
1106 $(info ++++ info: executables of lib $(lib.name) installed \
1107 from $(CURDIR) to $(installpath))
1108 $(if $(stripflags), $(strip-executables),)
1109
1110 install-datafiles: all
1111 $(INSTALL_DIR) -v "$(installpath)"
1112 $(foreach v, $(datafiles), \
1113 $(INSTALL_DATA) '$(v)' "$(installpath)";)
1114 $(info ++++ info: data files of lib $(lib.name) installed \
1115 from $(CURDIR) to $(installpath))
1116
1117 install-datadirs: all
1118 $(foreach v, $(datadirs), $(INSTALL_DIR) "$(installpath)/$v";)
1119 $(foreach v, $(datadirs), \
1120 $(INSTALL_DATA) $(wildcard $v/*) "$(installpath)/$v";)
1121 $(info ++++ info: data directories of lib $(lib.name) installed \
1122 from $(CURDIR) to $(installpath))
1123
1124
1125 ################################################################################
1126 ### rules: distribution targets ################################################
1127 ################################################################################
1128
1129
1130 # TODO
1131 # These targets are implemented in Makefile Template, but I have to figure out
1132 # how to do it under the not-so-strict conditions of Makefile.pdlibbuilder.
1133
1134 # make source package
1135 dist:
1136 @echo "target dist not yet implemented"
1137
1138 # make Debian source package
1139 dpkg-source:
1140 @echo "target dpkg-source not yet implemented"
1141
1142 $(ORIGDIR):
1143
1144 $(DISTDIR):
1145
1146
1147 ################################################################################
1148 ### rules: clean targets #######################################################
1149 ################################################################################
1150
1151
1152 # delete build products from build tree
1153 clean:
1154 rm -f $(all.objects)
1155 rm -f $(classes.executables) $(lib.name).$(extension) $(shared.lib)
1156 rm -f *.pre *.lst
1157
1158 # remove distribution directories and tarballs from build tree
1159 distclean: clean
1160 @echo "target distclean not yet implemented"
1161
1162
1163 ################################################################################
1164 ### rules: submake targets #####################################################
1165 ################################################################################
1166
1167
1168 # Iterate over sub-makefiles or makefiles in other directories.
1169
1170 # When 'continue-make=yes' is set, sub-makes will report 'true' to the parent
1171 # process regardless of their real exit status. This prevents the parent make
1172 # from being aborted by a sub-make error. Useful when you want to quickly find
1173 # out which sub-makes from a large set will succeed.
1174 ifeq ($(continue-make),yes)
1175 continue = || true
1176 endif
1177
1178 # These targets will trigger sub-make processes for entries in 'makefiledirs'
1179 # and 'makefiles'.
1180 all alldebug install clean distclean dist dkpg-source: \
1181 $(makefiledirs) $(makefiles)
1182
1183 # this expands to identical rules for each entry in 'makefiledirs'
1184 $(makefiledirs):
1185 $(MAKE) --directory=$@ $(MAKECMDGOALS) $(continue)
1186
1187 # this expands to identical rules for each entry in 'makefiles'
1188 $(makefiles):
1189 $(MAKE) --directory=$(dir $@) --makefile=$(notdir $@) $(MAKECMDGOALS) $(continue)
1190
1191
1192 ################################################################################
1193 ### rules: convenience targets #################################################
1194 ################################################################################
1195
1196
1197 #=== show variables ============================================================
1198
1199
1200 # Several 'function' macro's cause errors when expanded within a rule or without
1201 # proper arguments. Variables which are set with the define directive are only
1202 # shown by name for that reason.
1203 functions = \
1204 add-class-source \
1205 declare-class-target \
1206 declare-class-executable-target \
1207 declare-object-target \
1208 link-class \
1209 link-lib \
1210 link-shared \
1211 make-object-file \
1212 make-preprocessor-file \
1213 make-assembly-file
1214
1215
1216 # show variables from makefiles
1217 vars:
1218 $(info ++++ info: showing makefile variables:)
1219 $(foreach v,\
1220 $(sort $(filter-out $(functions) functions, $(.VARIABLES))),\
1221 $(if $(filter file, $(origin $v)),\
1222 $(info variable $v = $($v))))
1223 $(foreach v, $(functions), $(info 'function' name: $v))
1224 @echo
1225
1226 # show all variables
1227 allvars:
1228 $(info ++++ info: showing default, automatic and makefile variables:)
1229 $(foreach v, \
1230 $(sort $(filter-out $(functions) functions, $(.VARIABLES))), \
1231 $(info variable ($(origin $v)) $v = $($v)))
1232 $(foreach v, $(functions), $(info 'function' name: $v))
1233 @echo
1234
1235
1236 #=== show dependencies =========================================================
1237
1238
1239 # show generated prerequisites rules
1240 depend:
1241 $(info ++++ info: generated prerequisite rules)
1242 $(foreach v, $(classes), $(info $(declare-class-target)))
1243 $(foreach v, $(classes), $(info $(declare-class-executable-target)))
1244 $(foreach v, $(all.sources), $(info $(call declare-object-target, $v)))
1245 @echo
1246
1247
1248 #=== show help text ============================================================
1249
1250
1251 # brief info about targets and paths
1252
1253 ifdef mpdh
1254 mpdhinfo := $(mpdh)
1255 else
1256 mpdhinfo := m_pd.h was not found. Is Pd installed?
1257 endif
1258
1259 help:
1260 @echo
1261 @echo " Main targets:"
1262 @echo " all: build executables (default target)"
1263 @echo " install: install all components of the library"
1264 @echo " vars: print makefile variables for troubleshooting"
1265 @echo " allvars: print all variables for troubleshooting"
1266 @echo " help: print this help text"
1267 @echo
1268 @echo " Pd API m_pd.h:"
1269 @echo " $(mpdhinfo)"
1270 @echo " You may specify your preferred Pd include directory as argument"
1271 @echo " to the make command, like 'PDINCLUDEDIR=path/to/pd/src'."
1272 @echo
1273 @echo " Path for installation of your libdir(s):"
1274 @echo " $(PDLIBDIR)"
1275 @echo " Alternatively you may specify your path for installation as argument"
1276 @echo " to the make command, like 'PDLIBDIR=path/to/pd-externals'."
1277 @echo
1278 @echo " Default paths are listed in the doc sections in Makefile.pdlibbuilder."
1279 @echo
1280
1281
1282 #=== dummy target ==============================================================
1283
1284
1285 coffee:
1286 @echo "Makefile.pdlibbuilder: Can not make coffee. Sorry."
1287
1288
1289 ################################################################################
1290 ### end of rules sections ######################################################
1291 ################################################################################
1292
1293
1294 # for syntax highlighting in vim and github
1295 # vim: set filetype=make:
1296
0
1
2 ### Makefile.pdlibbuilder ###
3
4 Helper makefile for Pure Data external libraries.
5 Written by Katja Vetter March-June 2015 for the public domain. No warranties.
6 Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's
7 ShakeNMake.
8
9 GNU make version >= 3.81 required.
10
11
12 ### characteristics ###
13
14
15 * defines build settings based on autodetected OS and architecture
16 * defines rules to build Pd class- or lib executables from C or C++ sources
17 * defines rules for libdir installation
18 * defines convenience targets for developer and user
19 * evaluates implicit dependencies for non-clean builds
20
21
22 ### basic usage ###
23
24
25 In your Makefile, define your Pd lib name and class files, and include
26 Makefile.pdlibbuilder at the end of the Makefile. Like so:
27
28
29 # Makefile for mylib
30
31 lib.name = mylib
32
33 class.sources = myclass1.c myclass2.c
34
35 datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt
36
37 include Makefile.pdlibbuilder
38
39
40 For files in class.sources it is assumed that class name == source file
41 basename. The default target builds all classes as individual executables
42 with Pd's default extension for the platform. For anything more than the
43 most basic usage, read the documentation sections in Makefile.pdlibbuilder.
44
45
46 ### paths ###
47
48
49 Makefile.pdlibbuilder >= v0.4.0 supports pd path variables which can be
50 defined not only as make command argument but also in the environment, to
51 override platform-dependent defaults:
52
53 PDDIR:
54 Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and
55 PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin.
56
57 PDINCLUDEDIR:
58 Directory where Pd API m_pd.h should be found, and other Pd header files.
59 Overrides the default search path.
60
61 PDBINDIR:
62 Directory where pd.dll should be found for linking (Windows only). Overrides
63 the default search path.
64
65 PDLIBDIR:
66 Root directory for installation of Pd library directories. Overrides the
67 default install location.
68
69
70 ### documentation ###
71
72
73 This README.md provides only basic information. A large comment section inside
74 Makefile.pdlibbuilder lists and explains the available user variables, default
75 paths, and targets. The internal documentation reflects the exact functionality
76 of the particular version. A tips&tricks page is in the works.
77
78
79 ### versioning ###
80
81
82 The project is versioned in MAJOR.MINOR.BUGFIX format (see http://semver.org),
83 and maintained at https://github.com/pure-data/pd-lib-builder. Pd lib developers
84 are invited to regulary check for updates, and to contribute and discuss
85 improvements here. If you really need to distribute a personalized version with
86 your library, rename Makefile.pdlibbuilder to avoid confusion.
87
88
89 ### examples ###
90
91
92 Here are a few projects using the Makefile.pdlibbuilder approach:
93
94 https://github.com/pure-data/helloworld
95
96 https://github.com/electrickery/pd-cyclone (stable)
97
98 https://github.com/porres/pd-cyclone (experimental)
99
100 https://git.iem.at/pd/iemguts
101
102 https://git.iem.at/pd/iemnet
103
104 https://git.iem.at/pd/iem_ambi
105
106 https://git.iem.at/pd/mediasettings
107
108 https://git.iem.at/pd-gui/punish
109
110 https://github.com/residuum/PuRestJson
111
112 More examples will be referenced here when they are available.
0 pd-lib-builder cheatsheet
1 =========================
2
3 # Creating special builds
4
5 ## cross-compiling W32 binaries from linux
6
7 I'm using the following to cross-compile W32 binaries on my Debian/64bit system,
8 using `mingw-w64`.
9
10 Assuming you have unzipped a W32 package for Pd into `${WINPDPATH}`, run:
11
12 make system=Windows pdbinpath="${WINPDPATH}/bin/" pdincludepath="${WINPDPATH}/src/" CC=i686-w64-mingw32-gcc
13
14 (if the project uses C++, you might also need to set `CXX=i686-w64-mingw32-g++`)
15
16 ## building double-precision externals
17
18 At the time of writing (2018-02) there is no official Pd that supports
19 double-precision numbers yet.
20 However, if you do get hold of an experimental double-precision Pd, you can
21 easily build your externals for 64-bit numbers:
22
23 make CPPFLAGS="-DPD_FLOATSIZE=64"
24
25 ## building externals for W64 (64-bit Windows)
26
27 At the time of writing (2018-02) there is no official Pd that supports
28 W64 yet.
29 However, if you do get hold of an experimental W64 Pd, you can
30 easily build your externals for this environment with
31
32 make CPPFLAGS="-DPD_LONGINTTYPE=__int64" CC=x86_64-w64-mingw32-gcc
33
34
35 To build a double-precision external for W64, use something like:
36
37 make CPPFLAGS="-DPD_LONGINTTYPE=__int64 -DPD_FLOATSIZE=64" CC=x86_64-w64-mingw32-gcc
38
39
40 ## TODO universal binaries on OSX
41
42
43 # Project management
44
45 In general it is advised to put the `Makefile.pdlibbuilder` into a separate
46 subdirectory (e.g. `pd-lib-builder/`).
47 This makes it much easier to update the `Makefile.pdlibbuilder` later
48
49 You *should* also use a variable to the actual path of the Makefile.pdlibbuilder
50 (even if you keep it in the root-directory), as this allows easy experimenting
51 with newer (or older) (or site-specific) versions of the pd-lib-builder
52 Makefile.
53
54 ~~~make
55 PDLIBBUILDER_DIR=pd-lib-builder/
56 include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder
57 ~~~
58
59 ## Keeping pd-lib-builder up-to-date
60
61 ### `git subtree`
62
63 With git-subtrees, you make the pd-lib-builder repository (or any other
64 repository for that matter) part of your own repository - with full history and
65 everything - put nicely into a distinct subdirectory.
66
67 Support for *manipulating* subtrees has been added with Git-v1.7.11 (May 2012).
68 The nice thing however is, that from "outside" the subtree is part of your
69 repository like any other directory. E.g. older versions of Git can clone your
70 repository with the full subtree (and all it's history) just fine.
71 You can also use git-archive to make a complete snapshot of your repository
72 (including the subtree) - nice, if you e.g. want self-contained downloads of
73 your project from git hosting platforms (like Github, Gitlab, Bitbucket,...)
74
75 In short, `git subtree` is the better `git submodule`.
76
77 So here's how to do it:
78
79 #### Initial setup/check-out
80 This will create a `pd-lib-builder/` directory containing the full history of
81 the pd-lib-builder repository up to its release `v0.5.0`
82
83 ~~~sh
84 git subtree add --prefix=pd-lib-builder/ https://github.com/pure-data/pd-lib-builder v0.5.0
85 ~~~
86
87 This will automatically merge the `pd-lib-builder/` history into your current
88 branch, so everything is ready to go.
89
90 #### Cloning your repository with the subtree
91 Nothing special, really.
92 Just clone your repository as always:
93
94 ~~~sh
95 git clone https://git.example.org/pd/superbonk~.git
96 ~~~
97
98 #### Updating the subtree
99 Time passes and sooner or later you will find, that there is a shiny new
100 pd-lib-builder with plenty of bugfixes and new features.
101 To update your local copy to pd-lib-builder's current `master`, simply run:
102
103 ~~~sh
104 git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master
105 ~~~
106
107 #### Pulling the updated subtree into existing clones
108 Again, nothing special.
109 Just pull as always:
110
111 ~~~sh
112 git pull
113 ~~~
114
115
116 #### Further reading
117 More on the power of `git subtree` can be found online
118 - https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844
119 - https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree
120 - ...
121
122 ### ~~`git submodule`~~ [DISCOURAGED]
123
124
125 #### Initial setup/check-out
126 To add a new submodule to your repository, just run `git submodule add` and
127 commit the changes:
128
129 ~~~sh
130 git submodule add https://github.com/pure-data/pd-lib-builder
131 git commit .gitmodules pd-lib-builder/ -m "Added pd-lib-builder as git-submodule"
132 ~~~
133
134 #### Cloning your repository with the submodule
135
136 When doing a fresh clone of your repository, pass the `--recursive` option to
137 automatically fetch all submodules:
138
139 ~~~sh
140 git clone --recursive https://git.example.org/pd/superbonk~.git
141 ~~~
142
143 If you've cloned non-recursively, you can initialize and update the submodules
144 manually:
145
146 ~~~sh
147 git submodule init
148 git submodule update
149 ~~~
150
151 #### Updating the submodule
152 Submodules are usually fixed to a given commit in their repository.
153 To update the `pd-lib-builder` submodule to the current `master` do something
154 like:
155
156 ~~~sh
157 cd pd-lib-builder
158 git checkout master
159 git pull
160 cd ..
161 git status pd-lib-builder
162 git commit pd-lib-builder -m "Updated pd-lib-builder to current master"
163 ~~~
164
165 #### Pulling the updated submodule into existing clones
166 After you have pushed the submodule updates in your repository, other clones of
167 the repository can be updated as follows:
168
169 ~~~sh
170 git pull
171 ~~~
172
173 The above will make your repository aware, that the submodule is out-of-sync.
174
175 ~~~sh
176 $ LANG=C git status pd-lib-builder
177 On branch master
178 Your branch is up to date with 'origin/master'.
179
180 Changes not staged for commit:
181 (use "git add <file>..." to update what will be committed)
182 (use "git checkout -- <file>..." to discard changes in working directory)
183
184 modified: pd-lib-builder (new commits)
185 $
186 ~~~
187
188 In order to sync the submodule to the correct commit, run the following:
189
190 ~~~sh
191 git submodule update
192 ~~~
193
194 #### Drawbacks
195 `git submodule` has a number of drawbacks:
196 - it requires special commands to synchronize the submodules, in addition to
197 synching your repository.
198 - you must make sure to use an URL for the submodule that is accessible to your
199 potential users. e.g. using `git@github.com:pure-data/pd-lib-builder` is bad,
200 because it requires everybody who wants to checkout your sources to have a
201 github-account - even if they could checkout *your* repository anonymously.
202 - submodules will be excluded from `git archive`. This means, that if you use a
203 mainstream git provider (like Github, GitLab, Bitbucket,...) and make releases
204 by creating a `git tag`, the automatically generated zipfiles with the sources
205 will lack the submodule - and your users will not be able to compile your
206 source code.
207
208 In general, I would suggest to **avoid** `git submodule`, and instead use the
209 better `git subtree` (above).
210
4545 int x_serialize;
4646
4747 int x_fd; // the socket
48 char *x_hostname; // address we want to connect to as text
48 const char *x_hostname; // address we want to connect to as text
4949 int x_connectstate; // 0 = not connected, 1 = connected
5050 int x_port; // port we're connected to
5151 long x_addr; // address we're connected to as 32bit int
4242 t_iemnet_receiver*x_receiver;
4343
4444 int x_fd; // the socket
45 char *x_hostname; // address we want to connect to as text
45 const char *x_hostname; // address we want to connect to as text
4646 int x_connectstate; // 0 = not connected, 1 = connected
4747 u_short x_port; // port we're sending to
4848 u_short x_sendport; // port we're sending from