├── CHANGELOG.txt ├── Makefile.pdlibbuilder ├── README.md ├── tests ├── Makefile ├── _template_ │ ├── Makefile │ ├── _template_-help.pd │ ├── _template_-meta.pd │ └── _template_.c ├── make-from-template.sh ├── multifor │ ├── Makefile │ ├── README.md │ ├── multifor-help.pd │ ├── multifor-meta.pd │ ├── multiforA.c │ └── multiforB.c ├── multilib │ ├── Makefile │ ├── README.md │ ├── multilib-help.pd │ ├── multilib-meta.pd │ ├── multilib.c │ ├── multilibA.c │ └── multilibB.c ├── multiple │ ├── Makefile │ ├── README.md │ ├── multiple-help.pd │ ├── multiple-meta.pd │ ├── multipleA.c │ └── multipleB.c ├── multiplexx │ ├── Makefile │ ├── README.md │ ├── multiplexx-help.pd │ ├── multiplexx-meta.pd │ ├── multiplexxA.cpp │ └── multiplexxB.c ├── multishared │ ├── Makefile │ ├── README.md │ ├── multishared-help.pd │ ├── multishared-meta.pd │ ├── multishared.h │ ├── multisharedA.c │ ├── multisharedB.c │ └── shared.c ├── single │ ├── Makefile │ ├── README.md │ ├── single-help.pd │ ├── single-meta.pd │ └── single.c ├── subdir │ ├── Makefile │ ├── README.md │ ├── src │ │ ├── subdir.c │ │ └── subdir~.c │ ├── subdir-help.pd │ ├── subdir-meta.pd │ └── subdir~-help.pd └── test-patches.sh └── tips-tricks.md /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | Changelog for Makefile.pdlibbuilder. 2 | 3 | v0.7.0, dated 2023-07-06 4 | - build double-precision externals with the 'floatsize' variable 5 | - allow building multiple flavours of an external side-by-side (#78) 6 | - facilitate multiple platform co-installation of shared lib (#58) 7 | - fix use of shared.ldflags with helper-library (#64) 8 | - fix broken armv6l platform detection (#71) 9 | - improve documentation 10 | 11 | v0.6.0, dated 2019-12-21 12 | - detect target platform (OS and architecture) rather than build platform (#55) 13 | - introduce optional user variable 'PLATFORM' for cross compilation 14 | - no longer build OSX/MacOS fat binaries by default (#21, #50) 15 | - do build fat binaries when 'extension=d_fat' is specified for OSX/MacOS 16 | - fix bug where minimum OSX/MacOS version wasn't defined, and set it to 10.6 17 | 18 | v0.5.1, dated 2018-03-15 19 | Fixes and improvements for Windows builds: 20 | - properly evaluate variables 'PDDIR' and 'PDBINDIR' to find pd.dll 21 | - define default path of 32 bit Pd on 64 bit Windows 22 | - link C++ externals with standard C libs on Windows, they don't load otherwise 23 | - strip installed Windows binaries by default 24 | (issues #34, #39, #41, #42 respectively) 25 | Warning for all platforms: variable 'PD_PATH' is no longer supported, use the 26 | equivalent 'PDDIR'. 27 | 28 | v0.5.0, dated 2018-01-23 29 | Implement target architecture detection for Windows builds, 30 | and set appropriate options for 32 and 64 bit (used to be for 32 bit only). 31 | (feature, issue #37 #38, merge commit 215bf3e) 32 | 33 | v0.4.4, dated 2016-11-22 34 | Use variable 'system' when evaluating 'for{Linux,Darwin,Windows}' 35 | (bugfix, issue #31, commit 2c14110) 36 | 37 | v0.4.3, dated 2016-11-02 38 | Replace flags '-fpic' by 'fPIC'. 39 | (bugfix, issue #29, commit 426b38b) 40 | 41 | v0.4.2, dated 2016-10-30 42 | Fix issue where incorrect message about m_pd.h is given. 43 | (bugfix, commit 2e13d8f) 44 | 45 | v0.4.1, dated 2016-10-27 46 | Respect cflag for minimum OSX version when defined by lib makefile. 47 | (bugfix, pull request #22, commit 48c4127) 48 | 49 | v0.4.0, dated 2016-10-14 50 | Introduced path variables PDDIR, PDINCLUDEDIR, PDBINDIR, PDLIBDIR which can 51 | also be defined in environment. 52 | (feature, issue #27, commit b0dab72) 53 | 54 | v0.3.1, dated 2016-10-13 55 | Fix bug where pd.dll wouldn't be found. 56 | (bugfix, commit a0c87be) 57 | 58 | v0.3.0, dated 2016-10-09 59 | Variable 'PD_PATH' introduced for pd-extended / pd-l2ork compatibility. 60 | (feature, issue #26, commit 41e9743) 61 | 62 | v0.2.8, dated 2016-10-09 63 | Allow installed files to contain weird characters (notably '$'). 64 | (bugfix, pull request #20, commit 5b920b1) 65 | 66 | v0.2.7, dated 2016-10-04 67 | Remove all default pd search paths except vanilla's. 68 | (discussion, issue #25, commit a6a89dc) 69 | 70 | v0.2.6, dated 2016-09-20 71 | Redefined dependency checking so it won't stall rebuilds on OSX. 72 | (bugfix, issue #16, commit 9fd1795) 73 | 74 | v0.2.5, dated 2016-06-26 75 | Fixed dependency checking for object files in other directories. 76 | (bugfix, commit f06e550) 77 | 78 | v0.2.4, dated 2016-06-25 79 | Fixed regression bug that disabled all dependency checking. 80 | (bugfix, commit 1d7bb5e) 81 | 82 | v0.2.3, dated 2016-03-29 83 | Disabled dependency checking for OSX <= 10.5 because it stalled rebuilds. 84 | (bugfix, issue #16, commit eb614fd) 85 | 86 | v0.2.2, dated 2016-03-28 87 | Removed target 'pre' because it forced rebuild of everything in 'all'. 88 | (bugfix, issue #17, commit c989c8e) 89 | 90 | v0.2.1, dated 2015-12-27 91 | Implement / respect 'CPPFLAGS','CFLAGS'and 'LDFLAGS'. 92 | (bugfix, issue #5, commit 98f3582) 93 | 94 | v0.2.0, dated 2015-12-19 95 | Added per-platform multiline defines 'forLinux', 'forDarwin', 'forWindows'. 96 | (feature, pull request #9, commit 3946ea5) 97 | 98 | v0.1.0, dated 2015-12-08 99 | Added targets 'pre' and 'post' to automatically run before and after 'all'. 100 | (feature, pull request #4, commit a5678ac) 101 | 102 | v0.0.2, dated 2015-12-06 103 | Improved methods for searching pd paths. 104 | (bugfix, commit ed37e6b) 105 | 106 | v0.0.1, dated 2015-10-31 107 | Fixed expansion of variable 'lib.version'. 108 | (bugfix, issue #1, commit 974b617) 109 | 110 | v0.0.0, dated 2015-06-24 111 | Initial version. 112 | (commit 16517a2) 113 | -------------------------------------------------------------------------------- /Makefile.pdlibbuilder: -------------------------------------------------------------------------------- 1 | # Makefile.pdlibbuilder dated 2019-12-21 2 | version = 0.7.0 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 | # Grab the newest version of Makefile.pdlibbuilder from 10 | # https://github.com/pure-data/pd-lib-builder/ 11 | # 12 | # GNU make version >= 3.81 required. 13 | # 14 | # 15 | #=== characteristics =========================================================== 16 | # 17 | # 18 | # - defines build settings based on autodetected OS and architecture 19 | # - defines rules to build Pd class- or lib executables from C or C++ sources 20 | # - defines rules for libdir installation 21 | # - defines convenience targets for developer and user 22 | # - evaluates implicit dependencies for non-clean builds 23 | # 24 | # 25 | #=== basic usage =============================================================== 26 | # 27 | # 28 | # In your Makefile, define your Pd lib name and class files, and include 29 | # Makefile.pdlibbuilder at the end of the Makefile. Like so: 30 | # 31 | # ________________________________________________________________________ 32 | # 33 | # # Makefile for mylib 34 | # 35 | # lib.name = mylib 36 | # 37 | # class.sources = myclass1.c myclass2.c 38 | # 39 | # datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt 40 | # 41 | # include Makefile.pdlibbuilder 42 | # ________________________________________________________________________ 43 | # 44 | # 45 | # For files in class.sources it is assumed that class basename == source file 46 | # basename. The default target builds all classes as individual executables 47 | # with Pd's default extension for the platform. For anything more than the 48 | # most basic usage, continue reading. 49 | # 50 | # 51 | #=== list of Makefile.pdlibbuilder API variables =============================== 52 | # 53 | # 54 | # Variables available for definition in your library Makefile: 55 | # 56 | # - lib.name 57 | # - lib.setup.sources 58 | # - class.sources 59 | # - common.sources 60 | # - shared.sources 61 | # - .class.sources 62 | # - .class.ldflags 63 | # - .class.ldlibs 64 | # - cflags 65 | # - ldflags 66 | # - ldlibs 67 | # - datafiles 68 | # - datadirs 69 | # - makefiles 70 | # - makefiledirs 71 | # - externalsdir 72 | # 73 | # Optional multiline defines evaluated per operating system: 74 | # 75 | # - forLinux 76 | # - forDarwin 77 | # - forWindows 78 | # 79 | # Variables available for your makefile or make command line: 80 | # 81 | # - make-lib-executable 82 | # - suppress-wunused 83 | # 84 | # Path variables for make command line or environment: 85 | # 86 | # - PDDIR 87 | # - PDINCLUDEDIR 88 | # - PDBINDIR 89 | # - PDLIBDIR 90 | # 91 | # Standard make variables for make command line or environment: 92 | # 93 | # - CPPFLAGS 94 | # - CFLAGS 95 | # - LDFLAGS 96 | # - CC 97 | # - CXX 98 | # - INSTALL 99 | # - STRIP 100 | # - DESTDIR 101 | # 102 | # Optional user variables for make command line or environment: 103 | # 104 | # - PLATFORM 105 | # - extension 106 | # - floatsize 107 | # 108 | # Deprecated path variables: 109 | # 110 | # - pdincludepath 111 | # - pdbinpath 112 | # - objectsdir 113 | # 114 | # 115 | #=== descriptions of Makefile.pdlibbuilder API variables ======================= 116 | # 117 | # 118 | # lib.name: 119 | # Name of the library directory as it will be installed / distributed. Also the 120 | # name of the lib executable in the case where all classes are linked into 121 | # a single binary. 122 | # 123 | # lib.setup.sources: 124 | # Source file(s) (C or C++) which must be compiled only when linking all classes 125 | # into a single lib binary. 126 | # 127 | # class.sources: 128 | # All sources files (C or C++) for which the condition holds that 129 | # class name == source file basename. 130 | # 131 | # .class.sources: 132 | # Source file(s) (C or C++) specific to class . Use this for 133 | # multiple-source classes or when class name != source file basename. 134 | # 135 | # common.sources: 136 | # Source file(s) which must be statically linked to each class in the library. 137 | # 138 | # shared.sources: 139 | # Source file(s) (C or C++) to build a shared dynamic link lib, to be linked 140 | # with all class executables. 141 | # 142 | # cflags, ldflags, ldlibs: 143 | # Define cflags (preprocessor&compiler), ldflags (linker) and ldlibs (dynamic 144 | # link libs) for the whole library. These flags are added to platform-specific 145 | # flags defined by Makefile.pdlibbuilder. 146 | # 147 | # .class.ldflags and .class.ldlibs: 148 | # Define ldflags resp. ldlibs specific to class . These flags are 149 | # added to platform-specific flags defined by Makefile.pdlibbuilder, and flags 150 | # defined in your Makefile for the whole library. Note: cflags can not be 151 | # defined per class in the current implementation. 152 | # 153 | # datafiles and datadirs: 154 | # All extra files you want to include in binary distributions of the 155 | # library: abstractions and help patches, example patches, meta patch, readme 156 | # and license texts, manuals, sound files, etcetera. Use 'datafiles' for all 157 | # files that should go into your lib rootdir and 'datadirs' for complete 158 | # directories you want to copy from source to distribution. 159 | # 160 | # forLinux, forDarwin, forWindows: 161 | # Shorthand for 'variable definitions for Linux only' etc. Use like: 162 | # define forLinux 163 | # cflags += -DLINUX 164 | # class.sources += linuxthing.c 165 | # endef 166 | # 167 | # makefiles and makefiledirs: 168 | # Extra makefiles or directories with makefiles that should be made in sub-make 169 | # processes. 170 | # 171 | # make-lib-executable: 172 | # When this variable is defined 'yes' in your makefile or as command argument, 173 | # Makefile.pdlibbuilder will try to build all classes into a single library 174 | # executable (but it will force exit if lib.setup.sources is undefined). 175 | # If your makefile defines 'make-lib-executable=yes' as the library default, 176 | # this can still be overridden with 'make-lib-executable=no' as command argument 177 | # to build individual class executables (the Makefile.pdlibbuilder default.) 178 | # 179 | # suppress-wunused: 180 | # When this variable is defined ('yes' or any other value), -Wunused-variable, 181 | # -Wunused-parameter, -Wunused-value and -Wunused-function are suppressed, 182 | # but the other warnings from -Wall are retained. 183 | # 184 | # PDDIR: 185 | # Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and 186 | # PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. 187 | # 188 | # PDINCLUDEDIR: 189 | # Directory where Pd API m_pd.h should be found, and other Pd header files. 190 | # Overrides the default search path. 191 | # 192 | # PDBINDIR: 193 | # Directory where pd.dll should be found for linking (Windows only). Overrides 194 | # the default search path. 195 | # 196 | # PDLIBDIR: 197 | # Root directory for installation of Pd library directories. Overrides the 198 | # default install location. 199 | # 200 | # DESTDIR: 201 | # Prepended path component for staged install. 202 | # 203 | # PLATFORM: 204 | # Target platform for cross compilation in the form of GNU triplet: 205 | # cpu-vendor-os. Example: x86_64-w64-mingw32. This specifies the tool chain that 206 | # pdlibbuilder will use, if installed and locatable. System and architecture 207 | # will then be autodefined accordingly. In most cases no other variables need to 208 | # be overridden. 209 | # 210 | # extension: 211 | # Extension for the external to use. Example: m_amd64 212 | # A sane default is picked, but it is useful if you want to provide 213 | # co-installable externals for multiple platforms (for the same operating 214 | # systems) 215 | # 216 | # floatsize: 217 | # the size of the t_float in bits. Example: 32 218 | # t_float are usually single precision (32bit), which is the default. 219 | # For double precision use floatsize=64 220 | # When building double precision externals, you will want to set the extension 221 | # as well, e.g. extension=windows-amd64-64.dll (--.) 222 | # 223 | # CPPFLAGS: 224 | # Preprocessor flags which are not strictly required for building. 225 | # 226 | # CFLAGS: 227 | # Compiler flags which are not strictly required for building. Compiler flags 228 | # defined by Makefile.pdlibbuilder for warning, optimization and architecture 229 | # specification are overriden by CFLAGS. 230 | # 231 | # LDFLAGS: 232 | # Linker flags which are not strictly required for building. Linker flags 233 | # defined by Makefile.pdlibbuilder for architecture specification are overriden 234 | # by LDFLAGS. 235 | # 236 | # CC and CXX: 237 | # C and C++ compiler programs as defined in your build environment. 238 | # 239 | # INSTALL 240 | # Definition of install program. 241 | # 242 | # STRIP 243 | # Name of strip program. Default 'strip' can be overridden in cross compilation 244 | # environments. 245 | # 246 | # objectsdir: 247 | # Root directory for installation of Pd library directories, like PDLIBDIR but 248 | # not overridable by environment. Supported for compatibility with pd-extended 249 | # central makefile, but deprecated otherwise. 250 | # 251 | # pdincludepath, pdbinpath: 252 | # As PDINCLUDEDIR and PDBINDIR but not overridable by environment. Deprecated 253 | # as user variables. 254 | # 255 | # 256 | #=== paths ===================================================================== 257 | # 258 | # 259 | # Source files in directories other than current working directory must be 260 | # prefixed with their relative path. Do not rely on VPATH or vpath. 261 | # Object (.o) files are built in the directory of their source files. 262 | # Executables are built in current working directory. 263 | # 264 | # Default search path for m_pd.h and other API header files is platform 265 | # dependent, and overridable by PDINCLUDEDIR: 266 | # 267 | # Linux: /usr/include/pd 268 | # 269 | # OSX: /Applications/Pd*.app/Contents/Resources/src 270 | # 271 | # Windows: %PROGRAMFILES%/Pd/src 272 | # %PROGRAMFILES(X86)%/Pd/src (32 bit builds on 64 bit Windows) 273 | # 274 | # Default search path for binary pd.dll (Windows), overridable by PDBINDIR 275 | # 276 | # %PROGRAMFILES%/Pd/bin 277 | # %PROGRAMFILES(X86)%/Pd/bin (32 bit builds on 64 bit Windows) 278 | # 279 | # Default location to install pd libraries is platform dependent, and 280 | # overridable by PDLIBDIR: 281 | # 282 | # Linux: /usr/local/lib/pd-externals 283 | # OSX: ~/Library/Pd 284 | # Windows: %APPDATA%/Pd 285 | # 286 | # https://puredata.info/docs/faq/how-do-i-install-externals-and-help-files 287 | # The rationale for not installing to ~/pd-externals by default on Linux 288 | # is that some people share the home dir between 32 and 64 bit installations. 289 | # 290 | # 291 | #=== targets =================================================================== 292 | # 293 | # 294 | # all: build $(executables) plus optional post target 295 | # post: target to build after $(executables) 296 | # alldebug: build all with -g option turned on for debug symbols 297 | # : force clean build of an individual class 298 | # .pre: make preprocessor output file in current working directory 299 | # .lst: make asm/source output file in current working directory 300 | # 301 | # install: install executables and data files 302 | # clean: remove build products from source tree 303 | # 304 | # help: print help text 305 | # vars: print makefile variables 306 | # allvars: print all variables 307 | # depend: print generated prerequisites 308 | # dumpmachine: print compiler output of option '-dumpmachine' 309 | # coffee: dummy target 310 | # 311 | # Variable $(executables) expands to class executables plus optional shared lib, 312 | # or alternatively to single lib executable when make-lib-executable=true. 313 | # Targets pre and post can be defined by library makefile. Make sure to include 314 | # Makefile.pdlibbuilder first so default target all will not be redefined. 315 | # 316 | # 317 | #=== Pd-extended libdir concept ================================================ 318 | # 319 | # 320 | # For libdir layout as conceived by Hans-Christoph Steiner, see: 321 | # 322 | # https://puredata.info/docs/developer/Libdir 323 | # 324 | # Files README.txt, LICENSE.txt and -meta.pd are part of the libdir 325 | # convention. Help patches for each class and abstraction are supposed to be 326 | # available. Makefile.pdlibbuilder does not force the presence of these files 327 | # however. It does not automatically include such files in libdir installations. 328 | # Data files you want to include in distributions must be defined explicitly in 329 | # your Makefile. 330 | # 331 | # 332 | #=== Makefile.pdlibbuilder syntax conventions ================================== 333 | # 334 | # 335 | # Makefile.pdlibbuilder variable names are lower case. Default make variables, 336 | # environment variables, and standard user variables (CC, CXX, CFLAGS, DESTDIR) 337 | # are upper case. Use target 'allvars' to print all variables and their values. 338 | # 339 | # 'Fields' in data variables are separated by dots, like in 'foo.class.sources'. 340 | # Words in variables expressing a function or command are separated by dashes, 341 | # like in 'make-lib-executable'. 342 | # 343 | # 344 | #=== useful make options ======================================================= 345 | # 346 | # 347 | # Use 'make -d ' to print debug details of the make process. 348 | # Use 'make -p ' to print make's database. 349 | # 350 | # 351 | #=== TODO ====================================================================== 352 | # 353 | # 354 | # - decide whether to use -static-libgcc or shared dll in MinGW 355 | # - cygwin support 356 | # - android support 357 | # - figure out how to handle '$' in filenames 358 | # - add makefile template targets dpkg-source dist libdir distclean tags? 359 | # 360 | # 361 | #=== end of documentation sections ============================================= 362 | # 363 | # 364 | ################################################################################ 365 | ################################################################################ 366 | ################################################################################ 367 | 368 | 369 | # GNU make version 3.81 (2006) or higher is required because of the following: 370 | # - function 'info' 371 | # - variable '.DEFAULT_GOAL' 372 | 373 | # force exit when make version is < 3.81 374 | ifneq ($(firstword $(sort 3.81 $(MAKE_VERSION))), 3.81) 375 | $(error GNU make version 3.81 or higher is required) 376 | endif 377 | 378 | # Relative path to externals root dir in multi-lib source tree like 379 | # pd-extended SVN. Default is parent of current working directory. May be 380 | # defined differently in including makefile. 381 | externalsdir ?= .. 382 | 383 | # variable you can use to check if Makefile.pdlibbuilder is already included 384 | Makefile.pdlibbuilder = true 385 | 386 | 387 | ################################################################################ 388 | ### target platform detection ################################################## 389 | ################################################################################ 390 | 391 | 392 | #=== target platform =========================================================== 393 | 394 | 395 | # PLATFORM: optional user variable to define target platform for cross 396 | # compilation. Redefine build tools accordingly. PLATFORM should match 397 | # the exact target prefix of tools present in $PATH, like x86_64-w64-mingw32, 398 | # x86_64-apple-darwin12 etc. Tool definitions are exported to ensure submakes 399 | # will get the same. 400 | 401 | ifneq ($(PLATFORM),) 402 | ifneq ($(findstring darwin, $(PLATFORM)),) 403 | export CC = $(PLATFORM)-cc 404 | export CXX = $(PLATFORM)-c++ 405 | export CPP = $(PLATFORM)-cc 406 | else 407 | export CC = $(PLATFORM)-gcc 408 | export CXX = $(PLATFORM)-g++ 409 | export CPP = $(PLATFORM)-cpp 410 | endif 411 | STRIP = $(PLATFORM)-strip 412 | endif 413 | 414 | # Let (native or cross-) compiler report target triplet and isolate individual 415 | # words therein to facilitate later processing. 416 | target.triplet := $(subst -, ,$(shell $(CC) -dumpmachine)) 417 | 418 | 419 | #=== operating system ========================================================== 420 | 421 | 422 | # The following systems are defined: Linux, Darwin, Windows. GNU and 423 | # GNU/kFreeBSD are treated as Linux to get the same options. 424 | 425 | ifneq ($(filter linux gnu% kfreebsd, $(target.triplet)),) 426 | system = Linux 427 | endif 428 | 429 | ifneq ($(filter darwin%, $(target.triplet)),) 430 | system = Darwin 431 | endif 432 | 433 | ifneq ($(filter mingw% cygwin%, $(target.triplet)),) 434 | system = Windows 435 | endif 436 | 437 | # evaluate possible system-specific multiline defines from library makefile 438 | $(eval $(for$(system))) 439 | 440 | 441 | # TODO: Cygwin, Android 442 | 443 | 444 | #=== architecture ============================================================== 445 | 446 | 447 | # The following CPU names can be processed by pdlibbuilder: 448 | # i*86 Intel 32 bit 449 | # x86_64 Intel 64 bit 450 | # arm ARM 32 bit 451 | # aarch64 ARM 64 bit 452 | 453 | target.arch := $(firstword $(target.triplet)) 454 | 455 | 456 | ################################################################################ 457 | ### variables per platform ##################################################### 458 | ################################################################################ 459 | 460 | #=== flags per floatsize == ==================================================== 461 | floatsize = 32 462 | ifneq ($(filter-out 32,$(floatsize)),) 463 | floatsize.flags = -DPD_FLOATSIZE=$(floatsize) 464 | else 465 | floatsize.flags = 466 | endif 467 | 468 | 469 | #=== flags per architecture ==================================================== 470 | 471 | 472 | # Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, 473 | # arch.c.flags are overriden below. To see gcc's default architecture flags: 474 | # $ gcc -Q --help=target 475 | 476 | # ARMv6: Raspberry Pi 1st gen, not detectable from target.arch 477 | ifeq ($(shell uname -m), armv6l) 478 | arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard 479 | 480 | # ARMv7: Beagle, Udoo, RPi2 etc. 481 | else ifeq ($(target.arch), arm) 482 | arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard 483 | 484 | # ARMv8 64 bit, not tested yet 485 | else ifeq ($(target.arch), aarch64) 486 | arch.c.flags = -mcpu=cortex-a53 487 | 488 | # Intel 32 bit, build with SSE and SSE2 instructions 489 | else ifneq ($(filter i%86, $(target.arch)),) 490 | arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 491 | 492 | # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions 493 | else ifeq ($(target.arch), x86_64) 494 | arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 495 | 496 | # if none of the above architectures detected 497 | else 498 | arch.c.flags = 499 | endif 500 | 501 | 502 | #=== flags and paths for Linux ================================================= 503 | 504 | 505 | ifeq ($(system), Linux) 506 | prefix = /usr/local 507 | libdir := $(prefix)/lib 508 | pkglibdir = $(libdir)/pd-externals 509 | pdincludepath := $(wildcard /usr/include/pd) 510 | extension = pd_linux 511 | cpp.flags := -DUNIX 512 | c.flags := -fPIC 513 | c.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags 514 | c.ldlibs := -lc -lm 515 | cxx.flags := -fPIC -fcheck-new 516 | cxx.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags 517 | cxx.ldlibs := -lc -lm -lstdc++ 518 | shared.extension = so 519 | shared.ldflags = -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib) 520 | endif 521 | 522 | 523 | #=== flags and paths for Darwin ================================================ 524 | 525 | 526 | # LLVM-clang doesn't support -fcheck-new, therefore this flag is only used when 527 | # compiling with g++. 528 | 529 | ifeq ($(system), Darwin) 530 | pkglibdir = $(HOME)/Library/Pd 531 | pdincludepath := $(firstword $(wildcard \ 532 | /Applications/Pd*.app/Contents/Resources/src)) 533 | extension = pd_darwin 534 | cpp.flags := -DUNIX -DMACOSX -I /sw/include 535 | c.flags := 536 | c.ldflags := -undefined suppress -flat_namespace -bundle 537 | c.ldlibs := -lc 538 | cxx.ldflags := -undefined suppress -flat_namespace -bundle 539 | cxx.ldlibs := -lc 540 | shared.extension = dylib 541 | shared.ldflags = -dynamiclib -undefined dynamic_lookup \ 542 | -install_name @loader_path/$(shared.lib) \ 543 | -compatibility_version 1 -current_version 1.0 544 | ifneq ($(filter %g++, $(CXX)),) 545 | cxx.flags := -fcheck-new 546 | endif 547 | ifeq ($(extension), d_fat) 548 | arch := i386 x86_64 549 | else 550 | arch := $(target.arch) 551 | endif 552 | ifneq ($(filter -mmacosx-version-min=%, $(cflags)),) 553 | version.flag := $(filter -mmacosx-version-min=%, $(cflags)) 554 | else 555 | version.flag = -mmacosx-version-min=10.6 556 | endif 557 | arch.c.flags := $(addprefix -arch , $(arch)) $(version.flag) 558 | arch.ld.flags := $(arch.c.flags) 559 | endif 560 | 561 | 562 | #=== flags and paths for Windows =============================================== 563 | 564 | 565 | # Standard paths on Windows contain spaces, and GNU make functions treat such 566 | # paths as lists, with unintended effects. Therefore we must use shell function 567 | # ls instead of make's wildcard when probing for a path, and use double quotes 568 | # when specifying a path in a command argument. 569 | 570 | # Default paths in Mingw / Mingw-w64 environments. 'PROGRAMFILES' is standard 571 | # location for builds with native architecture, 'ProgramFiles(x86)' for i686 572 | # builds on x86_64 Windows (detection method by Lucas Cordiviola). Curly braces 573 | # required because of parentheses in variable name. 574 | ifeq ($(system), Windows) 575 | pkglibdir := $(APPDATA)/Pd 576 | ifeq ($(target.arch), i686) 577 | programfiles := ${ProgramFiles(x86)} 578 | else 579 | programfiles := $(PROGRAMFILES) 580 | endif 581 | pdbinpath := $(programfiles)/Pd/bin 582 | pdincludepath := $(programfiles)/Pd/src 583 | endif 584 | 585 | # Store default path to pd.dll in PDBINDIR if the latter is not user-defined. 586 | # For include path this is done in the platform-independent paths section below, 587 | # but for PDBINDIR it is done here so ld flags can be evaluated as immediate 588 | # variables. 589 | ifeq ($(system), Windows) 590 | ifdef PDDIR 591 | PDBINDIR := $(PDDIR)/bin 592 | endif 593 | PDBINDIR ?= $(pdbinpath) 594 | endif 595 | 596 | # TODO: decide whether -mms-bitfields should be specified. 597 | ifeq ($(system), Windows) 598 | cpp.flags := -DMSW -DNT 599 | ifeq ($(target.arch), i686) 600 | arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse 601 | else ifeq ($(target.arch), x86_64) 602 | cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 603 | arch.c.flags := -march=core2 -msse -msse2 -msse3 -mfpmath=sse 604 | else 605 | arch.c.flags = 606 | endif 607 | extension = dll 608 | c.flags := 609 | c.ldflags := -static-libgcc -shared \ 610 | -Wl,--enable-auto-import "$(PDBINDIR)/pd$(filter-out 32,$(floatsize)).dll" 611 | c.ldlibs := 612 | cxx.flags := -fcheck-new 613 | cxx.ldflags := -static-libgcc -static-libstdc++ -shared \ 614 | -Wl,--enable-auto-import "$(PDBINDIR)/pd$(filter-out 32,$(floatsize)).dll" 615 | cxx.ldlibs := 616 | shared.extension = dll 617 | shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd$(filter-out 32,$(floatsize)).dll" 618 | stripflags = --strip-all 619 | endif 620 | 621 | 622 | #=== paths ===================================================================== 623 | 624 | 625 | # Platform-dependent default paths are specified above, but overridable. 626 | # Path variables in upper case can be defined as make command argument or in the 627 | # environment. Variable 'objectsdir' is supported for compatibility with 628 | # the build system that pd-l2ork has inherited from pd-extended. 629 | 630 | PDINCLUDEDIR ?= $(pdincludepath) 631 | PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir)) 632 | 633 | ifdef PDDIR 634 | PDINCLUDEDIR := $(wildcard $(PDDIR)/src) 635 | endif 636 | 637 | # base path where all components of the lib will be installed by default 638 | installpath := $(DESTDIR)$(PDLIBDIR)/$(lib.name) 639 | 640 | # check if include path contains spaces (as is often the case on Windows) 641 | # if so, store the path so we can later do checks with it 642 | pdincludepathwithspaces := $(if $(word 2, $(PDINCLUDEDIR)), $(PDINCLUDEDIR)) 643 | 644 | 645 | #=== accumulated build flags =================================================== 646 | 647 | 648 | # From GNU make docs: 'Users expect to be able to specify CFLAGS freely 649 | # themselves.' So we use CFLAGS to define options which are not strictly 650 | # required for compilation: optimizations, architecture specifications, and 651 | # warnings. CFLAGS can be safely overriden using a make command argument. 652 | # Variables cflags, ldflags and ldlibs may be defined in including makefile. 653 | 654 | optimization.flags = -O3 -ffast-math -funroll-loops -fomit-frame-pointer 655 | warn.flags = -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing 656 | 657 | # suppress -Wunused-variable & Co if you don't want to clutter a build log 658 | ifdef suppress-wunused 659 | warn.flags += $(addprefix -Wno-unused-, function parameter value variable) 660 | endif 661 | 662 | CFLAGS = $(warn.flags) $(optimization.flags) $(arch.c.flags) 663 | 664 | # preprocessor flags 665 | cpp.flags := -DPD -I "$(PDINCLUDEDIR)" $(floatsize.flags) $(cpp.flags) $(CPPFLAGS) 666 | 667 | # flags for dependency checking (cflags from makefile may define -I options) 668 | depcheck.flags := $(cpp.flags) $(cflags) 669 | 670 | # architecture specifications for linker are overridable by LDFLAGS 671 | LDFLAGS := $(arch.ld.flags) 672 | 673 | # now add the same ld flags to shared dynamic lib 674 | shared.ldflags += $(LDFLAGS) 675 | 676 | # accumulated flags for C compiler / linker 677 | c.flags := $(cpp.flags) $(c.flags) $(cflags) $(CFLAGS) 678 | c.ldflags := $(c.ldflags) $(ldflags) $(LDFLAGS) 679 | c.ldlibs := $(c.ldlibs) $(ldlibs) 680 | 681 | # accumulated flags for C++ compiler / linker 682 | cxx.flags := $(cpp.flags) $(cxx.flags) $(cflags) $(CFLAGS) 683 | cxx.ldflags := $(cxx.ldflags) $(ldflags) $(LDFLAGS) 684 | cxx.ldlibs := $(cxx.ldlibs) $(ldlibs) 685 | 686 | 687 | ################################################################################ 688 | ### variables: library name and version ######################################## 689 | ################################################################################ 690 | 691 | 692 | # strip possibles spaces from lib.name, they mess up calculated file names 693 | lib.name := $(strip $(lib.name)) 694 | 695 | # if meta file exists, check library version 696 | metafile := $(wildcard $(lib.name)-meta.pd) 697 | 698 | ifdef metafile 699 | lib.version := $(shell sed -n \ 700 | 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \ 701 | $(metafile)) 702 | endif 703 | 704 | 705 | ################################################################################ 706 | ### variables: files ########################################################### 707 | ################################################################################ 708 | 709 | object.extension = $(extension).o 710 | 711 | #=== sources =================================================================== 712 | 713 | 714 | # (re)define .class.sources using file names in class.sources 715 | 716 | define add-class-source 717 | $(notdir $(basename $v)).class.sources += $v 718 | endef 719 | 720 | $(foreach v, $(class.sources), $(eval $(add-class-source))) 721 | 722 | # derive class names from .class.sources variables 723 | sourcevariables := $(filter %.class.sources, $(.VARIABLES)) 724 | classes := $(basename $(basename $(sourcevariables))) 725 | 726 | # accumulate all source files specified in makefile 727 | classes.sources := $(sort $(foreach v, $(sourcevariables), $($v))) 728 | all.sources := $(classes.sources) $(lib.setup.sources) \ 729 | $(shared.sources) $(common.sources) 730 | 731 | 732 | #=== object files ============================================================== 733 | 734 | 735 | # construct object filenames from all C and C++ source file names 736 | classes.objects := $(addsuffix .$(object.extension), $(basename $(classes.sources))) 737 | common.objects := $(addsuffix .$(object.extension), $(basename $(common.sources))) 738 | shared.objects := $(addsuffix .$(object.extension), $(basename $(shared.sources))) 739 | lib.setup.objects := $(addsuffix .$(object.extension), $(basename $(lib.setup.sources))) 740 | all.objects = $(classes.objects) $(common.objects) $(shared.objects) \ 741 | $(lib.setup.objects) 742 | 743 | 744 | #=== executables =============================================================== 745 | 746 | 747 | # construct class executable names from class names 748 | classes.executables := $(addsuffix .$(extension), $(classes)) 749 | 750 | # Construct shared lib executable name if shared sources are defined. 751 | # If extension does not end with shared extension, use both to facilitate co- 752 | # installation for different platforms, like .m_i386.dll and .linux-amd64-32.so 753 | ifdef shared.sources 754 | ifneq ($(filter %.$(shared.extension), .$(extension)), ) 755 | # $(extension) already ends with $(shared.extension), no need to duplicate it 756 | shared.lib = lib$(lib.name).$(extension) 757 | else 758 | shared.lib = lib$(lib.name).$(extension).$(shared.extension) 759 | endif 760 | else 761 | shared.lib := 762 | endif 763 | 764 | 765 | ################################################################################ 766 | ### variables: tools ########################################################### 767 | ################################################################################ 768 | 769 | 770 | # aliases so we can later define 'compile-$1' and set 'c' or 'cxx' as argument 771 | compile-c := $(CC) 772 | compile-cxx := $(CXX) 773 | 774 | 775 | ################################################################################ 776 | ### checks ##################################################################### 777 | ################################################################################ 778 | 779 | 780 | # At this point most variables are defined. Now do some checks and info's 781 | # before rules begin. 782 | 783 | # print Makefile.pdlibbuilder version before possible termination 784 | $(info ++++ info: using Makefile.pdlibbuilder version $(version)) 785 | 786 | # Terminate if target triplet remained empty, to avoid all sorts of confusing 787 | # scenarios and spurious bugs. 788 | ifeq ($(target.triplet),) 789 | $(error Command "$(CC) -dumpmachine" did not return a target triplet, \ 790 | needed for a build. \ 791 | Is compiler "$(CC)" installed in your PATH? ($(PATH)). \ 792 | Does compiler "$(CC)" support option "-dumpmachine"?) 793 | endif 794 | 795 | # 'forward declaration' of default target, needed to do checks 796 | all: 797 | 798 | # To avoid unpredictable results, make sure the default target is not redefined 799 | # by including makefile. 800 | ifneq ($(.DEFAULT_GOAL), all) 801 | $(error Default target must be 'all'.) 802 | endif 803 | 804 | # find out which target(s) will be made 805 | ifdef MAKECMDGOALS 806 | goals := $(MAKECMDGOALS) 807 | else 808 | goals := all 809 | endif 810 | 811 | # store path to Pd API m_pd.h if it is found 812 | ifdef PDINCLUDEDIR 813 | mpdh := $(shell ls "$(PDINCLUDEDIR)/m_pd.h") 814 | endif 815 | 816 | # store path to pd.dll; if not found, ls will give a useful error 817 | ifeq ($(system), Windows) 818 | pddll := $(shell ls "$(PDBINDIR)/pd$(filter-out 32,$(floatsize)).dll") 819 | endif 820 | 821 | # when making target all, check if m_pd.h is found and print info about it 822 | ifeq ($(goals), all) 823 | $(if $(mpdh), \ 824 | $(info ++++ info: using Pd API $(mpdh)), \ 825 | $(warning Where is Pd API m_pd.h? Do 'make help' for info.)) 826 | endif 827 | 828 | # print target info 829 | $(info ++++ info: making target $(goals) $(if $(lib.name),in lib $(lib.name))) 830 | 831 | # when installing, print installpath info 832 | $(if $(filter install install-lib, $(goals)), $(info ++++ info: \ 833 | installpath is '$(installpath)')) 834 | 835 | 836 | #=== define executables ======================================================== 837 | 838 | 839 | # By default we build class executables, and optionally a shared dynamic link 840 | # lib. When make-lib-executable=yes we build all classes into a single lib 841 | # executable, on the condition that variable lib.setup.sources is defined. 842 | 843 | ifeq ($(make-lib-executable),yes) 844 | $(if $(lib.setup.sources), ,\ 845 | $(error Can not build library blob because lib.setup.sources is undefined)) 846 | executables := $(lib.name).$(extension) 847 | else 848 | executables := $(classes.executables) $(shared.lib) 849 | endif 850 | 851 | 852 | ################################################################################ 853 | ### rules: special targets ##################################################### 854 | ################################################################################ 855 | 856 | 857 | # Disable built-in rules. If some target can't be built with the specified 858 | # rules, it should not be built at all. 859 | MAKEFLAGS += --no-builtin-rules 860 | 861 | .PRECIOUS: 862 | .SUFFIXES: 863 | .PHONY: all post build-lib \ 864 | $(classes) $(makefiledirs) $(makefiles) \ 865 | install install-executables install-datafiles install-datadirs \ 866 | force clean vars allvars depend help 867 | 868 | 869 | ################################################################################ 870 | ### rules: build targets ####################################################### 871 | ################################################################################ 872 | 873 | 874 | # Target all forces the build of targets [$(executables) post] in 875 | # deterministic order. Target $(executables) builds class executables plus 876 | # optional shared lib or alternatively a single lib executable when 877 | # make-lib-executable=true. Target post is optionally defined by 878 | # library makefile. 879 | 880 | all: post 881 | post: $(executables) 882 | 883 | all: 884 | $(info ++++info: target all in lib $(lib.name) completed) 885 | 886 | # build all with -g option turned on for debug symbols 887 | alldebug: c.flags += -g 888 | alldebug: cxx.flags += -g 889 | alldebug: all 890 | 891 | 892 | #=== class executable ========================================================== 893 | 894 | 895 | # recipe for linking objects in class executable 896 | # argument $1 = compiler type (c or cxx) 897 | # argument $2 = class basename 898 | define link-class 899 | $(compile-$1) \ 900 | $($1.ldflags) $($2.class.ldflags) \ 901 | -o $2.$(extension) \ 902 | $(addsuffix .$(object.extension), $(basename $($2.class.sources))) \ 903 | $(addsuffix .$(object.extension), $(basename $(common.sources))) \ 904 | $($1.ldlibs) $($2.class.ldlibs) $(shared.lib) 905 | endef 906 | 907 | # general rule for linking object files in class executable 908 | %.$(extension): $(shared.lib) 909 | $(info ++++ info: linking objects in $@ for lib $(lib.name)) 910 | $(if $(filter %.cc %.cpp, $($*.class.sources)), \ 911 | $(call link-class,cxx,$*), \ 912 | $(call link-class,c,$*)) 913 | 914 | 915 | #=== library blob ============================================================== 916 | 917 | 918 | # build all classes into single executable 919 | build-lib: $(lib.name).$(extension) 920 | $(info ++++ info: library blob $(lib.name).$(extension) completed) 921 | 922 | # recipe for linking objects in lib executable 923 | # argument $1 = compiler type (c or cxx) 924 | define link-lib 925 | $(compile-$1) \ 926 | $($1.ldflags) $(lib.ldflags) \ 927 | -o $(lib.name).$(extension) $(all.objects) \ 928 | $($1.ldlibs) $(lib.ldlibs) 929 | endef 930 | 931 | # rule for linking objects in lib executable 932 | # declared conditionally to avoid name clashes 933 | ifeq ($(make-lib-executable),yes) 934 | $(lib.name).$(extension): $(all.objects) 935 | $(if $(filter %.cc %.cpp, $(all.sources)), \ 936 | $(call link-lib,cxx), \ 937 | $(call link-lib,c)) 938 | endif 939 | 940 | 941 | #=== shared dynamic lib ======================================================== 942 | 943 | 944 | # recipe for linking objects in shared executable 945 | # argument $1 = compiler type (c or cxx) 946 | define link-shared 947 | $(compile-$1) \ 948 | $(shared.ldflags) \ 949 | -o $(shared.lib) $(shared.objects) \ 950 | $($1.ldlibs) $(shared.ldlibs) 951 | endef 952 | 953 | # rule for linking objects in shared executable 954 | # build recipe is in macro 'link-shared' 955 | $(shared.lib): $(shared.objects) 956 | $(info ++++ info: linking objects in shared lib $@) 957 | $(if $(filter %.cc %.cpp, $(shared.sources)), \ 958 | $(call link-shared,cxx), \ 959 | $(call link-shared,c)) 960 | 961 | 962 | #=== object files ============================================================== 963 | 964 | 965 | # recipe to make .o file from source 966 | # argument $1 is compiler type (c or cxx) 967 | define make-object-file 968 | $(info ++++ info: making $@ in lib $(lib.name)) 969 | $(compile-$1) \ 970 | $($1.flags) \ 971 | -o $@ -c $< 972 | endef 973 | 974 | # Three rules to create .o files. These are double colon 'terminal' rules, 975 | # meaning they are the last in a rules chain. 976 | 977 | %.$(object.extension):: %.c 978 | $(call make-object-file,c) 979 | 980 | %.$(object.extension):: %.cc 981 | $(call make-object-file,cxx) 982 | 983 | %.$(object.extension):: %.cpp 984 | $(call make-object-file,cxx) 985 | 986 | 987 | #=== explicit prerequisites for class executables ============================== 988 | 989 | 990 | # For class executables, prerequisite rules are declared in run time. Target 991 | # 'depend' prints these rules for debugging purposes. 992 | 993 | # declare explicit prerequisites rule like 'class: class.extension' 994 | # argument $v is class basename 995 | define declare-class-target 996 | $v: $v.$(extension) 997 | endef 998 | 999 | # declare explicit prerequisites rule like 'class.extension: object1.o object2.o' 1000 | # argument $v is class basename 1001 | define declare-class-executable-target 1002 | $v.$(extension): $(addsuffix .$(object.extension), $(basename $($v.class.sources))) \ 1003 | $(addsuffix .$(object.extension), $(basename $(common.sources))) 1004 | endef 1005 | 1006 | # evaluate explicit prerequisite rules for all classes 1007 | $(foreach v, $(classes), $(eval $(declare-class-target))) 1008 | $(foreach v, $(classes), $(eval $(declare-class-executable-target))) 1009 | 1010 | 1011 | #=== implicit prerequisites for class executables ============================== 1012 | 1013 | 1014 | # Evaluating implicit prerequisites (header files) with help from the 1015 | # preprocessor is 'expensive' so this is done conditionally and selectively. 1016 | # Note that it is also possible to trigger a build via install targets, in 1017 | # which case implicit prerequisites are not checked. 1018 | 1019 | # When the Pd include path contains spaces it will mess up the implicit 1020 | # prerequisites rules. 1021 | disable-dependency-tracking := $(strip $(pdincludepathwithspaces)) 1022 | 1023 | ifndef disable-dependency-tracking 1024 | must-build-everything := $(filter all, $(goals)) 1025 | must-build-class := $(filter $(classes), $(goals)) 1026 | must-build-sources := $(foreach v, $(must-build-class), $($v.class.sources)) 1027 | endif 1028 | 1029 | # declare implicit prerequisites rule like 'object.o: header1.h header2.h ...' 1030 | # argument $1 is input source file(s) 1031 | # dir is explicitly added because option -MM strips it by default 1032 | define declare-object-target 1033 | $(dir $1)$(patsubst %.o:,%.$(object.extension):,$(filter %.o: %.h, $(shell $(CPP) $(depcheck.flags) -MM $1))) $(MAKEFILE_LIST) 1034 | endef 1035 | 1036 | # evaluate implicit prerequisite rules when rebuilding everything 1037 | ifdef must-build-everything 1038 | $(if $(wildcard $(all.objects)), \ 1039 | $(info ++++ info: evaluating implicit prerequisites in lib $(lib.name).....) \ 1040 | $(foreach v, $(all.sources), $(eval $(call declare-object-target, $v)))) 1041 | endif 1042 | 1043 | # evaluate implicit prerequisite rules when selectively building classes 1044 | ifdef must-build-class 1045 | $(foreach v, $(must-build-sources), \ 1046 | $(eval $(call declare-object-target, $v))) 1047 | $(foreach v, $(shared.sources), \ 1048 | $(eval $(call declare-object-target, $v))) 1049 | endif 1050 | 1051 | 1052 | ################################################################################ 1053 | ### rules: preprocessor and assembly files ##################################### 1054 | ################################################################################ 1055 | 1056 | 1057 | # Preprocessor and assembly output files for bug tracing etc. They are not part 1058 | # of the build processes for executables. By default these files are created in 1059 | # the current working directory. Dependency tracking is not performed, the build 1060 | # is forced instead to make sure it's up to date. 1061 | 1062 | force: 1063 | 1064 | 1065 | #=== preprocessor file ========================================================= 1066 | 1067 | 1068 | # make preprocessor output file with extension .pre 1069 | # argument $1 = compiler type (c or cxx) 1070 | define make-preprocessor-file 1071 | $(info ++++ info: making preprocessor output file $(notdir $*.pre) \ 1072 | in current working directory) 1073 | $(compile-$1) -E $< $(c.flags) $($1.flags) -o $(notdir $*.pre) 1074 | endef 1075 | 1076 | %.pre:: %.c force 1077 | $(call make-preprocessor-file,c) 1078 | 1079 | %.pre:: %.cc force 1080 | $(call make-preprocessor-file,cxx) 1081 | 1082 | %.pre:: %.cpp force 1083 | $(call make-preprocessor-file,cxx) 1084 | 1085 | 1086 | #=== assembly file ============================================================= 1087 | 1088 | 1089 | # make C / assembly interleaved output file with extension .lst 1090 | # argument $1 = compiler type (c or cxx) 1091 | define make-assembly-file 1092 | $(info ++++ info: making assembly output file $(notdir $*.lst) \ 1093 | in current working directory) 1094 | $(compile-$1) \ 1095 | -c -Wa,-a,-ad -fverbose-asm \ 1096 | $($1.flags) \ 1097 | $< > $(notdir $*.lst) 1098 | endef 1099 | 1100 | %.lst:: %.c force 1101 | $(call make-assembly-file,c) 1102 | 1103 | %.lst:: %.cc force 1104 | $(call make-assembly-file,cxx) 1105 | 1106 | %.lst:: %.cpp force 1107 | $(call make-assembly-file,cxx) 1108 | 1109 | 1110 | ################################################################################ 1111 | ### rules: installation targets ################################################ 1112 | ################################################################################ 1113 | 1114 | 1115 | #=== strip ===================================================================== 1116 | 1117 | 1118 | # Stripping of installed binaries will only be done when variable 'stripflags' 1119 | # is defined non-empty. No default definition is provided except for Windows 1120 | # where the unstripped binaries are large, especially in the case of Mingw-w64. 1121 | 1122 | # Note: while stripping all symbols ('-s' or '--strip-all') is possible for 1123 | # Linux and Windows, in the case of OSX only non-global symbols can be stripped 1124 | # (option '-x' or '--discard-all'). 1125 | 1126 | # Make definition of strip command overridable so it can be defined in an 1127 | # environment for cross-compilation. 1128 | STRIP ?= strip 1129 | 1130 | # Commands in 'strip-executables' will be executed conditionally in the rule for 1131 | # target 'install-executables'. 1132 | strip-executables = cd "$(installpath)" && \ 1133 | $(foreach v, $(executables), $(STRIP) $(stripflags) '$v';) 1134 | 1135 | 1136 | #=== install =================================================================== 1137 | 1138 | 1139 | # Install targets depend on successful exit status of target all because nothing 1140 | # must be installed in case of a build error. 1141 | 1142 | # -p = preserve time stamps 1143 | # -m = set permission mode (as in chmod) 1144 | # -d = create all components of specified directories 1145 | INSTALL = install 1146 | INSTALL_PROGRAM := $(INSTALL) -p -m 644 1147 | INSTALL_DATA := $(INSTALL) -p -m 644 1148 | INSTALL_DIR := $(INSTALL) -m 755 -d 1149 | 1150 | # strip spaces from file names 1151 | executables := $(strip $(executables)) 1152 | datafiles := $(strip $(datafiles)) 1153 | datadirs := $(strip $(datadirs)) 1154 | 1155 | # Do not make any install sub-target with empty variable definition because the 1156 | # install program would exit with an error. 1157 | install: $(if $(executables), install-executables) 1158 | install: $(if $(datafiles), install-datafiles) 1159 | install: $(if $(datadirs), install-datadirs) 1160 | 1161 | install-executables: all 1162 | $(INSTALL_DIR) -v "$(installpath)" 1163 | $(foreach v, $(executables), \ 1164 | $(INSTALL_PROGRAM) '$v' "$(installpath)";) 1165 | $(info ++++ info: executables of lib $(lib.name) installed \ 1166 | from $(CURDIR) to $(installpath)) 1167 | $(if $(stripflags), $(strip-executables),) 1168 | 1169 | install-datafiles: all 1170 | $(INSTALL_DIR) -v "$(installpath)" 1171 | $(foreach v, $(datafiles), \ 1172 | $(INSTALL_DATA) '$(v)' "$(installpath)";) 1173 | $(info ++++ info: data files of lib $(lib.name) installed \ 1174 | from $(CURDIR) to $(installpath)) 1175 | 1176 | install-datadirs: all 1177 | $(foreach v, $(datadirs), $(INSTALL_DIR) "$(installpath)/$v";) 1178 | $(foreach v, $(datadirs), \ 1179 | $(INSTALL_DATA) $(wildcard $v/*) "$(installpath)/$v";) 1180 | $(info ++++ info: data directories of lib $(lib.name) installed \ 1181 | from $(CURDIR) to $(installpath)) 1182 | 1183 | 1184 | ################################################################################ 1185 | ### rules: distribution targets ################################################ 1186 | ################################################################################ 1187 | 1188 | 1189 | # TODO 1190 | # These targets are implemented in Makefile Template, but I have to figure out 1191 | # how to do it under the not-so-strict conditions of Makefile.pdlibbuilder. 1192 | 1193 | # make source package 1194 | dist: 1195 | @echo "target dist not yet implemented" 1196 | 1197 | # make Debian source package 1198 | dpkg-source: 1199 | @echo "target dpkg-source not yet implemented" 1200 | 1201 | $(ORIGDIR): 1202 | 1203 | $(DISTDIR): 1204 | 1205 | 1206 | ################################################################################ 1207 | ### rules: clean targets ####################################################### 1208 | ################################################################################ 1209 | 1210 | 1211 | # delete build products from build tree 1212 | clean: 1213 | rm -f $(all.objects) 1214 | rm -f $(classes.executables) $(lib.name).$(extension) $(shared.lib) 1215 | rm -f *.pre *.lst 1216 | 1217 | # remove distribution directories and tarballs from build tree 1218 | distclean: clean 1219 | @echo "target distclean not yet implemented" 1220 | 1221 | 1222 | ################################################################################ 1223 | ### rules: submake targets ##################################################### 1224 | ################################################################################ 1225 | 1226 | 1227 | # Iterate over sub-makefiles or makefiles in other directories. 1228 | 1229 | # When 'continue-make=yes' is set, sub-makes will report 'true' to the parent 1230 | # process regardless of their real exit status. This prevents the parent make 1231 | # from being aborted by a sub-make error. Useful when you want to quickly find 1232 | # out which sub-makes from a large set will succeed. 1233 | ifeq ($(continue-make),yes) 1234 | continue = || true 1235 | endif 1236 | 1237 | # These targets will trigger sub-make processes for entries in 'makefiledirs' 1238 | # and 'makefiles'. 1239 | all alldebug install clean distclean dist dkpg-source: \ 1240 | $(makefiledirs) $(makefiles) 1241 | 1242 | # this expands to identical rules for each entry in 'makefiledirs' 1243 | $(makefiledirs): 1244 | $(MAKE) --directory=$@ $(MAKECMDGOALS) $(continue) 1245 | 1246 | # this expands to identical rules for each entry in 'makefiles' 1247 | $(makefiles): 1248 | $(MAKE) --directory=$(dir $@) --makefile=$(notdir $@) $(MAKECMDGOALS) $(continue) 1249 | 1250 | 1251 | ################################################################################ 1252 | ### rules: convenience targets ################################################# 1253 | ################################################################################ 1254 | 1255 | 1256 | #=== show variables ============================================================ 1257 | 1258 | 1259 | # Several 'function' macro's cause errors when expanded within a rule or without 1260 | # proper arguments. Variables which are set with the define directive are only 1261 | # shown by name for that reason. 1262 | functions = \ 1263 | add-class-source \ 1264 | declare-class-target \ 1265 | declare-class-executable-target \ 1266 | declare-object-target \ 1267 | link-class \ 1268 | link-lib \ 1269 | link-shared \ 1270 | make-object-file \ 1271 | make-preprocessor-file \ 1272 | make-assembly-file 1273 | 1274 | 1275 | # show variables from makefiles 1276 | vars: 1277 | $(info ++++ info: showing makefile variables:) 1278 | $(foreach v,\ 1279 | $(sort $(filter-out $(functions) functions, $(.VARIABLES))),\ 1280 | $(if $(filter file, $(origin $v)),\ 1281 | $(info variable $v = $($v)))) 1282 | $(foreach v, $(functions), $(info 'function' name: $v)) 1283 | @echo 1284 | 1285 | # show all variables 1286 | allvars: 1287 | $(info ++++ info: showing default, automatic and makefile variables:) 1288 | $(foreach v, \ 1289 | $(sort $(filter-out $(functions) functions, $(.VARIABLES))), \ 1290 | $(info variable ($(origin $v)) $v = $($v))) 1291 | $(foreach v, $(functions), $(info 'function' name: $v)) 1292 | @echo 1293 | 1294 | 1295 | #=== show dependencies ========================================================= 1296 | 1297 | 1298 | # show generated prerequisites rules 1299 | depend: 1300 | $(info ++++ info: generated prerequisite rules) 1301 | $(foreach v, $(classes), $(info $(declare-class-target))) 1302 | $(foreach v, $(classes), $(info $(declare-class-executable-target))) 1303 | $(foreach v, $(all.sources), $(info $(call declare-object-target, $v))) 1304 | @echo 1305 | 1306 | 1307 | #=== show help text ============================================================ 1308 | 1309 | 1310 | # brief info about targets and paths 1311 | 1312 | ifdef mpdh 1313 | mpdhinfo := $(mpdh) 1314 | else 1315 | mpdhinfo := m_pd.h was not found. Is Pd installed? 1316 | endif 1317 | 1318 | help: 1319 | @echo 1320 | @echo " Main targets:" 1321 | @echo " all: build executables (default target)" 1322 | @echo " install: install all components of the library" 1323 | @echo " vars: print makefile variables for troubleshooting" 1324 | @echo " allvars: print all variables for troubleshooting" 1325 | @echo " help: print this help text" 1326 | @echo 1327 | @echo " Pd API m_pd.h:" 1328 | @echo " $(mpdhinfo)" 1329 | @echo " You may specify your preferred Pd include directory as argument" 1330 | @echo " to the make command, like 'PDINCLUDEDIR=path/to/pd/src'." 1331 | @echo 1332 | @echo " Path for installation of your libdir(s):" 1333 | @echo " $(PDLIBDIR)" 1334 | @echo " Alternatively you may specify your path for installation as argument" 1335 | @echo " to the make command, like 'PDLIBDIR=path/to/pd-externals'." 1336 | @echo 1337 | @echo " Default paths are listed in the doc sections in Makefile.pdlibbuilder." 1338 | @echo 1339 | 1340 | 1341 | #=== platform test ============================================================= 1342 | 1343 | 1344 | # This target can be used to test if the compiler for specified PLATFORM is 1345 | # correctly defined and available. 1346 | 1347 | dumpmachine: 1348 | @$(CC) -dumpmachine 1349 | 1350 | 1351 | #=== dummy target ============================================================== 1352 | 1353 | 1354 | coffee: 1355 | @echo "Makefile.pdlibbuilder: Can not make coffee. Sorry." 1356 | 1357 | 1358 | ################################################################################ 1359 | ### end of rules sections ###################################################### 1360 | ################################################################################ 1361 | 1362 | 1363 | # for syntax highlighting in vim and github 1364 | # vim: set filetype=make: 1365 | 1366 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### Makefile.pdlibbuilder ### 4 | 5 | Helper makefile for Pure Data external libraries. Written by Katja Vetter 6 | March-June 2015 for the public domain and since then developed as a Pd 7 | community project. No warranties. Inspired by Hans Christoph Steiner's Makefile 8 | Template and Stephan Beal's ShakeNMake. 9 | 10 | GNU make version >= 3.81 required. 11 | 12 | 13 | ### characteristics ### 14 | 15 | 16 | * defines build settings based on autodetected target platform 17 | * defines rules to build Pd class- or lib executables from C or C++ sources 18 | * defines rules for libdir installation 19 | * defines convenience targets for developer and user 20 | * evaluates implicit dependencies for non-clean builds 21 | 22 | 23 | ### basic usage ### 24 | 25 | 26 | In your Makefile, define your Pd lib name and class files, and include 27 | Makefile.pdlibbuilder at the end of the Makefile. Like so: 28 | 29 | 30 | # Makefile for mylib 31 | 32 | lib.name = mylib 33 | 34 | class.sources = myclass1.c myclass2.c 35 | 36 | datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt 37 | 38 | PDLIBBUILDER_DIR=. 39 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 40 | 41 | 42 | For files in class.sources it is assumed that class name == source file 43 | basename. The default target builds all classes as individual executables 44 | with Pd's default extension for the platform. For anything more than the 45 | most basic usage, read the documentation sections in Makefile.pdlibbuilder. 46 | 47 | 48 | ### paths ### 49 | 50 | 51 | Makefile.pdlibbuilder >= v0.4.0 supports pd path variables which can be 52 | defined not only as make command argument but also in the environment, to 53 | override platform-dependent defaults: 54 | 55 | PDDIR: 56 | Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and 57 | PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. 58 | 59 | PDINCLUDEDIR: 60 | Directory where Pd API m_pd.h should be found, and other Pd header files. 61 | Overrides the default search path. 62 | 63 | PDBINDIR: 64 | Directory where pd.dll should be found for linking (Windows only). Overrides 65 | the default search path. 66 | 67 | PDLIBDIR: 68 | Root directory for installation of Pd library directories. Overrides the 69 | default install location. 70 | 71 | 72 | ### platform detection and predefined variables ### 73 | 74 | 75 | Makefile.pdlibbuilder tries to detect architecture and operating system in 76 | order to define platform-specific variables. Since v0.6.0 we let the compiler 77 | report target platform, rather than taking the build machine as reference. This 78 | simplifies cross compilation. The kind of build options that are predefined: 79 | 80 | - optimizations useful for realtime DSP processing 81 | - options strictly required for the platform 82 | - options to make the build work accross a range of CPU's and OS versions 83 | 84 | The exact choice and definition predefined variables changes over time, as new 85 | platforms arrive and older platforms become obsolete. The easiest way to get an 86 | overview for your platform is by checking the flags categories in the output of 87 | target `vars`. Variables written in capitals (like `CFLAGS`) are intentionally 88 | exposed as user variables, although technically all makefile variables can be 89 | overridden by make command arguments. 90 | 91 | 92 | ### specific language versions ### 93 | 94 | 95 | Makefile.pdlibbuilder handles C and C++, but can not detect if your code uses 96 | features of a specific version (like C99, C++11, C++14 etc.). In such cases 97 | your makefile should specify that version as compiler option: 98 | 99 | cflags = -std=c++11 100 | 101 | Also you may need to be explicit about minimum OSX version. For example, C++11 102 | needs OSX 10.9 or higher: 103 | 104 | define forDarwin 105 | cflags = -mmacosx-version-min=10.9 106 | endef 107 | 108 | 109 | ### documentation ### 110 | 111 | 112 | This README.md provides only basic information. A large comment section inside 113 | Makefile.pdlibbuilder lists and explains the available user variables, default 114 | paths, and targets. The internal documentation reflects the exact functionality 115 | of the particular version. For suggestions about project maintenance and 116 | advanced compilation see tips-tricks.md. 117 | 118 | 119 | ### versioning ### 120 | 121 | 122 | The project is versioned in MAJOR.MINOR.BUGFIX format (see http://semver.org), 123 | and maintained at https://github.com/pure-data/pd-lib-builder. Pd lib developers 124 | are invited to regulary check for updates, and to contribute and discuss 125 | improvements here. If you really need to distribute a personalized version with 126 | your library, rename Makefile.pdlibbuilder to avoid confusion. 127 | 128 | 129 | ### examples ### 130 | 131 | The list of projects using pd-lib-builder can be helpful if you are looking for 132 | examples, from the simplest use case to more complex implementations. 133 | 134 | - helloworld: traditional illustration of simplest use case 135 | - pd-windowing: straightforward real world use case of a small library 136 | - pd-nilwind / pd-cyclone: more elaborate source tree 137 | - zexy: migrated from autotools to pd-lib-builder 138 | 139 | 140 | ### projects using pd-lib-builder ### 141 | 142 | non-exhaustive list 143 | 144 | https://github.com/pure-data/helloworld 145 | 146 | https://github.com/electrickery/pd-nilwind 147 | 148 | https://github.com/electrickery/pd-maxlib 149 | 150 | https://github.com/electrickery/pd-sigpack 151 | 152 | https://github.com/electrickery/pd-tof 153 | 154 | https://github.com/electrickery/pd-windowing 155 | 156 | https://github.com/electrickery/pd-smlib 157 | 158 | https://github.com/porres/pd-cyclone 159 | 160 | https://github.com/porres/pd-else 161 | 162 | https://github.com/porres/pd-psycho 163 | 164 | https://git.iem.at/pd/comport 165 | 166 | https://git.iem.at/pd/hexloader 167 | 168 | https://git.iem.at/pd/iemgui 169 | 170 | https://git.iem.at/pd/iemguts 171 | 172 | https://git.iem.at/pd/iemlib 173 | 174 | https://git.iem.at/pd/iemnet 175 | 176 | https://git.iem.at/pd/iem_ambi 177 | 178 | https://git.iem.at/pd/iem_tab 179 | 180 | https://git.iem.at/pd/iem_adaptfilt 181 | 182 | https://git.iem.at/pd/iem_roomsim 183 | 184 | https://git.iem.at/pd/iem_spec2 185 | 186 | https://git.iem.at/pd/mediasettings 187 | 188 | https://git.iem.at/pd/zexy 189 | 190 | https://git.iem.at/pd-gui/punish 191 | 192 | https://github.com/residuum/PuRestJson 193 | 194 | https://github.com/libpd/abl_link 195 | 196 | https://github.com/wbrent/timbreID 197 | 198 | https://github.com/MetaluNet/moonlib 199 | 200 | 201 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | # recursively build all example projects in the subdirectories 2 | 3 | 4 | makefiledirs := $(filter-out _%, $(dir $(wildcard */Makefile))) 5 | 6 | PDLIBBUILDER_DIR = ../ 7 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 8 | 9 | buildcheck installcheck: $(makefiledirs) 10 | 11 | runcheck: 12 | PDBINDIR=$(PDBINDIR) ./test-patches.sh $(makefiledirs:%=%*.pd) 13 | 14 | projects: 15 | @echo $(makefiledirs) 16 | -------------------------------------------------------------------------------- /tests/_template_/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class '_template_' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = _template_ 7 | 8 | # input source file (class name == source file basename) 9 | class.sources = _template_.c 10 | 11 | # all extra files to be included in binary distribution of the library 12 | datafiles = _template_-help.pd _template_-meta.pd 13 | 14 | # include Makefile.pdlibbuilder 15 | # (for real-world projects see the "Project Management" section 16 | # in tips-tricks.md) 17 | PDLIBBUILDER_DIR=../.. 18 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 19 | 20 | # simplistic tests whether all expected files have been produced/installed 21 | buildcheck: all 22 | test -e _template_.$(extension) 23 | installcheck: install 24 | test -e $(installpath)/_template_.$(extension) 25 | -------------------------------------------------------------------------------- /tests/_template_/_template_-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X obj 143 125 _template_; 3 | #X msg 143 93 7; 4 | #X connect 1 0 0 0; 5 | -------------------------------------------------------------------------------- /tests/_template_/_template_-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "_template_" external.; 8 | #X text 10 30 NAME _template_; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/_template_/_template_.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*_template__class; 3 | static void _template__float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*_template__new(void) { 7 | return pd_new(_template__class); 8 | } 9 | void _template__setup(void) { 10 | post("%s", __FUNCTION__); 11 | _template__class = class_new(gensym("_template_"), _template__new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(_template__class, _template__float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/make-from-template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | template=_template_ 4 | template_dir=${0%/*}/${template} 5 | 6 | outdir=$1 7 | outdir=${outdir%/} 8 | outname=${outdir##*/} 9 | 10 | 11 | usage() { 12 | cat 1>&2 < 14 | creates a new test-directory from _template_; 15 | must not exist yet. 16 | EOL 17 | if [ "x$@" != "x" ]; then 18 | echo 19 | echo " $@" 1>&2 20 | fi 21 | exit 1 22 | } 23 | 24 | if [ "x${outdir}" = "x" ]; then 25 | usage 26 | fi 27 | 28 | if [ -d "${outdir}" ]; then 29 | usage "output directory '${outdir}' already exists!" 30 | fi 31 | 32 | if [ ! -d "${template_dir}" ]; then 33 | echo "unable to find '${template_dir}'" 1>&2 34 | exit 1 35 | fi 36 | 37 | mkdir -p "${outdir}" || usage "unable to create '${outdir}'!" 38 | rmdir "${outdir}" 39 | cp -r "${template_dir}" "${outdir}" 40 | find "${outdir}" -type f -exec sed -e "s|${template}|${outname}|g" -i {} + 41 | for f in "${outdir}"/*; do 42 | g=$(echo $f | sed -e "s|${template}|${outname}|g") 43 | if [ "x${f}" != "x${g}" ]; then 44 | mv "${f}" "${g}" 45 | fi 46 | done 47 | -------------------------------------------------------------------------------- /tests/multifor/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class 'multifor' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = multifor 7 | 8 | # input source file (class name == source file basename) 9 | class.sources = multiforA.c 10 | 11 | # additional classes 12 | define forLinux 13 | class.sources += multiforB.c 14 | endef 15 | define forDarwin 16 | class.sources += multiforB.c 17 | endef 18 | define forWindows 19 | class.sources += multiforB.c 20 | endef 21 | 22 | # all extra files to be included in binary distribution of the library 23 | datafiles = multifor-help.pd multifor-meta.pd 24 | 25 | # include Makefile.pdlibbuilder 26 | # (for real-world projects see the "Project Management" section 27 | # in tips-tricks.md) 28 | PDLIBBUILDER_DIR=../.. 29 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 30 | 31 | # simplistic tests whether all expected files have been produced/installed 32 | buildcheck: all 33 | test -e multiforA.$(extension) 34 | test -e multiforB.$(extension) 35 | installcheck: install 36 | test -e $(installpath)/multiforA.$(extension) 37 | test -e $(installpath)/multiforB.$(extension) 38 | test -e $(installpath)/multifor-help.pd 39 | test -e $(installpath)/multifor-meta.pd 40 | -------------------------------------------------------------------------------- /tests/multifor/README.md: -------------------------------------------------------------------------------- 1 | multifor 2 | ======== 3 | 4 | minimal pd-lib-builder project that shows how to compile 5 | a library that contains multiple C-files that are compiled into 6 | multiple binaries each containing a different Pd-objectclass. 7 | some of the objectclasses are only compiled on specific platforms. 8 | 9 | this is a special case of the one-object-per-binary library structure. 10 | -------------------------------------------------------------------------------- /tests/multifor/multifor-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X msg 143 93 7; 3 | #X obj 143 125 multiforA; 4 | #X obj 223 125 multiforB; 5 | #X msg 223 93 12; 6 | #X connect 0 0 1 0; 7 | #X connect 3 0 2 0; 8 | -------------------------------------------------------------------------------- /tests/multifor/multifor-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "multifor" external.; 8 | #X text 10 30 NAME multifor; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/multifor/multiforA.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*multiforA_class; 3 | static void multiforA_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*multiforA_new(void) { 7 | return pd_new(multiforA_class); 8 | } 9 | void multiforA_setup(void) { 10 | post("%s", __FUNCTION__); 11 | multiforA_class = class_new(gensym("multiforA"), multiforA_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(multiforA_class, multiforA_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/multifor/multiforB.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*multiforB_class; 3 | static void multiforB_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*multiforB_new(void) { 7 | return pd_new(multiforB_class); 8 | } 9 | void multiforB_setup(void) { 10 | post("%s", __FUNCTION__); 11 | multiforB_class = class_new(gensym("multiforB"), multiforB_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(multiforB_class, multiforB_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/multilib/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class 'multilib' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = multilib 7 | 8 | make-lib-executable=yes 9 | 10 | # input source file (class name == source file basename) 11 | class.sources = multilibA.c multilibB.c 12 | 13 | # glue for building a multi-object library 14 | lib.setup.sources = $(lib.name).c 15 | 16 | # all extra files to be included in binary distribution of the library 17 | datafiles = multilib-help.pd multilib-meta.pd 18 | 19 | # include Makefile.pdlibbuilder 20 | # (for real-world projects see the "Project Management" section 21 | # in tips-tricks.md) 22 | PDLIBBUILDER_DIR=../.. 23 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 24 | 25 | 26 | # simplistic tests whether all expected files have been produced/installed 27 | buildcheck: all 28 | test -e multilib.$(extension) 29 | installcheck: install 30 | test -e $(installpath)/multilib.$(extension) 31 | test -e $(installpath)/multilib-help.pd 32 | test -e $(installpath)/multilib-meta.pd 33 | -------------------------------------------------------------------------------- /tests/multilib/README.md: -------------------------------------------------------------------------------- 1 | multilib 2 | ======== 3 | 4 | minimal pd-lib-builder project that shows how to compile 5 | a library that contains multiple C-files that are compiled into 6 | a single binary containing different Pd-objectclasses. 7 | 8 | this is the general case of the single-binary library structure. 9 | -------------------------------------------------------------------------------- /tests/multilib/multilib-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X declare -lib multilib; 3 | #X msg 143 93 7; 4 | #X obj 143 125 multilibA; 5 | #X obj 223 125 multilibB; 6 | #X msg 223 93 12; 7 | #X obj 136 47 declare -lib multilib; 8 | #X connect 0 0 1 0; 9 | #X connect 3 0 2 0; 10 | -------------------------------------------------------------------------------- /tests/multilib/multilib-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "multiple" external.; 8 | #X text 10 30 NAME multiple; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/multilib/multilib.c: -------------------------------------------------------------------------------- 1 | 2 | void multilibA_setup(void); 3 | void multilibB_setup(void); 4 | 5 | void multilib_setup(void) { 6 | multilibA_setup(); 7 | multilibB_setup(); 8 | } 9 | -------------------------------------------------------------------------------- /tests/multilib/multilibA.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*multilibA_class; 3 | static void multilibA_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*multilibA_new(void) { 7 | return pd_new(multilibA_class); 8 | } 9 | void multilibA_setup(void) { 10 | post("%s", __FUNCTION__); 11 | multilibA_class = class_new(gensym("multilibA"), multilibA_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(multilibA_class, multilibA_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/multilib/multilibB.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*multilibB_class; 3 | static void multilibB_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*multilibB_new(void) { 7 | return pd_new(multilibB_class); 8 | } 9 | void multilibB_setup(void) { 10 | post("%s", __FUNCTION__); 11 | multilibB_class = class_new(gensym("multilibB"), multilibB_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(multilibB_class, multilibB_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/multiple/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class 'multiple' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = multiple 7 | 8 | # input source file (class name == source file basename) 9 | class.sources = multipleA.c multipleB.c 10 | 11 | # all extra files to be included in binary distribution of the library 12 | datafiles = multiple-help.pd multiple-meta.pd 13 | 14 | # include Makefile.pdlibbuilder 15 | # (for real-world projects see the "Project Management" section 16 | # in tips-tricks.md) 17 | PDLIBBUILDER_DIR=../.. 18 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 19 | 20 | # simplistic tests whether all expected files have been produced/installed 21 | buildcheck: all 22 | test -e multipleA.$(extension) 23 | test -e multipleB.$(extension) 24 | installcheck: install 25 | test -e $(installpath)/multipleA.$(extension) 26 | test -e $(installpath)/multipleB.$(extension) 27 | test -e $(installpath)/multiple-help.pd 28 | test -e $(installpath)/multiple-meta.pd 29 | -------------------------------------------------------------------------------- /tests/multiple/README.md: -------------------------------------------------------------------------------- 1 | multiple 2 | ======== 3 | 4 | minimal pd-lib-builder project that shows how to compile 5 | a library that contains multiple C-files that are compiled into 6 | multiple binaries each containing a different Pd-objectclass. 7 | 8 | this is the general case of the one-object-per-binary library structure. 9 | -------------------------------------------------------------------------------- /tests/multiple/multiple-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X msg 143 93 7; 3 | #X obj 143 125 multipleA; 4 | #X obj 223 125 multipleB; 5 | #X msg 223 93 12; 6 | #X connect 0 0 1 0; 7 | #X connect 3 0 2 0; 8 | -------------------------------------------------------------------------------- /tests/multiple/multiple-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "multiple" external.; 8 | #X text 10 30 NAME multiple; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/multiple/multipleA.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*multipleA_class; 3 | static void multipleA_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*multipleA_new(void) { 7 | return pd_new(multipleA_class); 8 | } 9 | void multipleA_setup(void) { 10 | post("%s", __FUNCTION__); 11 | multipleA_class = class_new(gensym("multipleA"), multipleA_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(multipleA_class, multipleA_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/multiple/multipleB.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*multipleB_class; 3 | static void multipleB_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*multipleB_new(void) { 7 | return pd_new(multipleB_class); 8 | } 9 | void multipleB_setup(void) { 10 | post("%s", __FUNCTION__); 11 | multipleB_class = class_new(gensym("multipleB"), multipleB_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(multipleB_class, multipleB_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/multiplexx/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class 'multiplexx' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = multiplexx 7 | 8 | # input source file (class name == source file basename) 9 | class.sources = multiplexxA.cpp multiplexxB.c 10 | 11 | # all extra files to be included in binary distribution of the library 12 | datafiles = multiplexx-help.pd multiplexx-meta.pd 13 | 14 | # include Makefile.pdlibbuilder 15 | # (for real-world projects see the "Project Management" section 16 | # in tips-tricks.md) 17 | PDLIBBUILDER_DIR=../.. 18 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 19 | 20 | # simplistic tests whether all expected files have been produced/installed 21 | buildcheck: all 22 | test -e multiplexxA.$(extension) 23 | test -e multiplexxB.$(extension) 24 | installcheck: install 25 | test -e $(installpath)/multiplexxA.$(extension) 26 | test -e $(installpath)/multiplexxB.$(extension) 27 | test -e $(installpath)/multiplexx-help.pd 28 | test -e $(installpath)/multiplexx-meta.pd 29 | -------------------------------------------------------------------------------- /tests/multiplexx/README.md: -------------------------------------------------------------------------------- 1 | multiplexx 2 | ======== 3 | 4 | minimal pd-lib-builder project that shows how to compile 5 | a library that contains multiplexx C-files that are compiled into 6 | multiplexx binaries each containing a different Pd-objectclass. 7 | 8 | this is the general case of the one-object-per-binary library structure. 9 | -------------------------------------------------------------------------------- /tests/multiplexx/multiplexx-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X msg 143 93 7; 3 | #X obj 143 125 multiplexxA; 4 | #X obj 223 125 multiplexxB; 5 | #X msg 223 93 12; 6 | #X connect 0 0 1 0; 7 | #X connect 3 0 2 0; 8 | -------------------------------------------------------------------------------- /tests/multiplexx/multiplexx-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "multiplexx" external.; 8 | #X text 10 30 NAME multiplexx; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/multiplexx/multiplexxA.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | t_class*multiplexxA_class; 4 | static void multiplexxA_float(t_object*x, t_float f1) { 5 | pd_error(x, "%s got %f", __FUNCTION__, f1); 6 | } 7 | static void*multiplexxA_new(void) { 8 | return pd_new(multiplexxA_class); 9 | } 10 | #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) 11 | extern "C" { 12 | void multiplexxA_setup(void); 13 | } 14 | #endif 15 | void multiplexxA_setup(void) { 16 | std::cerr << __FUNCTION__ << std::endl; 17 | multiplexxA_class = class_new(gensym("multiplexxA"), multiplexxA_new, 0, sizeof(t_object), 0, A_NULL); 18 | class_addfloat(multiplexxA_class, multiplexxA_float); 19 | } 20 | -------------------------------------------------------------------------------- /tests/multiplexx/multiplexxB.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*multiplexxB_class; 3 | static void multiplexxB_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*multiplexxB_new(void) { 7 | return pd_new(multiplexxB_class); 8 | } 9 | void multiplexxB_setup(void) { 10 | post("%s", __FUNCTION__); 11 | multiplexxB_class = class_new(gensym("multiplexxB"), multiplexxB_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(multiplexxB_class, multiplexxB_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/multishared/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class 'multishared' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = multishared 7 | 8 | # common functions 9 | shared.sources = shared.c 10 | 11 | # input source file (class name == source file basename) 12 | class.sources = multisharedA.c multisharedB.c 13 | 14 | # all extra files to be included in binary distribution of the library 15 | datafiles = multishared-help.pd multishared-meta.pd 16 | 17 | # include Makefile.pdlibbuilder 18 | # (for real-world projects see the "Project Management" section 19 | # in tips-tricks.md) 20 | PDLIBBUILDER_DIR=../.. 21 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 22 | 23 | # simplistic tests whether all expected files have been produced/installed 24 | buildcheck: all 25 | ifeq ($(shared.extension), $(extension)) 26 | test -e lib$(lib.name).$(shared.extension) 27 | else 28 | test -e lib$(lib.name).$(extension).$(shared.extension) 29 | endif 30 | test -e multisharedA.$(extension) 31 | test -e multisharedB.$(extension) 32 | installcheck: install 33 | ifeq ($(shared.extension), $(extension)) 34 | test -e $(installpath)/lib$(lib.name).$(shared.extension) 35 | else 36 | test -e $(installpath)/lib$(lib.name).$(extension).$(shared.extension) 37 | endif 38 | test -e $(installpath)/multisharedA.$(extension) 39 | test -e $(installpath)/multisharedB.$(extension) 40 | test -e $(installpath)/multishared-help.pd 41 | test -e $(installpath)/multishared-meta.pd 42 | -------------------------------------------------------------------------------- /tests/multishared/README.md: -------------------------------------------------------------------------------- 1 | multishared 2 | =========== 3 | 4 | minimal pd-lib-builder project that shows how to compile 5 | a library that contains multiple C-files that are compiled into 6 | multiple binaries each containing a different Pd-objectclass. 7 | a local shared library is used for common components. 8 | 9 | this is an extended case of the one-object-per-binary library structure. 10 | -------------------------------------------------------------------------------- /tests/multishared/multishared-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X msg 143 93 7; 3 | #X obj 143 125 multisharedA; 4 | #X obj 223 125 multisharedB; 5 | #X msg 223 93 12; 6 | #X connect 0 0 1 0; 7 | #X connect 3 0 2 0; 8 | -------------------------------------------------------------------------------- /tests/multishared/multishared-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "multishared" external.; 8 | #X text 10 30 NAME multishared; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/multishared/multishared.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void multishared_foo(t_float f); 4 | -------------------------------------------------------------------------------- /tests/multishared/multisharedA.c: -------------------------------------------------------------------------------- 1 | #include "multishared.h" 2 | t_class*multisharedA_class; 3 | static void multisharedA_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | multishared_foo(f1); 6 | } 7 | static void*multisharedA_new(void) { 8 | return pd_new(multisharedA_class); 9 | } 10 | void multisharedA_setup(void) { 11 | post("%s", __FUNCTION__); 12 | multisharedA_class = class_new(gensym("multisharedA"), multisharedA_new, 0, sizeof(t_object), 0, A_NULL); 13 | class_addfloat(multisharedA_class, multisharedA_float); 14 | } 15 | -------------------------------------------------------------------------------- /tests/multishared/multisharedB.c: -------------------------------------------------------------------------------- 1 | #include "multishared.h" 2 | t_class*multisharedB_class; 3 | static void multisharedB_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | multishared_foo(f1); 6 | } 7 | static void*multisharedB_new(void) { 8 | return pd_new(multisharedB_class); 9 | } 10 | void multisharedB_setup(void) { 11 | post("%s", __FUNCTION__); 12 | multisharedB_class = class_new(gensym("multisharedB"), multisharedB_new, 0, sizeof(t_object), 0, A_NULL); 13 | class_addfloat(multisharedB_class, multisharedB_float); 14 | } 15 | -------------------------------------------------------------------------------- /tests/multishared/shared.c: -------------------------------------------------------------------------------- 1 | #include "multishared.h" 2 | 3 | void multishared_foo(t_float f) { 4 | post("%s(%f)", __FUNCTION__, f); 5 | } 6 | -------------------------------------------------------------------------------- /tests/single/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class 'single' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = single 7 | 8 | # input source file (class name == source file basename) 9 | class.sources = single.c 10 | 11 | # all extra files to be included in binary distribution of the library 12 | datafiles = single-help.pd single-meta.pd 13 | 14 | # include Makefile.pdlibbuilder 15 | # (for real-world projects see the "Project Management" section 16 | # in tips-tricks.md) 17 | PDLIBBUILDER_DIR=../.. 18 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 19 | 20 | # simplistic tests whether all expected files have been produced/installed 21 | buildcheck: all 22 | test -e single.$(extension) 23 | installcheck: install 24 | test -e $(installpath)/single.$(extension) 25 | -------------------------------------------------------------------------------- /tests/single/README.md: -------------------------------------------------------------------------------- 1 | single 2 | ====== 3 | 4 | minimal pd-lib-builder project that shows how to compile 5 | a library that contains a single C-file that is compiled into 6 | a single binary containing a single Pd-objectclass. 7 | 8 | this is a degenerate case of the one-object-per-binary library structure. 9 | -------------------------------------------------------------------------------- /tests/single/single-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X obj 143 125 single; 3 | #X msg 143 93 7; 4 | #X connect 1 0 0 0; 5 | -------------------------------------------------------------------------------- /tests/single/single-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "single" external.; 8 | #X text 10 30 NAME single; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/single/single.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*single_class; 3 | static void single_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*single_new(void) { 7 | return pd_new(single_class); 8 | } 9 | void single_setup(void) { 10 | post("%s", __FUNCTION__); 11 | single_class = class_new(gensym("single"), single_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(single_class, single_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/subdir/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to build class 'subdir' for Pure Data. 2 | # Needs Makefile.pdlibbuilder as helper makefile for platform-dependent build 3 | # settings and rules. 4 | 5 | # library name 6 | lib.name = subdir 7 | 8 | # input source file (class name == source file basename) 9 | class.sources = src/subdir.c src/subdir~.c 10 | 11 | # all extra files to be included in binary distribution of the library 12 | datafiles = subdir-help.pd subdir-meta.pd 13 | 14 | # include Makefile.pdlibbuilder 15 | # (for real-world projects see the "Project Management" section 16 | # in tips-tricks.md) 17 | 18 | PDLIBBUILDER_DIR=../.. 19 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 20 | 21 | # simplistic tests whether all expected files have been produced/installed 22 | buildcheck: all 23 | test -e subdir.$(extension) 24 | test -e subdir~.$(extension) 25 | installcheck: install 26 | test -e $(installpath)/subdir.$(extension) 27 | test -e $(installpath)/subdir~.$(extension) 28 | -------------------------------------------------------------------------------- /tests/subdir/README.md: -------------------------------------------------------------------------------- 1 | subdir 2 | ====== 3 | 4 | pd-lib-builder project that shows how to compile 5 | a library that contains a single C-file in a separate src/ directory, 6 | that is compiled into a single binary containing a subdir Pd-objectclass. 7 | 8 | this is a special case of the one-object-per-binary library structure. 9 | -------------------------------------------------------------------------------- /tests/subdir/src/subdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*subdir_class; 3 | static void subdir_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*subdir_new(void) { 7 | return pd_new(subdir_class); 8 | } 9 | void subdir_setup(void) { 10 | post("%s", __FUNCTION__); 11 | subdir_class = class_new(gensym("subdir"), subdir_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(subdir_class, subdir_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/subdir/src/subdir~.c: -------------------------------------------------------------------------------- 1 | #include 2 | t_class*subdir_tilde_class; 3 | static void subdir_tilde_float(t_object*x, t_float f1) { 4 | pd_error(x, "%s got %f", __FUNCTION__, f1); 5 | } 6 | static void*subdir_tilde_new(void) { 7 | return pd_new(subdir_tilde_class); 8 | } 9 | void subdir_tilde_setup(void) { 10 | post("%s", __FUNCTION__); 11 | subdir_tilde_class = class_new(gensym("subdir~"), subdir_tilde_new, 0, sizeof(t_object), 0, A_NULL); 12 | class_addfloat(subdir_tilde_class, subdir_tilde_float); 13 | } 14 | -------------------------------------------------------------------------------- /tests/subdir/subdir-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X obj 143 125 subdir; 3 | #X msg 143 93 7; 4 | #X connect 1 0 0 0; 5 | -------------------------------------------------------------------------------- /tests/subdir/subdir-meta.pd: -------------------------------------------------------------------------------- 1 | #N canvas 966 322 200 200 10; 2 | #N canvas 19 51 420 300 META 0; 3 | #X text 10 10 META this is a prototype of a libdir meta file; 4 | #X text 10 51 AUTHOR IOhannes m zmolnig; 5 | #X text 10 110 VERSION 1.0.0; 6 | #X text 10 90 LICENSE CC0; 7 | #X text 10 70 DESCRIPTION Example "subdir" external.; 8 | #X text 10 30 NAME subdir; 9 | #X restore 10 10 pd META; 10 | -------------------------------------------------------------------------------- /tests/subdir/subdir~-help.pd: -------------------------------------------------------------------------------- 1 | #N canvas 335 160 450 300 12; 2 | #X obj 143 125 subdir~; 3 | #X msg 143 93 7; 4 | #X connect 1 0 0 0; 5 | -------------------------------------------------------------------------------- /tests/test-patches.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## simple script to open patches via Pd, and check for errors 4 | ## - each patch is opened separately 5 | ## - if an error is encountered, the Pd-printout is displayed 6 | ## (else it is suppressed) 7 | ## - if any of the patches encountered an error, the script will 8 | ## exit with a non-0 code 9 | 10 | if [ "x${PD}" = "x" ]; then 11 | if [ "x${PDBINDIR}" != "x" ]; then 12 | for exe in pd.com pd pd.exe; do 13 | if [ -x "${PDBINDIR}/${exe}" ]; then 14 | PD="${PDBINDIR}/${exe}" 15 | break 16 | fi 17 | done 18 | if [ "x${PD}" = "x" ]; then 19 | echo "WARNING: couldn't find a usable Pd in '${PDBINDIR}'" 1>&2 20 | fi 21 | fi 22 | fi 23 | if [ "x${PD}" = "x" ]; then 24 | PD=pd 25 | fi 26 | echo "using Pd: ${PD}" 27 | 28 | failed=0 29 | failed_tests="" 30 | succeeded=0 31 | 32 | open1patch() { 33 | logfile=$(mktemp) 34 | local patch=$1 35 | local patchdir=${patch%%/*} 36 | local patchfile=${patch#*/} 37 | patchfile=${patchfile#/} 38 | #echo "INFO: running ${patchfile} in ${patchdir}" 39 | cd "${patchdir}" && \ 40 | ${PD} -batch -nrt -noprefs -nostdpath -open "${patchfile}" -send "pd quit" \ 41 | >"${logfile}" 2>&1 42 | ret=$? 43 | if grep "error: ... couldn't create" "${logfile}" >/dev/null; then 44 | ret=1 45 | fi 46 | if [ "x${ret}" != "x0" ]; then 47 | echo "" 48 | cat "${logfile}" 49 | echo "FAILED[$ret]: ${patch}" 50 | else 51 | echo "SUCCEEDED: ${patch}" 52 | fi 53 | rm "${logfile}" 54 | return $ret 55 | } 56 | 57 | for p in "${@}"; do 58 | if (open1patch "${p}"); then 59 | succeeded=$((succeeded+1)) 60 | else 61 | failed=$((failed+1)) 62 | failed_tests="${failed_tests} ${p}" 63 | fi 64 | done 65 | 66 | echo "" 67 | echo "SUCCESS: ${succeeded}" 68 | echo "FAILURE: ${failed}" 69 | test ${failed} -eq 0 || echo "FAILS :${failed_tests}" 70 | test ${failed} -eq 0 71 | -------------------------------------------------------------------------------- /tips-tricks.md: -------------------------------------------------------------------------------- 1 | pd-lib-builder cheatsheet 2 | ========================= 3 | 4 | # Creating special builds 5 | 6 | ## Building for non-native platform 7 | 8 | Using pd-lib-builder >=0.6.0 we can define variable `PLATFORM` to specify a 9 | target triplet for cross-compilation. Assuming a W32 package for Pd is unzipped 10 | into path `${PDWIN32}`, to build for Windows 32 bit: 11 | 12 | make PLATFORM=i686-w64-mingw32 PDDIR="${PDWIN32}" 13 | 14 | #### Older pd-lib-builder versions 15 | 16 | Using pd-lib-builder < 0.6.0, in the absence of variable `PLATFORM`, you would 17 | instead override variables `system`, `target.arch`, `CC` and / or `CXX`, 18 | `STRIP`. Example: 19 | 20 | make system=Windows target.arch=i686 CC=i686-w64-mingw32-gcc STRIP=i686-w64-mingw32-strip PDDIR="${PDWIN32}" 21 | 22 | #### Toolchains 23 | 24 | To build for non-native OS and/or architecture you need a cross toolchain. On 25 | Linux such toolchains are relatively easy to get. For example Debian Buster 26 | amd64 provides them for the following platforms (install g++ with dependencies 27 | for a given platform to get the whole toolchain): 28 | 29 | - `arm-linux-gnueabihf` 30 | - `aarch64-linux-gnu` 31 | - `i686-linux-gnu` 32 | - `i686-w64-mingw32` and `x86_64-w64-mingw32` (install `mingw-w64`) 33 | 34 | Cross toolchains for OSX/MacOS are not generally distributed. Project 35 | `osxcross` from Thomas Poechtraeger can create them for Linux. 36 | 37 | ## Universal binaries on macOS 38 | 39 | The compiler, by default, builds for the native architecture of the build 40 | machine. To make a "universal" multi-arch build, specify the desired 41 | archtectures on the command line using the "arch" pd-lib-builder Makefile 42 | variable. 43 | 44 | For example, to build a "fat" external for both 64-bit Intel and Arm (Apple 45 | Silicon): 46 | 47 | make arch="x86_64 arm64" 48 | 49 | If the build is successful, the compiled architectures in the built external can 50 | be confirmed via the `file` command: 51 | 52 | ~~~sh 53 | % file vbap.pd_darwin 54 | vbap.pd_darwin: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64] 55 | vbap.pd_darwin (for architecture x86_64): Mach-O 64-bit bundle x86_64 56 | vbap.pd_darwin (for architecture arm64): Mach-O 64-bit bundle arm64 57 | ~~~ 58 | 59 | Note: The available architectures depend on which macOS version & command line 60 | tools/Xcode combination the build system has. For example, any newer macOS 61 | 10.15+ will support both x86_64 (Intel 64-bit) and arm64 (Apple Silicon) while 62 | OSX 10.6 - macOS 10.14 can build for x86_64 and i386 (Intel 32-bit). 63 | 64 | ## Building double-precision externals 65 | 66 | At the time of writing (2023-07-06) there is no official Pd that supports 67 | double-precision numbers yet. 68 | However, if you do get hold of an experimental double-precision Pd, you can 69 | easily build your externals for 64-bit numbers, by passing `floatsize=64` 70 | as an argument to `make`. 71 | Starting with Pd>=0.54, double precision externals use different extensions 72 | from traditional (single-precision) externals. 73 | The extension consists of the OS ("linux", "darwin", "windows"), the CPU 74 | architecture ("amd64" (x86_64), "i386" (x86), "arm64",...) and the floatsize 75 | in bits ("64" for double-precision), followed by the system's native extension 76 | for dynamic libraries (".dll" on Windows, ".so" on macOS/Linux/un*xes). 77 | As of pd-lib-builder==0.7.0, you have to manually pass this extension: 78 | 79 | make floatsize=64 extension=windows-amd64-64.dll 80 | make floatsize=64 extension=linux-arm64-64.so 81 | make floatsize=64 extension=darwin-fat-64.so arch="x86_64 arm64" 82 | 83 | 84 | # Project management 85 | 86 | In general it is advised to put the `Makefile.pdlibbuilder` into a separate 87 | subdirectory (e.g. `pd-lib-builder/`). 88 | This makes it much easier to update the `Makefile.pdlibbuilder` later 89 | 90 | You *should* also use a variable to the actual path of the Makefile.pdlibbuilder 91 | (even if you keep it in the root-directory), as this allows easy experimenting 92 | with newer (or older) (or site-specific) versions of the pd-lib-builder 93 | Makefile. 94 | 95 | ~~~make 96 | PDLIBBUILDER_DIR=pd-lib-builder/ 97 | include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder 98 | ~~~ 99 | 100 | ## Keeping pd-lib-builder up-to-date 101 | 102 | ### `git subtree` 103 | 104 | With git-subtrees, you make the pd-lib-builder repository (or any other 105 | repository for that matter) part of your own repository - with full history and 106 | everything - put nicely into a distinct subdirectory. 107 | 108 | Support for *manipulating* subtrees has been added with Git-v1.7.11 (May 2012). 109 | The nice thing however is, that from "outside" the subtree is part of your 110 | repository like any other directory. E.g. older versions of Git can clone your 111 | repository with the full subtree (and all it's history) just fine. 112 | You can also use git-archive to make a complete snapshot of your repository 113 | (including the subtree) - nice, if you e.g. want self-contained downloads of 114 | your project from git hosting platforms (like Github, Gitlab, Bitbucket,...) 115 | 116 | In short, `git subtree` is the better `git submodule`. 117 | 118 | So here's how to do it: 119 | 120 | #### Initial setup/check-out 121 | 122 | This will create a `pd-lib-builder/` directory containing the full history of 123 | the pd-lib-builder repository up to its release `v0.5.0` 124 | 125 | ~~~sh 126 | git subtree add --prefix=pd-lib-builder/ https://github.com/pure-data/pd-lib-builder v0.5.0 127 | ~~~ 128 | 129 | This will automatically merge the `pd-lib-builder/` history into your current 130 | branch, so everything is ready to go. 131 | 132 | #### Cloning your repository with the subtree 133 | 134 | Nothing special, really. 135 | Just clone your repository as always: 136 | 137 | ~~~sh 138 | git clone https://git.example.org/pd/superbonk~.git 139 | ~~~ 140 | 141 | #### Updating the subtree 142 | 143 | Time passes and sooner or later you will find, that there is a shiny new 144 | pd-lib-builder with plenty of bugfixes and new features. 145 | To update your local copy to pd-lib-builder's current `master`, simply run: 146 | 147 | ~~~sh 148 | git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master 149 | ~~~ 150 | 151 | #### Pulling the updated subtree into existing clones 152 | 153 | Again, nothing special. 154 | Just pull as always: 155 | 156 | ~~~sh 157 | git pull 158 | ~~~ 159 | 160 | #### Further reading 161 | 162 | More on the power of `git subtree` can be found online 163 | - https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844 164 | - https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree 165 | - ... 166 | 167 | ### ~~`git submodule`~~ [DISCOURAGED] 168 | 169 | #### Initial setup/check-out 170 | 171 | To add a new submodule to your repository, just run `git submodule add` and 172 | commit the changes: 173 | 174 | ~~~sh 175 | git submodule add https://github.com/pure-data/pd-lib-builder 176 | git commit .gitmodules pd-lib-builder/ -m "Added pd-lib-builder as git-submodule" 177 | ~~~ 178 | 179 | #### Cloning your repository with the submodule 180 | 181 | When doing a fresh clone of your repository, pass the `--recursive` option to 182 | automatically fetch all submodules: 183 | 184 | ~~~sh 185 | git clone --recursive https://git.example.org/pd/superbonk~.git 186 | ~~~ 187 | 188 | If you've cloned non-recursively, you can initialize and update the submodules 189 | manually: 190 | 191 | ~~~sh 192 | git submodule init 193 | git submodule update 194 | ~~~ 195 | 196 | #### Updating the submodule 197 | 198 | Submodules are usually fixed to a given commit in their repository. 199 | To update the `pd-lib-builder` submodule to the current `master` do something 200 | like: 201 | 202 | ~~~sh 203 | cd pd-lib-builder 204 | git checkout master 205 | git pull 206 | cd .. 207 | git status pd-lib-builder 208 | git commit pd-lib-builder -m "Updated pd-lib-builder to current master" 209 | ~~~ 210 | 211 | #### Pulling the updated submodule into existing clones 212 | 213 | After you have pushed the submodule updates in your repository, other clones of 214 | the repository can be updated as follows: 215 | 216 | ~~~sh 217 | git pull 218 | ~~~ 219 | 220 | The above will make your repository aware, that the submodule is out-of-sync. 221 | 222 | ~~~sh 223 | $ LANG=C git status pd-lib-builder 224 | On branch master 225 | Your branch is up to date with 'origin/master'. 226 | 227 | Changes not staged for commit: 228 | (use "git add ..." to update what will be committed) 229 | (use "git checkout -- ..." to discard changes in working directory) 230 | 231 | modified: pd-lib-builder (new commits) 232 | $ 233 | ~~~ 234 | 235 | In order to sync the submodule to the correct commit, run the following: 236 | 237 | ~~~sh 238 | git submodule update 239 | ~~~ 240 | 241 | #### Drawbacks 242 | 243 | `git submodule` has a number of drawbacks: 244 | - it requires special commands to synchronize the submodules, in addition to 245 | synching your repository. 246 | - you must make sure to use an URL for the submodule that is accessible to your 247 | potential users. e.g. using `git@github.com:pure-data/pd-lib-builder` is bad, 248 | because it requires everybody who wants to checkout your sources to have a 249 | github-account - even if they could checkout *your* repository anonymously. 250 | - submodules will be excluded from `git archive`. This means, that if you use a 251 | mainstream git provider (like Github, GitLab, Bitbucket,...) and make releases 252 | by creating a `git tag`, the automatically generated zipfiles with the sources 253 | will lack the submodule - and your users will not be able to compile your 254 | source code. 255 | 256 | In general, I would suggest to **avoid** `git submodule`, and instead use the 257 | better `git subtree` (above). 258 | --------------------------------------------------------------------------------