From 16517a2be6b45c159301b6b81dc3d0d9fe9cd000 Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 25 Jun 2015 12:22:40 +0200 Subject: [PATCH 01/86] Makefile.pdlibbuilder version 0.0.0 --- Makefile.pdlibbuilder | 1138 +++++++++++++++++++++++++++++++++++++++++ README.md | 54 ++ 2 files changed, 1192 insertions(+) create mode 100644 Makefile.pdlibbuilder create mode 100644 README.md diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder new file mode 100644 index 0000000..56674ec --- /dev/null +++ b/Makefile.pdlibbuilder @@ -0,0 +1,1138 @@ +# Makefile.pdlibbuilder version 0.0.0, dated 2015-06-24 +# +# Helper makefile for Pure Data external libraries. +# Written by Katja Vetter March-June 2015 for the public domain. +# Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's +# ShakeNMake. +# +# GNU make version >= 3.81 required. +# +# +#=== characteristics =========================================================== +# +# +# - defines build settings based on autodetected OS and architecture +# - defines rules to build Pd class- or lib executables from C or C++ sources +# - defines rules for libdir installation +# - defines convenience targets for developer and user +# - evaluates implicit dependencies for non-clean builds +# +# +#=== basic usage =============================================================== +# +# +# In your Makefile, define your Pd lib name and class files, and include +# Makefile.pdlibbuilder at the end of the Makefile. Like so: +# +# ________________________________________________________________________ +# +# # Makefile for mylib +# +# lib.name = mylib +# +# class.sources = myclass1.c myclass2.c +# +# datafiles = myclass1-help.pd myclass2-help.pd +# +# include Makefile.pdlibbuilder +# ________________________________________________________________________ +# +# +# For files in class.sources it is assumed that class basename == source file +# basename. The default target builds all classes as individual executables +# with Pd's default extension for the platform. For anything more than the +# most basic usage, continue reading. +# +# +#=== list of Makefile.pdlibbuilder API variables =============================== +# +# +# Variables available for definition in your library Makefile: +# +# - lib.name +# - lib.setup.sources +# - class.sources +# - common.sources +# - shared.sources +# - .class.sources +# - .class.ldflags +# - .class.ldlibs +# - cflags +# - ldflags +# - ldlibs +# - datafiles +# - datadirs +# - makefiles +# - makefiledirs +# - externalsdir +# +# Variables avaialable for (re)definition via command arguments: +# +# - pdbinpath (Windows only) +# - pdincludepath +# - DESTDIR +# - prefix +# - libdir +# - pkglibdir +# - CFLAGS +# - CC +# - CXX +# - INSTALL +# - INSTALL_PROGRAM +# - INSTALL_DATA +# - INSTALL_DIR +# +# Variables available for your makefile or as command argument: +# +# - objectsdir +# - make-lib-executable +# - suppress-wunused +# +# +#=== descriptions of Makefile.pdlibbuilder API variables ======================= +# +# +# lib.name: +# Name of the library directory as it will be installed / distributed. Also the +# name of the lib executable in the case where all classes are linked into +# a single binary. +# +# lib.setup.sources: +# Source file(s) (C or C++) which must be compiled only when linking all classes +# into a single lib binary. +# +# class.sources: +# All sources files (C or C++) for which the condition holds that +# class name == source file basename. +# +# .class.sources: +# Source file(s) (C or C++) specific to class . Use this for +# multiple-source classes or when class name != source file basename. +# +# common.sources: +# Source file(s) which must be statically linked to each class in the library. +# +# shared.sources: +# Source file(s) (C or C++) to build a shared dynamic link lib, to be linked +# with all class executables. +# +# cflags, ldflags, ldlibs: +# Define cflags (preprocessor&compiler), ldflags (linker) and ldlibs (dynamic +# link libs) for the whole library. These flags are added to platform-specific +# flags defined by Makefile.pdlibbuilder. +# +# .class.ldflags and .class.ldlibs: +# Define ldflags resp. ldlibs specific to class . These flags are +# added to platform-specific flags defined by Makefile.pdlibbuilder, and flags +# defined in your Makefile for the whole library. Note: cflags can not be +# defined per class in the current implementation. +# +# datafiles and datadirs: +# All extra files you want to include in binary distributions of the +# library: abstractions and help patches, example patches, meta patch, readme +# and license texts, manuals, sound files, etcetera. Use 'datafiles' for all +# files that should go into your lib rootdir and 'datadirs' for complete +# directories you want to copy from source to distribution. +# +# externalsdir: +# Relative path to directory 'externals' in the context of pd-extended SVN, or +# any other centralized build layout for multiple libraries. Default value +# is '..', meaning the direct parent. The value is used in search paths for +# pd core components (header files, and executable in the case of Windows). +# +# makefiles and makefiledirs: +# Extra makefiles or directories with makefiles that should be made in sub-make +# processes. +# +# pdbinpath: +# For Windows only. Directory where pd.dll can be found for linking. +# +# pdincludepath: +# Directory where Pd API m_pd.h can be found, and other Pd header files. +# +# DESTDIR, prefix, libdir: +# Components of the path for installation as conventionally used on Linux. +# +# pkglibdir: +# Base path for installation of Pd library directories. Default is specified +# per OS, see section about paths below. +# +# objectsdir: +# Alias of pkglibdir. Can be defined in your makefile to enable project- +# dependent relative install locations. +# +# CFLAGS: +# Compiler (notably optimization) flags which are defined by +# Makefile.pdlibbuilder, but may be overriden via command argument. +# +# CC and CXX: +# C and C++ compiler programs as defined in your build environment. +# +# INSTALL, INSTALL_PROGRAM, INSTALL_DATA, INSTALL_DIR: +# Definitions of install program, may be overriden via command argument. +# +# make-lib-executable: +# When this variable is defined 'yes' in your makefile or as command argument, +# Makefile.pdlibbuilder will try to build all classes into a single library +# executable (but it will force exit if lib.setup.sources is undefined). +# If your makefile defines 'make-lib-executable=yes' as the library default, +# this can still be overriden with 'make-lib-executable=no' as command argument +# to build individual class executables (the Makefile.pdlibbuilder default.) +# +# suppress-wunused: +# When this variable is defined ('yes' or any other value), -Wunused-variable, +# -Wunused-parameter, -Wunused-value and -Wunused-function are suppressed, +# but the other warnings from -Wall are retained. +# +# +#=== paths ===================================================================== +# +# +# Source files in directories other than current working directory must be +# prefixed with their relative path. Do not rely on VPATH or vpath. +# Object (.o) files are built in the directory of their source files. +# Executables are built in current working directory. +# +# Variable 'pdincludepath' stores the location where m_pd.h was found. +# Locations where Makefile.pdlibbuilder tries to find it, in order of priority: +# +# any OS: $(externalsdir)../pd/src/ +# +# Linux: /usr/include/pdextended/ +# /usr/include/pd/ +# +# OSX: /Applications/Pd-extended.app/Contents/Resources/include/pdextended/ +# /Applications/Pd.app/Contents/Resources/src/ +# +# Windows: %PROGRAMFILES%/pd/include/pdextended/ +# %PROGRAMFILES%/pd/src/ +# +# The path for installation of all library components is constructed as: +# +# installpath := $(DESTDIR)$(objectsdir)/$(lib.name) +# +# Default for 'objectsdir' is defined per platform and follows this convention: +# https://puredata.info/docs/faq/how-do-i-install-externals-and-help-files +# +# Linux: /usr/local/lib/pd-externals +# OSX: ~/Library/Pd +# Windows: %APPDATA%/Pd +# +# The rationale for not installing to ~/pd-externals by default on Linux +# is that some people share the home dir between 32 and 64 bit installations. +# +# +#=== targets =================================================================== +# +# +# all: build classes (default) or library blob (if make-lib-executable=true) +# alldebug: build all with -g option turned on for debug symbols +# : force clean build of an individual class +# .pre: make preprocessor output file in current working directory +# .lst: make asm/source output file in current working directory +# +# install: install executables and data files +# dist: make source package for distribution (not yet implemented) +# dpkg-source: make debian source package (not yet implemented) +# +# clean: remove build products from source tree +# distclean: not yet implemented +# +# help: print help text +# vars: print makefile variables +# allvars: print all variables +# depend: print generated prerequisites +# coffee: dummy target +# +# +#=== Pd-extended libdir concept ================================================ +# +# +# For libdir layout as conceived by Hans-Christoph Steiner, see: +# +# https://puredata.info/docs/developer/Libdir +# +# Files README.txt, LICENSE.txt and -meta.pd are part of the libdir +# convention. Help patches for each class and abstraction are supposed to be +# available. Makefile.pdlibbuilder does not force the presence of these files +# however. It does not automatically include such files in libdir installations. +# Data files you want to include in distributions must be defined explicitly in +# your Makefile. +# +# +#=== Makefile.pdlibbuilder syntax conventions ================================== +# +# +# Makefile.pdlibbuilder variable names are lower case. Default make variables, +# environment variables, and standard user variables (CC, CXX, CFLAGS, DESTDIR) +# are upper case. Use target 'allvars' to print all variables and their values. +# +# 'Fields' in data variables are separated by dots, like in 'foo.class.sources'. +# Words in variables expressing a function or command are separated by dashes, +# like in 'make-lib-executable'. +# +# +#=== useful make options ======================================================= +# +# +# Use 'make -d ' to print debug details of the make process. +# Use 'make -p ' to print make's database. +# +# +#=== TODO ====================================================================== +# +# +# - decide whether to use -static-libgcc or shared dll in MinGW +# - cygwin support +# - android support +# - Windows 64 bit support +# - makefile template targets: dpkg-source dist libdir distclean tags +# - figure out how to handle '$' in filenames +# +# +# +#=== end of documentation sections ============================================= +# +# +################################################################################ +################################################################################ +################################################################################ + + +# GNU make version 3.81 (2006) or higher is required because of the following: +# - function 'info' +# - variable '.DEFAULT_GOAL' + +# force exit when make version is < 3.81 +ifneq ($(firstword $(sort 3.81 $(MAKE_VERSION))), 3.81) + $(error GNU make version 3.81 or higher is required) +endif + +# Relative path to externals root dir in multi-lib source tree like +# pd-extended SVN. Default is parent of current working directory. May be +# defined differently in including makefile. This variable is used to probe for +# paths. +externalsdir ?= .. + +# variable you can use to check if Makefile.pdlibbuilder is already included +Makefile.pdlibbuilder = true + + +################################################################################ +### variables: files ########################################################### +################################################################################ + + +# strip possibles spaces from lib.name, they mess up calculated file names +lib.name := $(strip $(lib.name)) + + +#=== sources =================================================================== + + +# (re)define .class.sources using file names in class.sources + +define add-class-source +$(notdir $(basename $v)).class.sources += $v +endef + +$(foreach v, $(class.sources), $(eval $(add-class-source))) + +# derive class names from .class.sources variables +sourcevariables := $(filter %.class.sources, $(.VARIABLES)) +classes := $(basename $(basename $(sourcevariables))) + +# accumulate all source files specified in makefile +classes.sources := $(sort $(foreach v, $(sourcevariables), $($v))) +all.sources := $(classes.sources) $(lib.setup.sources) \ + $(shared.sources) $(common.sources) + + +#=== object files ============================================================== + + +# construct object filenames from all C and C++ source file names +classes.objects := $(addsuffix .o, $(basename $(classes.sources))) +common.objects := $(addsuffix .o, $(basename $(common.sources))) +shared.objects := $(addsuffix .o, $(basename $(shared.sources))) +lib.setup.objects := $(addsuffix .o, $(basename $(lib.setup.sources))) +all.objects = $(classes.objects) $(common.objects) $(shared.objects) \ + $(lib.setup.objects) + + +#=== executables =============================================================== + + +# use recursive variables here because executable extension is not yet known + +# construct class executable names from class names +classes.executables = $(addsuffix .$(extension), $(classes)) + +# construct shared lib executable name if shared sources are defined +ifdef shared.sources + shared.lib = lib$(lib.name).$(shared.extension) +else + shared.lib = +endif + + +################################################################################ +### variables per platform ##################################################### +################################################################################ + + +#=== flags per architecture ==================================================== + + +# Set architecture-dependent flags, mainly for Linux. For Mac and Windows, +# arch.flags are overriden below. + +machine := $(shell uname -m) + +# Raspberry Pi 1st generation +ifeq ($(machine), armv6l) + arch.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard +endif + +# Beagle, Udoo, RPi2 etc. +ifeq ($(machine), armv7l) + arch.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard +endif + +# Intel 32 bit, build with SSE and SSE2 instructions +ifeq ($(findstring $(machine), i386 i686), $(machine)) + arch.flags = -march=pentium4 -mfpmath=sse -msse -msse2 +endif + +# Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions +ifeq ($(findstring $(machine), ia64 x86_64), $(machine)) + arch.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 +endif + + +#=== operating system ========================================================== + + +# The following systems are defined: Linux, Darwin, Windows. GNU and +# GNU/kFreeBSD are treated as Linux to get the same options. + +uname := $(shell uname) + +ifeq ($(findstring $(uname), Linux GNU GNU/kFreeBSD), $(uname)) + system = Linux +endif + +ifeq ($(uname), Darwin) + system = Darwin +endif + +ifeq ($(findstring MINGW, $(uname)), MINGW) + system = Windows +endif + +# TODO: Cygwin, Android + + +#=== flags and paths for Linux ================================================= + + +ifeq ($(system), Linux) + prefix = /usr/local + libdir := $(prefix)/lib + pkglibdir = $(libdir)/pd-externals + pdincludepath := $(firstword $(dir $(wildcard \ + $(externalsdir)/../pd/src/m_pd.h \ + /usr/include/pdextended/m_pd.h \ + /usr/include/pd/m_pd.h))) + extension = pd_linux + cpp.flags := -DUNIX + c.flags := -fpic + c.ldflags := -rdynamic -shared -fpic -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags + c.ldlibs := -lc -lm + cxx.flags := -fpic -fcheck-new + cxx.ldflags := -rdynamic -shared -fpic -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags + cxx.ldlibs := -lc -lm -lstdc++ + shared.extension = so + shared.ldflags := -rdynamic -fpic -shared -Wl,-soname,$(shared.lib) + stripflags = --strip-unneeded -R .note -R .comment +endif + + +#=== flags and paths for Darwin ================================================ + + +# On OSX we try to build fat binaries by default. It is assumed that OSX i386 +# can build for ppc and OSX x86_64 can't. TODO: try to refine this condition. +# LLVM-clang doesn't support -fcheck-new, therefore this flag is omitted for +# OSX x86_64. + +ifeq ($(system), Darwin) + pkglibdir = $(HOME)/Library/Pd + pdincludepath := $(firstword $(dir $(wildcard \ + $(externalsdir)/../pd/src/m_pd.h \ + /Applications/Pd-extended.app/Contents/Resources/include/pdextended/m_pd.h \ + /Applications/Pd.app/Contents/Resources/src/m_pd.h))) + extension = pd_darwin + arch.flags = + cpp.flags := -DUNIX -DMACOSX -I /sw/include + c.flags := + c.ldflags := -undefined suppress -flat_namespace -bundle + c.ldlibs := -lc + cxx.ldflags := -undefined suppress -flat_namespace -bundle + cxx.ldlibs := -lc + shared.extension = dylib + shared.ldflags = -dynamiclib -undefined dynamic_lookup \ + -install_name @loader_path/$(shared.lib) \ + -compatibility_version 1 -current_version 1.0 + stripflags = -x + ifeq ($(machine), i386) + cxx.flags := -fcheck-new + arch.flags := -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 + endif + ifeq ($(machine), x86_64) + arch.flags := -arch i386 -arch x86_64 -mmacosx-version-min=10.5 + endif +endif + + +#=== flags and paths for Windows =============================================== + + +# Standard paths on Windows contain spaces, and GNU make functions treat such +# paths as lists, with unintended effects. Therefore we must use shell function +# ls instead of make's wildcard, and probe for each standard path individually. +# Using double quotes around paths with spaces is obligatory. Since some path +# variables are assembled or re-expanded later, great care must be taken to put +# quotes at appropriate points throughout the makefile. Thanks, Bill. + +# paths for 32-bit executables on 64-bit Windows aren't yet defined here (TODO) +ifeq ($(system), Windows) + pkglibdir := $(APPDATA)/Pd + pdbinpath := $(wildcard $(externalsdir)/../pd/bin/) + pdincludepath := $(wildcard $(externalsdir)/../pd/src/) + ifndef pdbinpath + pdbinpath := $(shell ls -d "$(PROGRAMFILES)/pd/bin/") + endif + ifndef pdincludepath + pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/include/pdextended/") + endif + ifndef pdincludepath + pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/src/") + endif +endif + +# On Windows we build 32 bit by default to match Pd(-extended) binary +# distributions. This may change in the future. +# TODO: decide whether -mms-bitfields should be specified. +ifeq ($(system), Windows) + extension = dll + CC = gcc + CXX = g++ + arch.flags := -march=pentium4 -msse -msse2 -mfpmath=sse + cpp.flags := -DMSW -DNT + c.flags := + c.ldflags := -static-libgcc -shared \ + -Wl,--enable-auto-import "$(pdbinpath)pd.dll" + c.ldlibs := + cxx.flags := -fcheck-new + cxx.ldflags := -static-libstdc++ -shared \ + -Wl,--enable-auto-import "$(pdbinpath)pd.dll" + cxx.ldlibs := + shared.extension = dll + shared.ldflags := -static-libgcc -shared "$(pdbinpath)pd.dll" + stripflags = --strip-unneeded -R .note -R .comment +endif + + +#=== paths ===================================================================== + + +# Default pkglibdir is specified above per operating system. It is aliased as +# 'objectsdir' to retain compatibility with pd-extended template. Assignment +# operator '?=' is used to enable a project-relative path definition in the +# including makefile. +objectsdir ?= $(pkglibdir) + +# base path where all components of the lib will be installed by default +installpath := $(DESTDIR)$(objectsdir)/$(lib.name) + +# check if pdincludepath contains spaces (as is often the case on Windows) +# if so, store the path so we can later do checks with it +pdincludepathwithspaces := $(if $(word 2, $(pdincludepath)), $(pdincludepath)) + + +#=== accumulated build flags =================================================== + + +# From GNU make docs: 'Users expect to be able to specify CFLAGS freely +# themselves.' So we use CFLAGS to define platform-independent options which +# are not strictly required for compilation: optimizations and warnings. CFLAGS +# can be safely overriden using a make command argument. +# Variables cflags, ldflags and ldlibs may be defined in including makefile. + +optimization.flags = -O3 -ffast-math -funroll-loops -fomit-frame-pointer +warn.flags = -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing + +# suppress -Wunused-variable & Co if you don't want to clutter a build log +ifdef suppress-wunused + warn.flags += $(addprefix -Wno-unused-, function parameter value variable) +endif + +CFLAGS = $(warn.flags) $(optimization.flags) + +# preprocessor flags +cpp.flags += -DPD -I "$(pdincludepath)" + +# flags for C compiler / linker +c.flags := $(cpp.flags) $(c.flags) $(cflags) $(CFLAGS) +c.ldflags := $(c.ldflags) $(ldflags) +c.ldlibs := $(c.ldlibs) $(ldlibs) + +# flags for C++ compiler / linker +cxx.flags := $(cpp.flags) $(cxx.flags) $(cflags) $(CFLAGS) +cxx.ldflags := $(cxx.ldflags) $(ldflags) +cxx.ldlibs := $(cxx.ldlibs) $(ldlibs) + + +################################################################################ +### variables: tools ########################################################### +################################################################################ + + +# aliases so we can later define 'compile-$1' and set 'c' or 'cxx' as argument +compile-c := $(CC) +compile-cxx := $(CXX) + + +################################################################################ +### checks ##################################################################### +################################################################################ + + +# At this point most variables are defined. Now do some checks and info's +# before rules begin. + +# 'forward declaration' of default target, needed to do checks +all: + +# To avoid unpredictable results, make sure the default target is not redefined +# by including makefile. +ifneq ($(.DEFAULT_GOAL), all) + $(error Default target must be 'all'.) +endif + +# find out which target(s) will be made +ifdef MAKECMDGOALS + goals := $(MAKECMDGOALS) +else + goals := all +endif + +# check if m_pd.h is found and print info about it +$(if $(shell ls "$(pdincludepath)m_pd.h"), \ + $(info ++++ info: using Pd API $(pdincludepath)m_pd.h), \ + $(warning Where is your m_pd.h? Do 'make help' for info.)) + +# print target info +$(info ++++ info: making target $(goals) $(if $(lib.name),in lib $(lib.name))) + +# when installing, print installpath info +$(if $(filter install install-lib, $(goals)), $(info ++++ info: \ + installpath is '$(installpath)')) + + +#=== define executables ======================================================== + + +# By default we build class executables, and optionally a shared dynamic link +# lib. When make-lib-executable=yes we build all classes into a single lib +# executable, on the condition that variable lib.setup.sources is defined. + +ifeq ($(make-lib-executable),yes) + $(if $(lib.setup.sources), ,\ + $(error Can not build library blob because lib.setup.sources is undefined)) + executables := $(lib.name).$(extension) +else + executables := $(classes.executables) $(shared.lib) +endif + + +#=== library version =========================================================== + + +# if meta file exists, check library version + +metafile := $(wildcard $(lib.name)-meta.pd) + +ifdef metafile + lib.version := $(shell sed -n \ + 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \ + $(lib.name)-meta.pd) +endif + + +################################################################################ +### rules: special targets ##################################################### +################################################################################ + + +# Disable built-in rules. If some target can't be built with the specified +# rules, it should not be built at all. +MAKEFLAGS += --no-builtin-rules + +.PRECIOUS: +.SUFFIXES: +.PHONY: all build-classes build-lib $(classes) $(makefiledirs) $(makefiles)\ + install install-executables install-datafiles install-datadirs \ + force clean vars allvars depend help + + +################################################################################ +### rules: build targets ####################################################### +################################################################################ + + +# target all builds class executables plus optional shared lib +# or alternatively a single lib executable when make-lib-executable=true +all: $(executables) + $(info ++++ info: $(if $(executables),executables in $(lib.name) completed)) + +# build all with -g option turned on for debug symbols +alldebug: c.flags += -g +alldebug: cxx.flags += -g +alldebug: all + + +#=== class executable ========================================================== + + +# recipe for linking objects in class executable +# argument $1 = compiler type (c or cxx) +# argument $2 = class basename +define link-class + $(compile-$1) \ + $(arch.flags) \ + $($1.ldflags) $($2.class.ldflags) \ + -o $2.$(extension) \ + $(addsuffix .o, $(basename $($2.class.sources))) \ + $(addsuffix .o, $(basename $(common.sources))) \ + $($1.ldlibs) $($2.class.ldlibs) $(shared.lib) +endef + +# general rule for linking object files in class executable +%.$(extension): $(shared.lib) + $(info ++++ info: linking objects in $@ for lib $(lib.name)) + $(if $(filter %.cc %.cpp, $($*.class.sources)), \ + $(call link-class,cxx,$*), \ + $(call link-class,c,$*)) + + +#=== library blob ============================================================== + + +# build all classes into single executable +build-lib: $(lib.name).$(extension) + $(info ++++ info: library blob $(lib.name).$(extension) completed) + +# recipe for linking objects in lib executable +# argument $1 = compiler type (c or cxx) +define link-lib + $(compile-$1) \ + $(arch.flags) \ + $($1.ldflags) $(lib.ldflags) \ + -o $(lib.name).$(extension) $(all.objects) \ + $($1.ldlibs) $(lib.ldlibs) +endef + +# rule for linking objects in lib executable +# declared conditionally to avoid name clashes +ifeq ($(make-lib-executable),yes) +$(lib.name).$(extension): $(all.objects) + $(if $(filter %.cc %.cpp, $(all.sources)), \ + $(call link-lib,cxx), \ + $(call link-lib,c)) +endif + + +#=== shared dynamic lib ======================================================== + + +# recipe for linking objects in shared executable +# argument $1 = compiler type (c or cxx) +define link-shared + $(compile-$1) \ + $(arch.flags) \ + $(shared.ldflags) \ + -o lib$(lib.name).$(shared.extension) $(shared.objects) \ + $($1.ldlibs) $(shared.ldlibs) +endef + +# rule for linking objects in shared executable +# build recipe is in macro 'link-shared' +lib$(lib.name).$(shared.extension): $(shared.objects) + $(info ++++ info: linking objects in shared lib $@) + $(if $(filter %.cc %.cpp, $(shared.sources)), \ + $(call link-shared,cxx), \ + $(call link-shared,c)) + + +#=== object files ============================================================== + + +# recipe to make .o file from source +# argument $1 is compiler type (c or cxx) +define make-object-file + $(info ++++ info: making $@ in lib $(lib.name)) + $(compile-$1) \ + $($1.flags) \ + $(arch.flags) -o $@ -c $< +endef + +# Three rules to create .o files. These are double colon 'terminal' rules, +# meaning they are the last in a rules chain. + +%.o:: %.c + $(call make-object-file,c) + +%.o:: %.cc + $(call make-object-file,cxx) + +%.o:: %.cpp + $(call make-object-file,cxx) + + +#=== explicit prerequisites for class executables ============================== + + +# For class executables, prerequisite rules are declared in run time. Target +# 'depend' prints these rules for debugging purposes. + +# declare explicit prerequisites rule like 'class: class.extension' +# argument $v is class basename +define declare-class-target +$v: $v.$(extension) +endef + +# declare explicit prerequisites rule like 'class.extension: object1.o object2.o' +# argument $v is class basename +define declare-class-executable-target +$v.$(extension): $(addsuffix .o, $(basename $($v.class.sources))) \ + $(addsuffix .o, $(basename $(common.sources))) +endef + +# evaluate explicit prerequisite rules for all classes +$(foreach v, $(classes), $(eval $(declare-class-target))) +$(foreach v, $(classes), $(eval $(declare-class-executable-target))) + + +#=== implicit prerequisites for class executables ============================== + + +# Evaluating implicit prerequisites (header files) with help from the +# preprocessor is 'expensive' so this is done conditionally and selectively. +# Note that it is also possible to trigger a build via install targets, in +# which case implicit prerequisites are not checked. + +# When the Pd include path contains spaces it will mess up the implicit +# prerequisites rules so we do not evaluate them in that case. + +ifndef pdincludepathwithspaces + must-build-everything := $(filter all default lib, $(goals)) + must-build-class := $(filter $(classes), $(goals)) + must-build-sources := $(foreach v, $(must-build-class), $($v.class.sources)) +endif + +# declare implicit prerequisites rule like 'object.o: header1.h header2.h ...' +# argument $1 is input source file(s) +define declare-object-target +$(filter %.o: %.h, $(shell $(CPP) $(c.flags) -MM $1)) $(MAKEFILE_LIST) +endef + +# evaluate implicit prerequisite rules when rebuilding everything +ifdef must-build-everything + $(if $(wildcard $(all.objects)), \ + $(info ++++ info: evaluating implicit prerequisites in lib $(lib.name).....) \ + $(foreach v, $(all.sources), $(eval $(call declare-object-target, $v)))) +endif + +# evaluate implicit prerequisite rules when selectively building classes +ifdef must-build-class + $(foreach v, $(must-build-sources), \ + $(eval $(call declare-object-target, $v))) + $(foreach v, $(shared.sources), \ + $(eval $(call declare-object-target, $v))) +endif + + +################################################################################ +### rules: preprocessor and assembly files ##################################### +################################################################################ + + +# Preprocessor and assembly output files for bug tracing etc. They are not part +# of the build processes for executables. By default these files are created in +# the current working directory. Dependency tracking is not performed, the build +# is forced instead to make sure it's up to date. + +force: + + +#=== preprocessor file ========================================================= + + +# make preprocessor output file with extension .pre +# argument $1 = compiler type (c or cxx) +define make-preprocessor-file + $(info ++++ info: making preprocessor output file $(notdir $*.pre) \ + in current working directory) + $(compile-$1) -E $< $(c.flags) $($1.flags) -o $(notdir $*.pre) +endef + +%.pre:: %.c force + $(call make-preprocessor-file,c) + +%.pre:: %.cc force + $(call make-preprocessor-file,cxx) + +%.pre:: %.cpp force + $(call make-preprocessor-file,cxx) + + +#=== assembly file ============================================================= + + +# make C / assembly interleaved output file with extension .lst +# argument $1 = compiler type (c or cxx) +define make-assembly-file + $(info ++++ info: making assembly output file $(notdir $*.lst) \ + in current working directory) + $(compile-$1) \ + -c -Wa,-a,-ad -fverbose-asm \ + $($1.flags) \ + $(arch.flags) \ + $< > $(notdir $*.lst) +endef + +%.lst:: %.c force + $(call make-assembly-file,c) + +%.lst:: %.cc force + $(call make-assembly-file,cxx) + +%.lst:: %.cpp force + $(call make-assembly-file,cxx) + + +################################################################################ +### rules: installation targets ################################################ +################################################################################ + + +# Install targets depend on successful exit status of target all because nothing +# must be installed in case of a build error. + + +# -p = preserve time stamps +# -m = set permission mode (as in chmod) +# -d = create all components of specified directories +INSTALL = install +INSTALL_PROGRAM := $(INSTALL) -p -m 644 +INSTALL_DATA := $(INSTALL) -p -m 644 +INSTALL_DIR := $(INSTALL) -m 755 -d + +# strip spaces from file names +executables := $(strip $(executables)) +datafiles := $(strip $(datafiles)) +datadirs := $(strip $(datadirs)) + +# Do not make any install sub-target with empty variable definition because the +# install program would exit with an error. +install: $(if $(executables), install-executables) +install: $(if $(datafiles), install-datafiles) +install: $(if $(datadirs), install-datadirs) + +install-executables: all + $(INSTALL_DIR) -v "$(installpath)" + $(INSTALL_PROGRAM) $(executables) "$(installpath)" + $(info ++++ info: executables of lib $(lib.name) installed \ + from $(CURDIR) to $(installpath)) + +install-datafiles: all + $(INSTALL_DIR) -v "$(installpath)" + $(INSTALL_DATA) $(datafiles) "$(installpath)" + $(info ++++ info: data files of lib $(lib.name) installed \ + from $(CURDIR) to $(installpath)) + +install-datadirs: all + $(foreach v, $(datadirs), $(INSTALL_DIR) "$(installpath)/$v";) + $(foreach v, $(datadirs), \ + $(INSTALL_DATA) $(wildcard $v/*) "$(installpath)/$v";) + $(info ++++ info: data directories of lib $(lib.name) installed \ + from $(CURDIR) to $(installpath)) + + +################################################################################ +### rules: distribution targets ################################################ +################################################################################ + + +# TODO +# These targets are implemented in Makefile Template, but I have to figure out +# how to do it under the not-so-strict conditions of Makefile.pdlibbuilder. + +# make source package +dist: + @echo "target dist not yet implemented" + +# make Debian source package +dpkg-source: + @echo "target dpkg-source not yet implemented" + +$(ORIGDIR): + +$(DISTDIR): + + +################################################################################ +### rules: clean targets ####################################################### +################################################################################ + + +# delete build products from build tree +clean: + rm -f $(all.objects) + rm -f $(classes.executables) $(lib.name).$(extension) $(shared.lib) + rm -f *.pre *.lst + +# remove distribution directories and tarballs from build tree +distclean: clean + @echo "target distclean not yet implemented" + + +################################################################################ +### rules: submake targets ##################################################### +################################################################################ + + +# Iterate over sub-makefiles or makefiles in other directories. + +# When 'continue-make=yes' is set, sub-makes will report 'true' to the parent +# process regardless of their real exit status. This prevents the parent make +# from being aborted by a sub-make error. Useful when you want to quickly find +# out which sub-makes from a large set will succeed. +ifeq ($(continue-make),yes) + continue = || true +endif + +# These targets will trigger sub-make processes for entries in 'makefiledirs' +# and 'makefiles'. +all alldebug install clean distclean dist dkpg-source: \ + $(makefiledirs) $(makefiles) + +# this expands to identical rules for each entry in 'makefiledirs' +$(makefiledirs): + $(MAKE) --directory=$@ $(MAKECMDGOALS) $(continue) + +# this expands to identical rules for each entry in 'makefiles' +$(makefiles): + $(MAKE) --directory=$(dir $@) --makefile=$(notdir $@) $(MAKECMDGOALS) $(continue) + + +################################################################################ +### rules: convenience targets ################################################# +################################################################################ + + +#=== show variables ============================================================ + + +# Several 'function' macro's cause errors when expanded within a rule or without +# proper arguments. Variables which are set with the define directive are only +# shown by name for that reason. +functions = \ +add-class-source \ +declare-class-target \ +declare-class-executable-target \ +declare-object-target \ +link-class \ +link-lib \ +link-shared \ +make-object-file \ +make-preprocessor-file \ +make-assembly-file + + +# show variables from makefiles +vars: + $(info ++++ info: showing makefile variables:) + $(foreach v,\ + $(sort $(filter-out $(functions) functions, $(.VARIABLES))),\ + $(if $(filter file, $(origin $v)),\ + $(info variable $v = $($v)))) + $(foreach v, $(functions), $(info 'function' name: $v)) + @echo + +# show all variables +allvars: + $(info ++++ info: showing default, automatic and makefile variables:) + $(foreach v, \ + $(sort $(filter-out $(functions) functions, $(.VARIABLES))), \ + $(info variable ($(origin $v)) $v = $($v))) + $(foreach v, $(functions), $(info 'function' name: $v)) + @echo + + +#=== show dependencies ========================================================= + + +# show generated prerequisites rules +depend: + $(info ++++ info: generated prerequisite rules) + $(foreach v, $(classes), $(info $(declare-class-target))) + $(foreach v, $(classes), $(info $(declare-class-executable-target))) + $(foreach v, $(all.sources), $(info $(call declare-object-target, $v))) + @echo + + +#=== show help text ============================================================ + + +# brief info about targets and paths + +mpdh := $(shell ls "$(pdincludepath)m_pd.h") +mpdh := $(if $(mpdh), $(mpdh), m_pd.h not found. Is Pd(-extended) installed?) + + +help: + @echo + @echo " Main targets:" + @echo " all: build executables (default target)" + @echo " install: install all components of the library" + @echo " vars: print makefile variables for troubleshooting" + @echo " allvars: print all variables for troubleshooting" + @echo " help: print this help text" + @echo + @echo " Pd API m_pd.h:" + @echo " $(shell ls "$(pdincludepath)m_pd.h")" + @echo " You may specify your preferred include path as argument to" + @echo " the make command, like 'pdincludepath=path/to/pd/src'." + @echo + @echo " Path for installation of your libdir(s):" + @echo " $(objectsdir)" + @echo " Alternatively you may specify your path for installation as argument" + @echo " to the make command, like 'objectsdir=path/to/pd-externals'." + @echo " For detailed info read the doc sections in Makefile.pdlibbuilder." + @echo + + +#=== dummy target ============================================================== + + +coffee: + @echo "Makefile.pdlibbuilder: Can not make coffee. Sorry." + + +################################################################################ +### the end #################################################################### +################################################################################ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf5b7d8 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ + + +### Makefile.pdlibbuilder ### + +Helper makefile for Pure Data external libraries. +Written by Katja Vetter March-June 2015 for the public domain. +Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's +ShakeNMake. + +GNU make version >= 3.81 required. + + +### characteristics ### + + +* defines build settings based on autodetected OS and architecture +* defines rules to build Pd class- or lib executables from C or C++ sources +* defines rules for libdir installation +* defines convenience targets for developer and user +* evaluates implicit dependencies for non-clean builds + + +### basic usage ### + + +In your Makefile, define your Pd lib name and class files, and include +Makefile.pdlibbuilder at the end of the Makefile. Like so: + + + # Makefile for mylib + + lib.name = mylib + + class.sources = myclass1.c myclass2.c + + datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENCE.txt + + include Makefile.pdlibbuilder + + +For files in class.sources it is assumed that class basename == source file +basename. The default target builds all classes as individual executables +with Pd's default extension for the platform. For anything more than the +most basic usage, read the documentation sections in Makefile.pdlibbuilder. + + +### examples ### + + +Here is one deployment example of the Makefile.pdlibbuilder approach: + +http://sourceforge.net/p/pure-data/svn/HEAD/tree/trunk/externals/miXed/cyclone/Makefile.cyclone + +More examples will be referenced here when they are available. From 9c7e50126638d7694acc293770d0de15f548a8c8 Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 25 Jun 2015 12:35:26 +0200 Subject: [PATCH 02/86] changed some comments --- Makefile.pdlibbuilder | 13 ++++--------- README.md | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 56674ec..86e89f0 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,7 +1,7 @@ -# Makefile.pdlibbuilder version 0.0.0, dated 2015-06-24 +# Makefile.pdlibbuilder version 0.0.0, dated 2015-06-25 # # Helper makefile for Pure Data external libraries. -# Written by Katja Vetter March-June 2015 for the public domain. +# Written by Katja Vetter March-June 2015 for the public domain. No warranties. # Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's # ShakeNMake. # @@ -32,7 +32,7 @@ # # class.sources = myclass1.c myclass2.c # -# datafiles = myclass1-help.pd myclass2-help.pd +# datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENCE.txt # # include Makefile.pdlibbuilder # ________________________________________________________________________ @@ -232,11 +232,7 @@ # .lst: make asm/source output file in current working directory # # install: install executables and data files -# dist: make source package for distribution (not yet implemented) -# dpkg-source: make debian source package (not yet implemented) -# # clean: remove build products from source tree -# distclean: not yet implemented # # help: print help text # vars: print makefile variables @@ -286,9 +282,8 @@ # - cygwin support # - android support # - Windows 64 bit support -# - makefile template targets: dpkg-source dist libdir distclean tags # - figure out how to handle '$' in filenames -# +# - add makefile template targets dpkg-source dist libdir distclean tags? # # #=== end of documentation sections ============================================= diff --git a/README.md b/README.md index cf5b7d8..fdf30fe 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### Makefile.pdlibbuilder ### Helper makefile for Pure Data external libraries. -Written by Katja Vetter March-June 2015 for the public domain. +Written by Katja Vetter March-June 2015 for the public domain. No warranties. Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's ShakeNMake. From 3906a92933f7b64e2ac7915defb4c06574e7780f Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 25 Jun 2015 19:43:17 +0200 Subject: [PATCH 03/86] corrected futile typo in comment --- Makefile.pdlibbuilder | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 86e89f0..91fb819 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -32,7 +32,7 @@ # # class.sources = myclass1.c myclass2.c # -# datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENCE.txt +# datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt # # include Makefile.pdlibbuilder # ________________________________________________________________________ diff --git a/README.md b/README.md index fdf30fe..bda994f 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Makefile.pdlibbuilder at the end of the Makefile. Like so: class.sources = myclass1.c myclass2.c - datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENCE.txt + datafiles = myclass1-help.pd myclass2-help.pd README.txt LICENSE.txt include Makefile.pdlibbuilder From 9e1fa90567f774c8a1f95ce197776fa5296948d0 Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 25 Jun 2015 19:53:17 +0200 Subject: [PATCH 04/86] added vim modeline for syntax highlighting --- Makefile.pdlibbuilder | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 91fb819..bc6cad6 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1128,6 +1128,10 @@ coffee: ################################################################################ -### the end #################################################################### +### end of rules sections ###################################################### ################################################################################ + +# for syntax highlighting in vim and github +# vim: set filetype=make + From b43f7ad2b3f6c10e5d417e72880874ce67a25bb6 Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 25 Jun 2015 19:59:43 +0200 Subject: [PATCH 05/86] another try at syntax highlighting modeline --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index bc6cad6..79f2d51 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1133,5 +1133,5 @@ coffee: # for syntax highlighting in vim and github -# vim: set filetype=make +# vim: set filetype=make: From 84ae43edc872cc46ddd5064a03ad512788a22841 Mon Sep 17 00:00:00 2001 From: katja Date: Mon, 6 Jul 2015 23:30:28 +0200 Subject: [PATCH 06/86] Added reference to helloworld project in README.md. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bda994f..5e0c2a6 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Makefile.pdlibbuilder at the end of the Makefile. Like so: include Makefile.pdlibbuilder -For files in class.sources it is assumed that class basename == source file +For files in class.sources it is assumed that class name == source file basename. The default target builds all classes as individual executables with Pd's default extension for the platform. For anything more than the most basic usage, read the documentation sections in Makefile.pdlibbuilder. @@ -47,7 +47,9 @@ most basic usage, read the documentation sections in Makefile.pdlibbuilder. ### examples ### -Here is one deployment example of the Makefile.pdlibbuilder approach: +Here are two projects using the Makefile.pdlibbuilder approach: + +https://github.com/pure-data/helloworld http://sourceforge.net/p/pure-data/svn/HEAD/tree/trunk/externals/miXed/cyclone/Makefile.cyclone From 0a7d0573419ff1f72aa0d36827a23c0250a08f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?uml=C3=A4ute?= Date: Thu, 29 Oct 2015 00:31:08 +0100 Subject: [PATCH 07/86] use $(metafile) in version expansion lib.version is only expanded if the file named by $(metafile) exists, but then it uses a hardcoded filename to do the actual expansion. this patch uses $(metafile) to do the expansion instead. --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 79f2d51..31510f1 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -662,7 +662,7 @@ metafile := $(wildcard $(lib.name)-meta.pd) ifdef metafile lib.version := $(shell sed -n \ 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \ - $(lib.name)-meta.pd) + $(metafile)) endif From 9015ba7b9fcb55687fd415029aefe062881c5337 Mon Sep 17 00:00:00 2001 From: katja Date: Sat, 31 Oct 2015 20:56:29 +0100 Subject: [PATCH 08/86] fix expansion of variable lib.version in cflags during compilation --- Makefile.pdlibbuilder | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 31510f1..190938d 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -314,13 +314,27 @@ Makefile.pdlibbuilder = true ################################################################################ -### variables: files ########################################################### +### variables: library name and version ######################################## ################################################################################ # strip possibles spaces from lib.name, they mess up calculated file names lib.name := $(strip $(lib.name)) +# if meta file exists, check library version +metafile := $(wildcard $(lib.name)-meta.pd) + +ifdef metafile + lib.version := $(shell sed -n \ + 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \ + $(metafile)) +endif + + +################################################################################ +### variables: files ########################################################### +################################################################################ + #=== sources =================================================================== @@ -652,20 +666,6 @@ else endif -#=== library version =========================================================== - - -# if meta file exists, check library version - -metafile := $(wildcard $(lib.name)-meta.pd) - -ifdef metafile - lib.version := $(shell sed -n \ - 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' \ - $(metafile)) -endif - - ################################################################################ ### rules: special targets ##################################################### ################################################################################ From 974b6174ce1de9546f58e96b4542914488df0dc5 Mon Sep 17 00:00:00 2001 From: katja Date: Sat, 31 Oct 2015 21:04:36 +0100 Subject: [PATCH 09/86] bump version to 0.0.1 --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 190938d..b97e2b5 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,4 +1,4 @@ -# Makefile.pdlibbuilder version 0.0.0, dated 2015-06-25 +# Makefile.pdlibbuilder version 0.0.1, dated 2015-10-31 # # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. From 164d29478877cc589a4206925fe75efbb766f59e Mon Sep 17 00:00:00 2001 From: katja Date: Fri, 4 Dec 2015 15:34:04 +0100 Subject: [PATCH 10/86] Evaluate optional per-system multiline defines --- Makefile.pdlibbuilder | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index b97e2b5..598cda9 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -66,6 +66,13 @@ # - makefiledirs # - externalsdir # +# Optional multiline defines evaluated per operating system: +# +# - forLinux +# - forDarwin +# - forWindows +# +# # Variables avaialable for (re)definition via command arguments: # # - pdbinpath (Windows only) @@ -140,6 +147,13 @@ # is '..', meaning the direct parent. The value is used in search paths for # pd core components (header files, and executable in the case of Windows). # +# forLinux, forDarwin, forWindows: +# Shorthand for 'variable definitions for Linux only' etc. Use like: +# define forLinux +# cflags += -DLINUX +# class.sources += linuxthing.c +# endef +# # makefiles and makefiledirs: # Extra makefiles or directories with makefiles that should be made in sub-make # processes. @@ -423,20 +437,25 @@ endif # The following systems are defined: Linux, Darwin, Windows. GNU and -# GNU/kFreeBSD are treated as Linux to get the same options. +# GNU/kFreeBSD are treated as Linux to get the same options. System-specific +# multiline defines (optionally set in library makefile) are conditionally +# evaluated here. uname := $(shell uname) ifeq ($(findstring $(uname), Linux GNU GNU/kFreeBSD), $(uname)) system = Linux + $(eval $(forLinux)) endif ifeq ($(uname), Darwin) system = Darwin + $(eval $(forDarwin)) endif ifeq ($(findstring MINGW, $(uname)), MINGW) system = Windows + $(eval $(forWindows)) endif # TODO: Cygwin, Android From 589d7fcda6ee17542ab75854ea824970b10248d7 Mon Sep 17 00:00:00 2001 From: katja Date: Sat, 5 Dec 2015 11:31:43 +0100 Subject: [PATCH 11/86] Use CPPFLAGS, CFLAGS and LDFLAGS to override/add build flags This commit reorganizes the accumulation of build flags in such a way that non-obligatory build flags can be overriden or added by specifying CPPFLAGS, CFLAGS and LDFLAGS as arguments from command line or environment. --- Makefile.pdlibbuilder | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index b97e2b5..1c214b7 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -393,29 +393,29 @@ endif #=== flags per architecture ==================================================== -# Set architecture-dependent flags, mainly for Linux. For Mac and Windows, -# arch.flags are overriden below. +# Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, +# arch.c.flags are overriden below. machine := $(shell uname -m) # Raspberry Pi 1st generation ifeq ($(machine), armv6l) - arch.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard + arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard endif # Beagle, Udoo, RPi2 etc. ifeq ($(machine), armv7l) - arch.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard + arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard endif # Intel 32 bit, build with SSE and SSE2 instructions ifeq ($(findstring $(machine), i386 i686), $(machine)) - arch.flags = -march=pentium4 -mfpmath=sse -msse -msse2 + arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 endif # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions ifeq ($(findstring $(machine), ia64 x86_64), $(machine)) - arch.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 + arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 endif @@ -482,7 +482,6 @@ ifeq ($(system), Darwin) /Applications/Pd-extended.app/Contents/Resources/include/pdextended/m_pd.h \ /Applications/Pd.app/Contents/Resources/src/m_pd.h))) extension = pd_darwin - arch.flags = cpp.flags := -DUNIX -DMACOSX -I /sw/include c.flags := c.ldflags := -undefined suppress -flat_namespace -bundle @@ -496,10 +495,12 @@ ifeq ($(system), Darwin) stripflags = -x ifeq ($(machine), i386) cxx.flags := -fcheck-new - arch.flags := -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 + arch.c.flags := -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 + arch.ld.flags := -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 endif ifeq ($(machine), x86_64) - arch.flags := -arch i386 -arch x86_64 -mmacosx-version-min=10.5 + arch.c.flags := -arch i386 -arch x86_64 -mmacosx-version-min=10.5 + arch.ld.flags := -arch i386 -arch x86_64 -mmacosx-version-min=10.5 endif endif @@ -537,7 +538,7 @@ ifeq ($(system), Windows) extension = dll CC = gcc CXX = g++ - arch.flags := -march=pentium4 -msse -msse2 -mfpmath=sse + arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse cpp.flags := -DMSW -DNT c.flags := c.ldflags := -static-libgcc -shared \ @@ -574,9 +575,9 @@ pdincludepathwithspaces := $(if $(word 2, $(pdincludepath)), $(pdincludepath)) # From GNU make docs: 'Users expect to be able to specify CFLAGS freely -# themselves.' So we use CFLAGS to define platform-independent options which -# are not strictly required for compilation: optimizations and warnings. CFLAGS -# can be safely overriden using a make command argument. +# themselves.' So we use CFLAGS to define options which are not strictly +# required for compilation: optimizations, architecture specifications, and +# warnings. CFLAGS can be safely overriden using a make command argument. # Variables cflags, ldflags and ldlibs may be defined in including makefile. optimization.flags = -O3 -ffast-math -funroll-loops -fomit-frame-pointer @@ -587,19 +588,22 @@ ifdef suppress-wunused warn.flags += $(addprefix -Wno-unused-, function parameter value variable) endif -CFLAGS = $(warn.flags) $(optimization.flags) +CFLAGS = $(warn.flags) $(optimization.flags) $(arch.c.flags) # preprocessor flags -cpp.flags += -DPD -I "$(pdincludepath)" +cpp.flags += -DPD -I "$(pdincludepath)" $(CPPFLAGS) -# flags for C compiler / linker +# architecture specifications for linker are overridable by LDFLAGS +LDFLAGS := $(arch.ld.flags) + +# accumulated flags for C compiler / linker c.flags := $(cpp.flags) $(c.flags) $(cflags) $(CFLAGS) -c.ldflags := $(c.ldflags) $(ldflags) +c.ldflags := $(c.ldflags) $(ldflags) $(LDFLAGS) c.ldlibs := $(c.ldlibs) $(ldlibs) -# flags for C++ compiler / linker +# accumulated flags for C++ compiler / linker cxx.flags := $(cpp.flags) $(cxx.flags) $(cflags) $(CFLAGS) -cxx.ldflags := $(cxx.ldflags) $(ldflags) +cxx.ldflags := $(cxx.ldflags) $(ldflags) $(LDFLAGS) cxx.ldlibs := $(cxx.ldlibs) $(ldlibs) @@ -706,7 +710,6 @@ alldebug: all # argument $2 = class basename define link-class $(compile-$1) \ - $(arch.flags) \ $($1.ldflags) $($2.class.ldflags) \ -o $2.$(extension) \ $(addsuffix .o, $(basename $($2.class.sources))) \ @@ -733,7 +736,6 @@ build-lib: $(lib.name).$(extension) # argument $1 = compiler type (c or cxx) define link-lib $(compile-$1) \ - $(arch.flags) \ $($1.ldflags) $(lib.ldflags) \ -o $(lib.name).$(extension) $(all.objects) \ $($1.ldlibs) $(lib.ldlibs) @@ -756,7 +758,6 @@ endif # argument $1 = compiler type (c or cxx) define link-shared $(compile-$1) \ - $(arch.flags) \ $(shared.ldflags) \ -o lib$(lib.name).$(shared.extension) $(shared.objects) \ $($1.ldlibs) $(shared.ldlibs) @@ -780,7 +781,7 @@ define make-object-file $(info ++++ info: making $@ in lib $(lib.name)) $(compile-$1) \ $($1.flags) \ - $(arch.flags) -o $@ -c $< + -o $@ -c $< endef # Three rules to create .o files. These are double colon 'terminal' rules, @@ -904,7 +905,6 @@ define make-assembly-file $(compile-$1) \ -c -Wa,-a,-ad -fverbose-asm \ $($1.flags) \ - $(arch.flags) \ $< > $(notdir $*.lst) endef From 0595e44e9f807a2b7586d6e856797a468e650320 Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 6 Dec 2015 16:18:50 +0100 Subject: [PATCH 12/86] Improve methods for searching Pd include paths. I've also tried to make printed info a bit more helpful. --- Makefile.pdlibbuilder | 78 ++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index b97e2b5..b3bcf6e 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -193,19 +193,19 @@ # Object (.o) files are built in the directory of their source files. # Executables are built in current working directory. # -# Variable 'pdincludepath' stores the location where m_pd.h was found. +# Variable 'pdincludepath' stores a location where m_pd.h is expected to reside. # Locations where Makefile.pdlibbuilder tries to find it, in order of priority: # -# any OS: $(externalsdir)../pd/src/ +# any OS: $(externalsdir)../pd/src # -# Linux: /usr/include/pdextended/ -# /usr/include/pd/ +# Linux: /usr/include/pdextended +# /usr/include/pd # -# OSX: /Applications/Pd-extended.app/Contents/Resources/include/pdextended/ -# /Applications/Pd.app/Contents/Resources/src/ +# OSX: /Applications/Pd-extended.app/Contents/Resources/include/pdextended +# /Applications/Pd.app/Contents/Resources/src # -# Windows: %PROGRAMFILES%/pd/include/pdextended/ -# %PROGRAMFILES%/pd/src/ +# Windows: %PROGRAMFILES%/pd/include/pdextended +# %PROGRAMFILES%/pd/src # # The path for installation of all library components is constructed as: # @@ -449,10 +449,10 @@ ifeq ($(system), Linux) prefix = /usr/local libdir := $(prefix)/lib pkglibdir = $(libdir)/pd-externals - pdincludepath := $(firstword $(dir $(wildcard \ - $(externalsdir)/../pd/src/m_pd.h \ - /usr/include/pdextended/m_pd.h \ - /usr/include/pd/m_pd.h))) + pdincludepath := $(firstword $(wildcard \ + $(externalsdir)/../pd/src \ + /usr/include/pdextended \ + /usr/include/pd)) extension = pd_linux cpp.flags := -DUNIX c.flags := -fpic @@ -477,10 +477,10 @@ endif ifeq ($(system), Darwin) pkglibdir = $(HOME)/Library/Pd - pdincludepath := $(firstword $(dir $(wildcard \ - $(externalsdir)/../pd/src/m_pd.h \ - /Applications/Pd-extended.app/Contents/Resources/include/pdextended/m_pd.h \ - /Applications/Pd.app/Contents/Resources/src/m_pd.h))) + pdincludepath := $(firstword $(wildcard \ + $(externalsdir)/../pd/src \ + /Applications/Pd-extended*.app/Contents/Resources/include/pdextended \ + /Applications/Pd*.app/Contents/Resources/src)) extension = pd_darwin arch.flags = cpp.flags := -DUNIX -DMACOSX -I /sw/include @@ -517,16 +517,16 @@ endif # paths for 32-bit executables on 64-bit Windows aren't yet defined here (TODO) ifeq ($(system), Windows) pkglibdir := $(APPDATA)/Pd - pdbinpath := $(wildcard $(externalsdir)/../pd/bin/) - pdincludepath := $(wildcard $(externalsdir)/../pd/src/) + pdbinpath := $(wildcard $(externalsdir)/../pd/bin) + pdincludepath := $(wildcard $(externalsdir)/../pd/src) ifndef pdbinpath - pdbinpath := $(shell ls -d "$(PROGRAMFILES)/pd/bin/") + pdbinpath := $(shell ls -d "$(PROGRAMFILES)/pd/bin") endif ifndef pdincludepath - pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/include/pdextended/") + pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/include/pdextended") endif ifndef pdincludepath - pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/src/") + pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/src") endif endif @@ -541,14 +541,14 @@ ifeq ($(system), Windows) cpp.flags := -DMSW -DNT c.flags := c.ldflags := -static-libgcc -shared \ - -Wl,--enable-auto-import "$(pdbinpath)pd.dll" + -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new cxx.ldflags := -static-libstdc++ -shared \ - -Wl,--enable-auto-import "$(pdbinpath)pd.dll" + -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" cxx.ldlibs := shared.extension = dll - shared.ldflags := -static-libgcc -shared "$(pdbinpath)pd.dll" + shared.ldflags := -static-libgcc -shared "$(pdbinpath)/pd.dll" stripflags = --strip-unneeded -R .note -R .comment endif @@ -637,10 +637,17 @@ else goals := all endif -# check if m_pd.h is found and print info about it -$(if $(shell ls "$(pdincludepath)m_pd.h"), \ - $(info ++++ info: using Pd API $(pdincludepath)m_pd.h), \ - $(warning Where is your m_pd.h? Do 'make help' for info.)) +# store path to Pd API m_pd.h if it is found +ifdef pdincludepath + mpdh := $(shell ls "$(pdincludepath)/m_pd.h") +endif + +# when making target all, check if m_pd.h is found and print info about it +ifeq ($(goals), all) + $(if $(mpdh), \ + $(info ++++ info: using Pd API $(mpdh)), \ + $(warning Where is Pd API m_pd.h? Do 'make help' for info.)) +endif # print target info $(info ++++ info: making target $(goals) $(if $(lib.name),in lib $(lib.name))) @@ -1094,9 +1101,11 @@ depend: # brief info about targets and paths -mpdh := $(shell ls "$(pdincludepath)m_pd.h") -mpdh := $(if $(mpdh), $(mpdh), m_pd.h not found. Is Pd(-extended) installed?) - +ifdef mpdh + mpdhinfo := $(mpdh) +else + mpdhinfo := m_pd.h was not found. Is Pd(-extended) installed? +endif help: @echo @@ -1108,15 +1117,16 @@ help: @echo " help: print this help text" @echo @echo " Pd API m_pd.h:" - @echo " $(shell ls "$(pdincludepath)m_pd.h")" - @echo " You may specify your preferred include path as argument to" + @echo " $(mpdhinfo)" + @echo " You may specify your preferred Pd include path as argument to" @echo " the make command, like 'pdincludepath=path/to/pd/src'." @echo @echo " Path for installation of your libdir(s):" @echo " $(objectsdir)" @echo " Alternatively you may specify your path for installation as argument" @echo " to the make command, like 'objectsdir=path/to/pd-externals'." - @echo " For detailed info read the doc sections in Makefile.pdlibbuilder." + @echo + @echo " Default paths are listed in the doc sections in Makefile.pdlibbuilder." @echo From 15832b5e0793f953c85203169237281e2dd46f8d Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 6 Dec 2015 18:00:01 +0100 Subject: [PATCH 13/86] Small fix: add LDFLAGS to shared.ldflags too. --- Makefile.pdlibbuilder | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 1c214b7..df60884 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -596,6 +596,9 @@ cpp.flags += -DPD -I "$(pdincludepath)" $(CPPFLAGS) # architecture specifications for linker are overridable by LDFLAGS LDFLAGS := $(arch.ld.flags) +# now add the same ld flags to shared dynamic lib +shared.ldflags := $(shared.ldflags) $(LDFLAGS) + # accumulated flags for C compiler / linker c.flags := $(cpp.flags) $(c.flags) $(cflags) $(CFLAGS) c.ldflags := $(c.ldflags) $(ldflags) $(LDFLAGS) From ed37e6bbb57cb07b91b405b16bdbfcf8151b433b Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 6 Dec 2015 20:52:45 +0100 Subject: [PATCH 14/86] Bumped to version 0.0.2. --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index b3bcf6e..fa507e2 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,4 +1,4 @@ -# Makefile.pdlibbuilder version 0.0.1, dated 2015-10-31 +# Makefile.pdlibbuilder version 0.0.2, dated 2015-12-06 # # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. From e08bab9eaaa731ce2b9c83282620f1c2142b82cd Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 6 Dec 2015 20:57:08 +0100 Subject: [PATCH 15/86] Updated README.md to include reference to xeq. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e0c2a6..a683915 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,12 @@ most basic usage, read the documentation sections in Makefile.pdlibbuilder. ### examples ### -Here are two projects using the Makefile.pdlibbuilder approach: +Here are three projects using the Makefile.pdlibbuilder approach: https://github.com/pure-data/helloworld http://sourceforge.net/p/pure-data/svn/HEAD/tree/trunk/externals/miXed/cyclone/Makefile.cyclone +https://github.com/pure-data/xeq + More examples will be referenced here when they are available. From c42845611fbed81e8f7f57ee46b4c362af7f995b Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 8 Dec 2015 13:04:13 +0100 Subject: [PATCH 16/86] Introduce pre and post targets. Targets pre and post can be defined in the including (library) makefile. They are added to provide extra flexibility. Target all will build pre, $(executable) and post in deterministic order. Built-in documentation is modified to reflect the new situation. --- Makefile.pdlibbuilder | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index fa507e2..52ab025 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -225,7 +225,9 @@ #=== targets =================================================================== # # -# all: build classes (default) or library blob (if make-lib-executable=true) +# all: build $(executables) plus optional pre and post targets +# pre: target to build before $(executables) +# post: target to build after $(executables) # alldebug: build all with -g option turned on for debug symbols # : force clean build of an individual class # .pre: make preprocessor output file in current working directory @@ -240,6 +242,11 @@ # depend: print generated prerequisites # coffee: dummy target # +# Variable $(executables) expands to class executables plus optional shared lib, +# or alternatively to single lib executable when make-lib-executable=true. +# Targets pre and post can be defined by library makefile. Make sure to include +# Makefile.pdlibbuilder first so default target all will not be redefined. +# # #=== Pd-extended libdir concept ================================================ # @@ -684,7 +691,8 @@ MAKEFLAGS += --no-builtin-rules .PRECIOUS: .SUFFIXES: -.PHONY: all build-classes build-lib $(classes) $(makefiledirs) $(makefiles)\ +.PHONY: all pre post build-classes build-lib \ + $(classes) $(makefiledirs) $(makefiles) \ install install-executables install-datafiles install-datadirs \ force clean vars allvars depend help @@ -694,10 +702,19 @@ MAKEFLAGS += --no-builtin-rules ################################################################################ -# target all builds class executables plus optional shared lib -# or alternatively a single lib executable when make-lib-executable=true -all: $(executables) - $(info ++++ info: $(if $(executables),executables in $(lib.name) completed)) +# Target all forces the build of targets [pre $(executables) post] in +# deterministic order. Target $(executables) builds class executables plus +# optional shared lib or alternatively a single lib executable when +# make-lib-executable=true. Targets pre and post are optionally defined by +# library makefile. + +all: post +post: $(executables) +$(executables): pre +pre: + +all: + $(info ++++info: target all in lib $(lib.name) completed) # build all with -g option turned on for debug symbols alldebug: c.flags += -g From a5678ac1e096f7f4e58ec141ce07dd37cb401b5c Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 8 Dec 2015 13:17:54 +0100 Subject: [PATCH 17/86] bump version 0.0.2 > 0.1.0 for added feature (targets pre / post) --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 52ab025..11e42db 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,4 +1,4 @@ -# Makefile.pdlibbuilder version 0.0.2, dated 2015-12-06 +# Makefile.pdlibbuilder version 0.1.0, dated 2015-12-08 # # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. From abeb4dec6e72f1153d9a27f3ede552812edce4fb Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 8 Dec 2015 14:35:12 +0100 Subject: [PATCH 18/86] Remove cruft from .PHONY: --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 11e42db..950286b 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -691,7 +691,7 @@ MAKEFLAGS += --no-builtin-rules .PRECIOUS: .SUFFIXES: -.PHONY: all pre post build-classes build-lib \ +.PHONY: all pre post build-lib \ $(classes) $(makefiledirs) $(makefiles) \ install install-executables install-datafiles install-datadirs \ force clean vars allvars depend help From 8cba158c9a38e5ca44ebe4fe0bbde8930c43620d Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 8 Dec 2015 14:41:30 +0100 Subject: [PATCH 19/86] Remove cruft from a variable definition --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 950286b..4d869a6 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -856,7 +856,7 @@ $(foreach v, $(classes), $(eval $(declare-class-executable-target))) # prerequisites rules so we do not evaluate them in that case. ifndef pdincludepathwithspaces - must-build-everything := $(filter all default lib, $(goals)) + must-build-everything := $(filter all, $(goals)) must-build-class := $(filter $(classes), $(goals)) must-build-sources := $(foreach v, $(must-build-class), $($v.class.sources)) endif From c6fe1832fc6f604b58e7ab696954e0a1bbb77cf2 Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 22 Dec 2015 00:45:26 +0100 Subject: [PATCH 20/86] Document CPPFLAGS, CFLAGS, LDFLAGS --- Makefile.pdlibbuilder | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index df60884..094db78 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -74,7 +74,9 @@ # - prefix # - libdir # - pkglibdir +# - CPPFLAGS # - CFLAGS +# - LDFLAGS # - CC # - CXX # - INSTALL @@ -161,9 +163,18 @@ # Alias of pkglibdir. Can be defined in your makefile to enable project- # dependent relative install locations. # +# CPPFLAGS: +# Preprocessor flags which are not strictly required for building. +# # CFLAGS: -# Compiler (notably optimization) flags which are defined by -# Makefile.pdlibbuilder, but may be overriden via command argument. +# Compiler flags which are not strictly required for building. Compiler flags +# defined by Makefile.pdlibbuilder for warning, optimization and architecture +# specification are overriden by CFLAGS. +# +# LDFLAGS: +# Linker flags which are not strictly required for building. Linker flags +# defined by Makefile.pdlibbuilder for architecture specification are overriden +# by LDFLAGS. # # CC and CXX: # C and C++ compiler programs as defined in your build environment. From c8875697b4123704800e41bbd88a22964a0efe5b Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 22 Dec 2015 23:25:03 +0100 Subject: [PATCH 21/86] Replaced outdated link to cyclone repository in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a683915..03d7f0f 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Here are three projects using the Makefile.pdlibbuilder approach: https://github.com/pure-data/helloworld -http://sourceforge.net/p/pure-data/svn/HEAD/tree/trunk/externals/miXed/cyclone/Makefile.cyclone +https://github.com/electrickery/pd-cyclone https://github.com/pure-data/xeq From d94538e1bbe5f02fa3b645504d477ab010ff54d1 Mon Sep 17 00:00:00 2001 From: katja Date: Sat, 26 Mar 2016 14:55:55 +0100 Subject: [PATCH 22/86] Remove target 'pre' from Makefile.pdlibbuilder Phony target 'pre' forces rebuilds. This should not be default behavior of Makefile.pdlibbuilder. If one needs a pre-build target (phony or real file), declare it as prerequisite of $(all.objects) in the library makefile after inclusion of Makefile.pdlibbuilder. A pre-build target can have any name that isn't a target in Makefile.pdlibbuilder. --- Makefile.pdlibbuilder | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 7f5d4bf..6ce5a3b 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -728,7 +728,7 @@ MAKEFLAGS += --no-builtin-rules .PRECIOUS: .SUFFIXES: -.PHONY: all pre post build-lib \ +.PHONY: all post build-lib \ $(classes) $(makefiledirs) $(makefiles) \ install install-executables install-datafiles install-datadirs \ force clean vars allvars depend help @@ -739,16 +739,14 @@ MAKEFLAGS += --no-builtin-rules ################################################################################ -# Target all forces the build of targets [pre $(executables) post] in +# Target all forces the build of targets [$(executables) post] in # deterministic order. Target $(executables) builds class executables plus # optional shared lib or alternatively a single lib executable when -# make-lib-executable=true. Targets pre and post are optionally defined by +# make-lib-executable=true. Target post is optionally defined by # library makefile. all: post post: $(executables) -$(executables): pre -pre: all: $(info ++++info: target all in lib $(lib.name) completed) From c989c8e0b0ddd9ca4404e5ae206eaadbfc7e7e64 Mon Sep 17 00:00:00 2001 From: katja Date: Sat, 26 Mar 2016 15:39:39 +0100 Subject: [PATCH 23/86] Bump to version 0.2.2 after removal of 'pre' target Also remove associated documentation comments. --- Makefile.pdlibbuilder | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 6ce5a3b..5f61e6f 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,4 +1,4 @@ -# Makefile.pdlibbuilder version 0.2.1, dated 2015-12-27 +# Makefile.pdlibbuilder version 0.2.2, dated 2016-03-28 # # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -250,8 +250,7 @@ #=== targets =================================================================== # # -# all: build $(executables) plus optional pre and post targets -# pre: target to build before $(executables) +# all: build $(executables) plus optional post target # post: target to build after $(executables) # alldebug: build all with -g option turned on for debug symbols # : force clean build of an individual class From eb614fdf163889297602813966eb062339b60e05 Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 29 Mar 2016 11:26:52 +0200 Subject: [PATCH 24/86] Disable dep. checking for fat builds on OSX <= 10.5. Version 0.2.3 Multiple arch flags are incompatible with option -MM for preprocessor on (at least) OSX <= 10.5. Non clean builds would stall on this. This commit disables dependency checking for fat builds (current default for OSX) on ppc and i386. Assuming that development is done on newer systems / machines it should rarely hurt. --- Makefile.pdlibbuilder | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 5f61e6f..a91bb39 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,4 +1,4 @@ -# Makefile.pdlibbuilder version 0.2.2, dated 2016-03-28 +# Makefile.pdlibbuilder version 0.2.3, dated 2016-03-29 # # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -884,9 +884,16 @@ $(foreach v, $(classes), $(eval $(declare-class-executable-target))) # which case implicit prerequisites are not checked. # When the Pd include path contains spaces it will mess up the implicit -# prerequisites rules so we do not evaluate them in that case. +# prerequisites rules. Also it is known that multiple arch flags are +# incompatible with preprocessor option -MM on OSX <= 10.5. Dependency +# tracking must be disabled in those cases. -ifndef pdincludepathwithspaces +oldfat := $(and $(filter ppc i386, $(machine)), \ + $(filter-out 0 1, $(words $(filter -arch, $(c.flags))))) + +disable-dependency-tracking := pdincludepathwithspaces oldfat + +ifndef disable-dependency-tracking must-build-everything := $(filter all, $(goals)) must-build-class := $(filter $(classes), $(goals)) must-build-sources := $(foreach v, $(must-build-class), $($v.class.sources)) From 1d7bb5e15493afdb2ea2a34a983d1188e045dc13 Mon Sep 17 00:00:00 2001 From: katja Date: Sat, 25 Jun 2016 22:26:33 +0200 Subject: [PATCH 25/86] Fix regression bug that disabled all dependency checking The bug was probably introduced with version 0.2.3. Bump version to 0.2.4. --- Makefile.pdlibbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index a91bb39..eb30f71 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,4 +1,4 @@ -# Makefile.pdlibbuilder version 0.2.3, dated 2016-03-29 +# Makefile.pdlibbuilder version 0.2.4, dated 2016-06-25 # # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -891,7 +891,7 @@ $(foreach v, $(classes), $(eval $(declare-class-executable-target))) oldfat := $(and $(filter ppc i386, $(machine)), \ $(filter-out 0 1, $(words $(filter -arch, $(c.flags))))) -disable-dependency-tracking := pdincludepathwithspaces oldfat +disable-dependency-tracking := $(strip $(pdincludepathwithspaces) $(oldfat)) ifndef disable-dependency-tracking must-build-everything := $(filter all, $(goals)) From b1a4c9b5251814546a2621a1faf3b494791cc419 Mon Sep 17 00:00:00 2001 From: katja Date: Sat, 25 Jun 2016 23:19:32 +0200 Subject: [PATCH 26/86] Print Makefile.pdlibbuilder version --- Makefile.pdlibbuilder | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index eb30f71..9f9990c 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,7 @@ -# Makefile.pdlibbuilder version 0.2.4, dated 2016-06-25 -# +# Makefile.pdlibbuilder dated 2016-06-25 + +version = 0.2.4 + # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. # Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's @@ -685,6 +687,9 @@ ifdef pdincludepath mpdh := $(shell ls "$(pdincludepath)/m_pd.h") endif +# print Makefile.pdlibbuilder version +$(info ++++ info: using Makefile.pdlibbuilder version $(version)) + # when making target all, check if m_pd.h is found and print info about it ifeq ($(goals), all) $(if $(mpdh), \ From f06e550a3ac006737c20bda199f8379354b8d47d Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 26 Jun 2016 11:19:54 +0200 Subject: [PATCH 27/86] Fix dependency checking for object files in other directories And bump version to 0.2.5 --- Makefile.pdlibbuilder | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 9f9990c..bb02fe1 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,6 +1,6 @@ -# Makefile.pdlibbuilder dated 2016-06-25 +# Makefile.pdlibbuilder dated 2016-06-26 -version = 0.2.4 +version = 0.2.5 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -906,8 +906,9 @@ endif # declare implicit prerequisites rule like 'object.o: header1.h header2.h ...' # argument $1 is input source file(s) +# dir is explicitly added because option -MM strips it by default define declare-object-target -$(filter %.o: %.h, $(shell $(CPP) $(c.flags) -MM $1)) $(MAKEFILE_LIST) +$(dir $1)$(filter %.o: %.h, $(shell $(CPP) $(c.flags) -MM $1)) $(MAKEFILE_LIST) endef # evaluate implicit prerequisite rules when rebuilding everything From 49a0b2fa5ea07fdf0775d92d5ce5a20cd96f0820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 28 Jun 2016 11:33:25 +0200 Subject: [PATCH 28/86] allow installed files to contain weirdo characters ...like '$' (e.g. "$arg-help.pd") by installing them one-by-one and using single-quotes (so the shell doesn't expand the dollargs) NOTE: this does not fix compiling such weirdo filenames Closes: https://github.com/pure-data/pd-lib-builder/issues/19 --- Makefile.pdlibbuilder | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index a91bb39..4885a30 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1009,13 +1009,15 @@ install: $(if $(datadirs), install-datadirs) install-executables: all $(INSTALL_DIR) -v "$(installpath)" - $(INSTALL_PROGRAM) $(executables) "$(installpath)" + $(foreach v, $(executables), \ + $(INSTALL_PROGRAM) '$v' "$(installpath)";) $(info ++++ info: executables of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) install-datafiles: all $(INSTALL_DIR) -v "$(installpath)" - $(INSTALL_DATA) $(datafiles) "$(installpath)" + $(foreach v, $(datafiles), \ + $(INSTALL_DATA) '$(v)' "$(installpath)";) $(info ++++ info: data files of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) From 9fd17957c7c6bb11ab9f77c9cc2cbffd0adb9587 Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 20 Sep 2016 12:37:55 +0200 Subject: [PATCH 29/86] Do not pass architecture flags for dependency checking Only pass flags categories which can be expected to hold -I flags to the preprocessor for dependency checking. Omit categories which may contain architecture and tuning flags. This is a small and hopefully reasonable limitation of dependency-checking functionality. The preprocessor will still see predefined macros, amongst which architecture definition. Thus, eventual architecture-dependent include statements in the source code are considered for native architecture during dependency checking. This commit should resolve the rebuild issue on OSX, where some compiler versions can not handle multiple architecture flags during dependency checking. --- Makefile.pdlibbuilder | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index bb02fe1..37179d3 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,6 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-06-26 - -version = 0.2.5 +# Makefile.pdlibbuilder dated 2016-09-20 +version = 0.2.6 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -629,7 +628,10 @@ endif CFLAGS = $(warn.flags) $(optimization.flags) $(arch.c.flags) # preprocessor flags -cpp.flags += -DPD -I "$(pdincludepath)" $(CPPFLAGS) +cpp.flags := -DPD -I "$(pdincludepath)" $(cpp.flags) $(CPPFLAGS) + +# flags for dependency checking (cflags from makefile may define -I options) +depcheck.flags := $(cpp.flags) $(cflags) # architecture specifications for linker are overridable by LDFLAGS LDFLAGS := $(arch.ld.flags) @@ -908,7 +910,7 @@ endif # argument $1 is input source file(s) # dir is explicitly added because option -MM strips it by default define declare-object-target -$(dir $1)$(filter %.o: %.h, $(shell $(CPP) $(c.flags) -MM $1)) $(MAKEFILE_LIST) +$(dir $1)$(filter %.o: %.h, $(shell $(CPP) $(depcheck.flags) -MM $1)) $(MAKEFILE_LIST) endef # evaluate implicit prerequisite rules when rebuilding everything From 2832db38fd7eba25ba1890f88ae902e33d662f51 Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 20 Sep 2016 13:01:10 +0200 Subject: [PATCH 30/86] Remove old dependency-check workaround for OSX <= 10.5 --- Makefile.pdlibbuilder | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 37179d3..707288d 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -891,14 +891,8 @@ $(foreach v, $(classes), $(eval $(declare-class-executable-target))) # which case implicit prerequisites are not checked. # When the Pd include path contains spaces it will mess up the implicit -# prerequisites rules. Also it is known that multiple arch flags are -# incompatible with preprocessor option -MM on OSX <= 10.5. Dependency -# tracking must be disabled in those cases. - -oldfat := $(and $(filter ppc i386, $(machine)), \ - $(filter-out 0 1, $(words $(filter -arch, $(c.flags))))) - -disable-dependency-tracking := $(strip $(pdincludepathwithspaces) $(oldfat)) +# prerequisites rules. +disable-dependency-tracking := $(strip $(pdincludepathwithspaces)) ifndef disable-dependency-tracking must-build-everything := $(filter all, $(goals)) From 5c9fed10988570b7cf0459920db11dad4fe51bee Mon Sep 17 00:00:00 2001 From: Dan Wilcox Date: Fri, 30 Sep 2016 11:40:21 -0600 Subject: [PATCH 31/86] updated cyclone link --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 03d7f0f..0a61e55 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,6 @@ Here are three projects using the Makefile.pdlibbuilder approach: https://github.com/pure-data/helloworld -https://github.com/electrickery/pd-cyclone - -https://github.com/pure-data/xeq +https://github.com/porres/pd-cyclone More examples will be referenced here when they are available. From dc9a8df02ac805f1d66f5896e55ebef10224214b Mon Sep 17 00:00:00 2001 From: Dan Wilcox Date: Sun, 2 Oct 2016 11:12:11 -0600 Subject: [PATCH 32/86] re-added cyclone link & added contextual info --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a61e55..7bf6c51 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,12 @@ most basic usage, read the documentation sections in Makefile.pdlibbuilder. ### examples ### -Here are three projects using the Makefile.pdlibbuilder approach: +Here are a few projects using the Makefile.pdlibbuilder approach: https://github.com/pure-data/helloworld -https://github.com/porres/pd-cyclone +https://github.com/electrickery/pd-cyclone (stable) + +https://github.com/porres/pd-cyclone (experimental) More examples will be referenced here when they are available. From a6a89dc021d42fdb5a61de8ca371fed0862009a8 Mon Sep 17 00:00:00 2001 From: katja Date: Tue, 4 Oct 2016 17:33:45 +0200 Subject: [PATCH 33/86] Scrap all default include / bin paths except vanilla's Multiple defaults cause confusion and after discussion vanilla is preferred default because: 1. vanilla is actively maintained 2. currently most pd lib authors develop against vanilla 3. unlike other pd flavors, vanilla is not part of a centralized build system with internal include path --- Makefile.pdlibbuilder | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 707288d..ef49b24 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-09-20 -version = 0.2.6 +# Makefile.pdlibbuilder dated 2016-10-04 +version = 0.2.7 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -220,18 +220,13 @@ version = 0.2.6 # Executables are built in current working directory. # # Variable 'pdincludepath' stores a location where m_pd.h is expected to reside. -# Locations where Makefile.pdlibbuilder tries to find it, in order of priority: +# Location where Makefile.pdlibbuilder tries to find it: # -# any OS: $(externalsdir)../pd/src +# Linux: /usr/include/pd # -# Linux: /usr/include/pdextended -# /usr/include/pd +# OSX: /Applications/Pd*.app/Contents/Resources/src # -# OSX: /Applications/Pd-extended.app/Contents/Resources/include/pdextended -# /Applications/Pd.app/Contents/Resources/src -# -# Windows: %PROGRAMFILES%/pd/include/pdextended -# %PROGRAMFILES%/pd/src +# Windows: %PROGRAMFILES%/pd/src # # The path for installation of all library components is constructed as: # @@ -337,8 +332,7 @@ endif # Relative path to externals root dir in multi-lib source tree like # pd-extended SVN. Default is parent of current working directory. May be -# defined differently in including makefile. This variable is used to probe for -# paths. +# defined differently in including makefile. externalsdir ?= .. # variable you can use to check if Makefile.pdlibbuilder is already included @@ -486,10 +480,7 @@ ifeq ($(system), Linux) prefix = /usr/local libdir := $(prefix)/lib pkglibdir = $(libdir)/pd-externals - pdincludepath := $(firstword $(wildcard \ - $(externalsdir)/../pd/src \ - /usr/include/pdextended \ - /usr/include/pd)) + pdincludepath := $(wildcard /usr/include/pd) extension = pd_linux cpp.flags := -DUNIX c.flags := -fpic @@ -515,8 +506,6 @@ endif ifeq ($(system), Darwin) pkglibdir = $(HOME)/Library/Pd pdincludepath := $(firstword $(wildcard \ - $(externalsdir)/../pd/src \ - /Applications/Pd-extended*.app/Contents/Resources/include/pdextended \ /Applications/Pd*.app/Contents/Resources/src)) extension = pd_darwin cpp.flags := -DUNIX -DMACOSX -I /sw/include @@ -555,14 +544,9 @@ endif # paths for 32-bit executables on 64-bit Windows aren't yet defined here (TODO) ifeq ($(system), Windows) pkglibdir := $(APPDATA)/Pd - pdbinpath := $(wildcard $(externalsdir)/../pd/bin) - pdincludepath := $(wildcard $(externalsdir)/../pd/src) ifndef pdbinpath pdbinpath := $(shell ls -d "$(PROGRAMFILES)/pd/bin") endif - ifndef pdincludepath - pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/include/pdextended") - endif ifndef pdincludepath pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/src") endif @@ -1160,7 +1144,7 @@ depend: ifdef mpdh mpdhinfo := $(mpdh) else - mpdhinfo := m_pd.h was not found. Is Pd(-extended) installed? + mpdhinfo := m_pd.h was not found. Is Pd installed? endif help: From 4815915ae28f18edfc7f887f60001d92a0cfe1ee Mon Sep 17 00:00:00 2001 From: katja Date: Wed, 5 Oct 2016 15:52:47 +0200 Subject: [PATCH 34/86] Add more projects that use pd-lib-builder in README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 7bf6c51..fd7660f 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,16 @@ https://github.com/electrickery/pd-cyclone (stable) https://github.com/porres/pd-cyclone (experimental) +https://git.iem.at/pd/iemguts + +https://git.iem.at/pd/iemnet + +https://git.iem.at/pd/iem_ambi + +https://git.iem.at/pd/mediasettings + +https://git.iem.at/pd-gui/punish + +https://github.com/residuum/PuRestJson + More examples will be referenced here when they are available. From a7d309822db391213ef61cdcfcafdf6902ecea09 Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 9 Oct 2016 11:56:14 +0200 Subject: [PATCH 35/86] Respect flag '-mmacosx-version-min=*' from lib makefile Makefile.pdlibbuilder sets a default minimum OSX version for optimal support of older OSX versions. With this commit, '-mmacosx-version-min=*' in variable 'cflags' from the lib makefile is respected, not overridden. A lib makefile can now determine the minimum OSX version (for example to support C++11, which was the direct motivation for this change). This is a response to pull request #22 'Making minimum Mac OS X version configurable', but note that it is implemented in a different way. --- Makefile.pdlibbuilder | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 724678c..c1512ff 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -503,6 +503,7 @@ endif # LLVM-clang doesn't support -fcheck-new, therefore this flag is omitted for # OSX x86_64. + ifeq ($(system), Darwin) pkglibdir = $(HOME)/Library/Pd pdincludepath := $(firstword $(wildcard \ @@ -519,15 +520,18 @@ ifeq ($(system), Darwin) -install_name @loader_path/$(shared.lib) \ -compatibility_version 1 -current_version 1.0 stripflags = -x + version.flag := $(filter $(cflags), -mmacosx-version-min=%) ifeq ($(machine), i386) cxx.flags := -fcheck-new - arch.c.flags := -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 - arch.ld.flags := -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 + arch := ppc i386 x86_64 + version.flag ?= -mmacosx-version-min=10.4 endif ifeq ($(machine), x86_64) - arch.c.flags := -arch i386 -arch x86_64 -mmacosx-version-min=10.5 - arch.ld.flags := -arch i386 -arch x86_64 -mmacosx-version-min=10.5 + arch := i386 x86_64 + version.flag ?= -mmacosx-version-min=10.5 endif + arch.c.flags := $(addprefix -arch , $(arch)) $(version.flag) + arch.ld.flags := $(arch.c.flags) endif From 5b920b194db4f01a7b16b15858cd1b39680f49dd Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 9 Oct 2016 14:12:31 +0200 Subject: [PATCH 36/86] Set version to 0.2.8 after merging 'install-dollarfiles' Update version number because of previous (merge) commit. The merge was done with github's 'Merge' button. Never again. The merged commit was 49a0b2f from 2016-06-28 allowing installed files to contain weirdo characters, and closing issue #19. --- Makefile.pdlibbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 724678c..6f68ebb 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-10-04 -version = 0.2.7 +# Makefile.pdlibbuilder dated 2016-10-09 +version = 0.2.8 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. From 41e9743ed5fa0dfd74008e50510543b9a3596d26 Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 9 Oct 2016 22:07:23 +0200 Subject: [PATCH 37/86] Introduce variable 'PD_PATH', bump version to 0.3.0 This variable is useful when building against a 'portable' pd install. Makefile.pdlibbuilder should now be compatible with centralized build systems when PD_PATH is passed as make argument, or set in environment. --- Makefile.pdlibbuilder | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 6f68ebb..a0dbd70 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ # Makefile.pdlibbuilder dated 2016-10-09 -version = 0.2.8 +version = 0.3.0 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -76,6 +76,7 @@ version = 0.2.8 # # Variables avaialable for (re)definition via command arguments: # +# - PD_PATH # - pdbinpath (Windows only) # - pdincludepath # - DESTDIR @@ -161,6 +162,10 @@ version = 0.2.8 # Extra makefiles or directories with makefiles that should be made in sub-make # processes. # +# PD_PATH: +# Root directory of portable pd installation where bin/ and src/ are direct +# subdirs. +# # pdbinpath: # For Windows only. Directory where pd.dll can be found for linking. # @@ -566,11 +571,11 @@ ifeq ($(system), Windows) -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new - cxx.ldflags := -static-libstdc++ -shared \ + cxx.ldflags = -static-libstdc++ -shared \ -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" cxx.ldlibs := shared.extension = dll - shared.ldflags := -static-libgcc -shared "$(pdbinpath)/pd.dll" + shared.ldflags = -static-libgcc -shared "$(pdbinpath)/pd.dll" stripflags = --strip-unneeded -R .note -R .comment endif @@ -578,6 +583,13 @@ endif #=== paths ===================================================================== +# If PD_PATH is defined as make command argument or in the environment, override +# the earlier platform-dependent default. +ifdef PD_PATH + pdincludepath := $(PD_PATH)/src + pdbinpath := $(PD_PATH)/bin +endif + # Default pkglibdir is specified above per operating system. It is aliased as # 'objectsdir' to retain compatibility with pd-extended template. Assignment # operator '?=' is used to enable a project-relative path definition in the From a0c87bea5e660e78e50fafd3738f266eae0751b1 Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 13 Oct 2016 23:58:13 +0200 Subject: [PATCH 38/86] Defer expansion of $(pdbinpath) to correctly find pd.dll (bugfix) The issue was introduced in version 0.3.0 from the previous commit (41e9743). --- Makefile.pdlibbuilder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index a0dbd70..f8215b8 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-10-09 -version = 0.3.0 +# Makefile.pdlibbuilder dated 2016-10-13 +version = 0.3.1 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -567,7 +567,7 @@ ifeq ($(system), Windows) arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse cpp.flags := -DMSW -DNT c.flags := - c.ldflags := -static-libgcc -shared \ + c.ldflags = -static-libgcc -shared \ -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new From b0dab729b9a1fe08ea55eb051298f99b9c779027 Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 13 Oct 2016 23:44:18 +0200 Subject: [PATCH 39/86] Introduce variables PDDIR, PDINCLUDEDIR, PDBINDIR, PDLIBDIR These new path variables are aliases of existing ones that didn't have coherent names. The new variables are all defined such that they are overridable from the environment, as indicated by the upper case syntax. --- Makefile.pdlibbuilder | 46 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index f8215b8..184bda5 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-10-13 -version = 0.3.1 +# Makefile.pdlibbuilder dated 2016-10-14 +version = 0.4.0 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -583,25 +583,27 @@ endif #=== paths ===================================================================== -# If PD_PATH is defined as make command argument or in the environment, override -# the earlier platform-dependent default. -ifdef PD_PATH - pdincludepath := $(PD_PATH)/src - pdbinpath := $(PD_PATH)/bin +# Platform-dependent default paths are specified above, but overridable. +# Path variables in upper case can be defined as make command argument or in the +# environment. 'PD_PATH' and 'objectsdir' are supported for compatibility with +# the build system that pd-l2ork has inherited from pd-extended. + +PDDIR ?= $(PD_PATH) +PDINCLUDEDIR ?= $(pdincludepath) +PDBINDIR ?= $(pdbinpath) +PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir)) + +ifneq ($(PDDIR),) + PDINCLUDEDIR := $(wildcard $(PDDIR)/src) + PDBINDIR := $(wildcard $(PDDIR)/bin) endif -# Default pkglibdir is specified above per operating system. It is aliased as -# 'objectsdir' to retain compatibility with pd-extended template. Assignment -# operator '?=' is used to enable a project-relative path definition in the -# including makefile. -objectsdir ?= $(pkglibdir) - # base path where all components of the lib will be installed by default -installpath := $(DESTDIR)$(objectsdir)/$(lib.name) +installpath := $(DESTDIR)$(PDLIBDIR)/$(lib.name) -# check if pdincludepath contains spaces (as is often the case on Windows) +# check if include path contains spaces (as is often the case on Windows) # if so, store the path so we can later do checks with it -pdincludepathwithspaces := $(if $(word 2, $(pdincludepath)), $(pdincludepath)) +pdincludepathwithspaces := $(if $(word 2, $(PDINCLUDEDIR)), $(PDINCLUDEDIR)) #=== accumulated build flags =================================================== @@ -624,7 +626,7 @@ endif CFLAGS = $(warn.flags) $(optimization.flags) $(arch.c.flags) # preprocessor flags -cpp.flags := -DPD -I "$(pdincludepath)" $(cpp.flags) $(CPPFLAGS) +cpp.flags := -DPD -I "$(PDINCLUDEDIR)" $(cpp.flags) $(CPPFLAGS) # flags for dependency checking (cflags from makefile may define -I options) depcheck.flags := $(cpp.flags) $(cflags) @@ -682,7 +684,7 @@ endif # store path to Pd API m_pd.h if it is found ifdef pdincludepath - mpdh := $(shell ls "$(pdincludepath)/m_pd.h") + mpdh := $(shell ls "$(PDINCLUDEDIR)/m_pd.h") endif # print Makefile.pdlibbuilder version @@ -1172,13 +1174,13 @@ help: @echo @echo " Pd API m_pd.h:" @echo " $(mpdhinfo)" - @echo " You may specify your preferred Pd include path as argument to" - @echo " the make command, like 'pdincludepath=path/to/pd/src'." + @echo " You may specify your preferred Pd include directory as argument" + @echo " to the make command, like 'PDINCLUDEDIR=path/to/pd/src'." @echo @echo " Path for installation of your libdir(s):" - @echo " $(objectsdir)" + @echo " $(PDLIBDIR)" @echo " Alternatively you may specify your path for installation as argument" - @echo " to the make command, like 'objectsdir=path/to/pd-externals'." + @echo " to the make command, like 'PDLIBDIR=path/to/pd-externals'." @echo @echo " Default paths are listed in the doc sections in Makefile.pdlibbuilder." @echo From cf04da9b4732733b5fdbd51efb7ca79a5287722f Mon Sep 17 00:00:00 2001 From: katja Date: Fri, 14 Oct 2016 11:50:34 +0200 Subject: [PATCH 40/86] Rewrite variable descriptions after introduction of 'PDDIR' & Co. Variables PDDIR, PDINCLUDEDIR, PDBINDIR and PDLIBDIR were introduced in the previous commit as API replacement for a less coherent set of path variable names, and made these paths settable in the environment. This commit (re)writes variable descriptions accordingly and reorganizes descriptions with the intention to give a more comprehensible overview of the API structure. --- Makefile.pdlibbuilder | 117 ++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 56 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 184bda5..f39efb3 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -73,31 +73,34 @@ version = 0.4.0 # - forDarwin # - forWindows # +# Variables available for your makefile or make command line: # -# Variables avaialable for (re)definition via command arguments: +# - make-lib-executable +# - suppress-wunused +# +# Path variables for make command line or environment: +# +# - PDDIR +# - PDINCLUDEDIR +# - PDBINDIR +# - PDLIBDIR +# +# Standard make variables for make command line or environment: # -# - PD_PATH -# - pdbinpath (Windows only) -# - pdincludepath -# - DESTDIR -# - prefix -# - libdir -# - pkglibdir # - CPPFLAGS # - CFLAGS # - LDFLAGS # - CC # - CXX # - INSTALL -# - INSTALL_PROGRAM -# - INSTALL_DATA -# - INSTALL_DIR +# - DESTDIR # -# Variables available for your makefile or as command argument: +# Deprecated path variables: # +# - PD_PATH +# - pdincludepath +# - pdbinpath # - objectsdir -# - make-lib-executable -# - suppress-wunused # # #=== descriptions of Makefile.pdlibbuilder API variables ======================= @@ -145,12 +148,6 @@ version = 0.4.0 # files that should go into your lib rootdir and 'datadirs' for complete # directories you want to copy from source to distribution. # -# externalsdir: -# Relative path to directory 'externals' in the context of pd-extended SVN, or -# any other centralized build layout for multiple libraries. Default value -# is '..', meaning the direct parent. The value is used in search paths for -# pd core components (header files, and executable in the case of Windows). -# # forLinux, forDarwin, forWindows: # Shorthand for 'variable definitions for Linux only' etc. Use like: # define forLinux @@ -162,26 +159,37 @@ version = 0.4.0 # Extra makefiles or directories with makefiles that should be made in sub-make # processes. # -# PD_PATH: -# Root directory of portable pd installation where bin/ and src/ are direct -# subdirs. +# make-lib-executable: +# When this variable is defined 'yes' in your makefile or as command argument, +# Makefile.pdlibbuilder will try to build all classes into a single library +# executable (but it will force exit if lib.setup.sources is undefined). +# If your makefile defines 'make-lib-executable=yes' as the library default, +# this can still be overriden with 'make-lib-executable=no' as command argument +# to build individual class executables (the Makefile.pdlibbuilder default.) # -# pdbinpath: -# For Windows only. Directory where pd.dll can be found for linking. +# suppress-wunused: +# When this variable is defined ('yes' or any other value), -Wunused-variable, +# -Wunused-parameter, -Wunused-value and -Wunused-function are suppressed, +# but the other warnings from -Wall are retained. # -# pdincludepath: -# Directory where Pd API m_pd.h can be found, and other Pd header files. +# PDDIR: +# Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and +# PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. # -# DESTDIR, prefix, libdir: -# Components of the path for installation as conventionally used on Linux. +# PDINCLUDEDIR: +# Directory where Pd API m_pd.h should be found, and other Pd header files. +# Overrides the default search path. # -# pkglibdir: -# Base path for installation of Pd library directories. Default is specified -# per OS, see section about paths below. +# PDBINDIR: +# Directory where pd.dll should be found for linking (Windows only). Overrides +# the default search path. # -# objectsdir: -# Alias of pkglibdir. Can be defined in your makefile to enable project- -# dependent relative install locations. +# PDLIBDIR: +# Root directory for installation of Pd library directories. Overrides the +# default install location. +# +# DESTDIR: +# Prepended path component for staged install. # # CPPFLAGS: # Preprocessor flags which are not strictly required for building. @@ -199,21 +207,21 @@ version = 0.4.0 # CC and CXX: # C and C++ compiler programs as defined in your build environment. # -# INSTALL, INSTALL_PROGRAM, INSTALL_DATA, INSTALL_DIR: -# Definitions of install program, may be overriden via command argument. +# INSTALL +# Definition of install program. # -# make-lib-executable: -# When this variable is defined 'yes' in your makefile or as command argument, -# Makefile.pdlibbuilder will try to build all classes into a single library -# executable (but it will force exit if lib.setup.sources is undefined). -# If your makefile defines 'make-lib-executable=yes' as the library default, -# this can still be overriden with 'make-lib-executable=no' as command argument -# to build individual class executables (the Makefile.pdlibbuilder default.) +# PD_PATH: +# Equivalent to PDDIR. Supported for compatibility with pd-extended central +# makefile, but deprecated otherwise. # -# suppress-wunused: -# When this variable is defined ('yes' or any other value), -Wunused-variable, -# -Wunused-parameter, -Wunused-value and -Wunused-function are suppressed, -# but the other warnings from -Wall are retained. +# objectsdir: +# Root directory for installation of Pd library directories, like PDLIBDIR but +# not overridable by environment. Supported for compatibility with pd-extended +# central makefile, but deprecated otherwise. +# +# pdincludepath, pdbinpath: +# As PDINCLUDEDIR and PDBINDIR but not overridable by environment. Deprecated +# as user variables. # # #=== paths ===================================================================== @@ -224,8 +232,8 @@ version = 0.4.0 # Object (.o) files are built in the directory of their source files. # Executables are built in current working directory. # -# Variable 'pdincludepath' stores a location where m_pd.h is expected to reside. -# Location where Makefile.pdlibbuilder tries to find it: +# Default search path for m_pd.h and other API header files is platform +# dependent, and overridable by PDINCLUDEDIR: # # Linux: /usr/include/pd # @@ -233,17 +241,14 @@ version = 0.4.0 # # Windows: %PROGRAMFILES%/pd/src # -# The path for installation of all library components is constructed as: -# -# installpath := $(DESTDIR)$(objectsdir)/$(lib.name) -# -# Default for 'objectsdir' is defined per platform and follows this convention: -# https://puredata.info/docs/faq/how-do-i-install-externals-and-help-files +# Default location to install pd libraries is platform dependent, and +# overridable by PDLIBDIR: # # Linux: /usr/local/lib/pd-externals # OSX: ~/Library/Pd # Windows: %APPDATA%/Pd # +# https://puredata.info/docs/faq/how-do-i-install-externals-and-help-files # The rationale for not installing to ~/pd-externals by default on Linux # is that some people share the home dir between 32 and 64 bit installations. # From 48c41272973f183f8f25bc8f98f2bdead701db90 Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 27 Oct 2016 00:44:56 +0200 Subject: [PATCH 41/86] Bump version to 0.4.1 after merging 'configurable-minimum-osxversion' --- Makefile.pdlibbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 4306898..8be6339 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-10-14 -version = 0.4.0 +# Makefile.pdlibbuilder dated 2016-10-27 +version = 0.4.1 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. From 4c680bfe6ff839c272ffc6e1ba9740d88611df1d Mon Sep 17 00:00:00 2001 From: katja Date: Thu, 27 Oct 2016 01:10:53 +0200 Subject: [PATCH 42/86] Add 'path' and 'documentation' sections in README.md --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index fd7660f..c6926b6 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,39 @@ with Pd's default extension for the platform. For anything more than the most basic usage, read the documentation sections in Makefile.pdlibbuilder. +### paths ### + + +Makefile.pdlibbuilder >= v0.4.0 supports pd path variables which can be +defined not only as make command argument but also in the environment, to +override platform-dependent defaults: + +PDDIR: +Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and +PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. + +PDINCLUDEDIR: +Directory where Pd API m_pd.h should be found, and other Pd header files. +Overrides the default search path. + +PDBINDIR: +Directory where pd.dll should be found for linking (Windows only). Overrides +the default search path. + +PDLIBDIR: +Root directory for installation of Pd library directories. Overrides the +default install location. + + +### documentation ### + + +This README.md provides only basic information. A large comment section inside +Makefile.pdlibbuilder lists and explains the available user variables, default +paths, and targets. The internal documentation reflects the exact functionality +of the particular version. A tips&tricks page is in the works. + + ### examples ### From 006d9575b52b79a4ac27dd5a345d9f21daa6c31b Mon Sep 17 00:00:00 2001 From: katja Date: Fri, 28 Oct 2016 09:58:47 +0200 Subject: [PATCH 43/86] Add CHANGELOG.txt to the project --- CHANGELOG.txt | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 CHANGELOG.txt diff --git a/CHANGELOG.txt b/CHANGELOG.txt new file mode 100644 index 0000000..1c9607c --- /dev/null +++ b/CHANGELOG.txt @@ -0,0 +1,71 @@ +Changelog for Makefile.pdlibbuilder. + + +v0.4.1, dated 2016-10-27 +Respect cflag for minimum OSX version when defined by lib makefile. +(bugfix, pull request #22, commit 48c4127) + +v0.4.0, dated 2016-10-14 +Introduced path variables PDDIR, PDINCLUDEDIR, PDBINDIR, PDLIBDIR which can +also be defined in environment. +(feature, issue #27, commit b0dab72) + +v0.3.1, dated 2016-10-13 +Fix bug where pd.dll wouldn't be found. +(bugfix, commit a0c87be) + +v0.3.0, dated 2016-10-09 +Variable 'PD_PATH' introduced for pd-extended / pd-l2ork compatibility. +(feature, issue #26, commit 41e9743) + +v0.2.8, dated 2016-10-09 +Allow installed files to contain weird characters (notably '$'). +(bugfix, pull request #20, commit 5b920b1) + +v0.2.7, dated 2016-10-04 +Remove all default pd search paths except vanilla's. +(discussion, issue #25, commit a6a89dc) + +v0.2.6, dated 2016-09-20 +Redefined dependency checking so it won't stall rebuilds on OSX. +(bugfix, issue #16, commit 9fd1795) + +v0.2.5, dated 2016-06-26 +Fixed dependency checking for object files in other directories. +(bugfix, commit f06e550) + +v0.2.4, dated 2016-06-25 +Fixed regression bug that disabled all dependency checking. +(bugfix, commit 1d7bb5e) + +v0.2.3, dated 2016-03-29 +Disabled dependency checking for OSX <= 10.5 because it stalled rebuilds. +(bugfix, issue #16, commit eb614fd) + +v0.2.2, dated 2016-03-28 +Removed target 'pre' because it forced rebuild of everything in 'all'. +(bugfix, issue #17, commit c989c8e) + +v0.2.1, dated 2015-12-27 +Implement / respect 'CPPFLAGS','CFLAGS'and 'LDFLAGS'. +(bugfix, issue #5, commit 98f3582) + +v0.2.0, dated 2015-12-19 +Added per-platform multiline defines 'forLinux', 'forDarwin', 'forWindows'. +(feature, pull request #9, commit 3946ea5) + +v0.1.0, dated 2015-12-08 +Added targets 'pre' and 'post' to automatically run before and after 'all'. +(feature, pull request #4, commit a5678ac) + +v0.0.2, dated 2015-12-06 +Improved methods for searching pd paths. +(bugfix, commit ed37e6b) + +v0.0.1, dated 2015-10-31 +Fixed expansion of variable 'lib.version'. +(bugfix, issue #1, commit 974b617) + +v0.0.0, dated 2015-06-24 +Initial version. +(commit 16517a2) From 058ba82a4792ebd568b9ab29618c1ecf249dd9d9 Mon Sep 17 00:00:00 2001 From: katja Date: Fri, 28 Oct 2016 14:31:01 +0200 Subject: [PATCH 44/86] Add section 'versioning' in README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index c6926b6..75e070e 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,16 @@ paths, and targets. The internal documentation reflects the exact functionality of the particular version. A tips&tricks page is in the works. +### versioning ### + + +The project is versioned in MAJOR.MINOR.BUGFIX format (see http://semver.org), +and maintained at https://github.com/pure-data/pd-lib-builder. Pd lib developers +are invited to regulary check for updates, and to contribute and discuss +improvements here. If you really need to distribute a personalized version with +your library, rename Makefile.pdlibbuilder to avoid confusion. + + ### examples ### From 2e13d8f7a33ab8ea61868b5bcf2403f41cddbe50 Mon Sep 17 00:00:00 2001 From: katja Date: Sun, 30 Oct 2016 21:50:10 +0100 Subject: [PATCH 45/86] Fix bug where incorrect message about m_pd.h is given And bump to version 0.4.2 --- Makefile.pdlibbuilder | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 8be6339..2cc321c 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-10-27 -version = 0.4.1 +# Makefile.pdlibbuilder dated 2016-10-30 +version = 0.4.2 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -692,7 +692,7 @@ else endif # store path to Pd API m_pd.h if it is found -ifdef pdincludepath +ifdef PDINCLUDEDIR mpdh := $(shell ls "$(PDINCLUDEDIR)/m_pd.h") endif From 426b38bb3543b72ba27149dc96020f099f12830f Mon Sep 17 00:00:00 2001 From: katja Date: Wed, 2 Nov 2016 01:27:43 +0100 Subject: [PATCH 46/86] Replace flags '-fpic' with '-fPIC' Reportedly '-fPIC' should work for all architectures while '-fpic' does not. --- Makefile.pdlibbuilder | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 2cc321c..8aa1cb7 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-10-30 -version = 0.4.2 +# Makefile.pdlibbuilder dated 2016-11-02 +version = 0.4.3 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -493,14 +493,14 @@ ifeq ($(system), Linux) pdincludepath := $(wildcard /usr/include/pd) extension = pd_linux cpp.flags := -DUNIX - c.flags := -fpic - c.ldflags := -rdynamic -shared -fpic -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags + c.flags := -fPIC + c.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags c.ldlibs := -lc -lm - cxx.flags := -fpic -fcheck-new - cxx.ldflags := -rdynamic -shared -fpic -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags + cxx.flags := -fPIC -fcheck-new + cxx.ldflags := -rdynamic -shared -fPIC -Wl,-rpath,"\$$ORIGIN",--enable-new-dtags cxx.ldlibs := -lc -lm -lstdc++ shared.extension = so - shared.ldflags := -rdynamic -fpic -shared -Wl,-soname,$(shared.lib) + shared.ldflags := -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib) stripflags = --strip-unneeded -R .note -R .comment endif From 6120db18a56eae468d3665eee8175d74da496db4 Mon Sep 17 00:00:00 2001 From: katja Date: Wed, 2 Nov 2016 01:44:26 +0100 Subject: [PATCH 47/86] Update CHANGELOG.txt --- CHANGELOG.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1c9607c..76e273c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,12 @@ Changelog for Makefile.pdlibbuilder. +v0.4.3, dated 2016-11-02 +Replace flags '-fpic' by 'fPIC'. +(bugfix, issue #29, commit 426b38b) + +v0.4.2, dated 2016-10-30 +Fix issue where incorrect message about m_pd.h is given. +(bugfix, commit 2e13d8f) v0.4.1, dated 2016-10-27 Respect cflag for minimum OSX version when defined by lib makefile. From cdd3b4397801b8a37035bce6d73958db4605df78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 22 Nov 2016 09:45:25 -0500 Subject: [PATCH 48/86] removed trailing whitespace --- Makefile.pdlibbuilder | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 8aa1cb7..dfcfb08 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -106,7 +106,7 @@ version = 0.4.3 #=== descriptions of Makefile.pdlibbuilder API variables ======================= # # -# lib.name: +# lib.name: # Name of the library directory as it will be installed / distributed. Also the # name of the lib executable in the case where all classes are linked into # a single binary. @@ -116,7 +116,7 @@ version = 0.4.3 # into a single lib binary. # # class.sources: -# All sources files (C or C++) for which the condition holds that +# All sources files (C or C++) for which the condition holds that # class name == source file basename. # # .class.sources: @@ -135,13 +135,13 @@ version = 0.4.3 # link libs) for the whole library. These flags are added to platform-specific # flags defined by Makefile.pdlibbuilder. # -# .class.ldflags and .class.ldlibs: +# .class.ldflags and .class.ldlibs: # Define ldflags resp. ldlibs specific to class . These flags are # added to platform-specific flags defined by Makefile.pdlibbuilder, and flags # defined in your Makefile for the whole library. Note: cflags can not be # defined per class in the current implementation. # -# datafiles and datadirs: +# datafiles and datadirs: # All extra files you want to include in binary distributions of the # library: abstractions and help patches, example patches, meta patch, readme # and license texts, manuals, sound files, etcetera. Use 'datafiles' for all @@ -155,7 +155,7 @@ version = 0.4.3 # class.sources += linuxthing.c # endef # -# makefiles and makefiledirs: +# makefiles and makefiledirs: # Extra makefiles or directories with makefiles that should be made in sub-make # processes. # @@ -164,7 +164,7 @@ version = 0.4.3 # Makefile.pdlibbuilder will try to build all classes into a single library # executable (but it will force exit if lib.setup.sources is undefined). # If your makefile defines 'make-lib-executable=yes' as the library default, -# this can still be overriden with 'make-lib-executable=no' as command argument +# this can still be overriden with 'make-lib-executable=no' as command argument # to build individual class executables (the Makefile.pdlibbuilder default.) # # suppress-wunused: @@ -173,7 +173,7 @@ version = 0.4.3 # but the other warnings from -Wall are retained. # # PDDIR: -# Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and +# Root directory of 'portable' pd package. When defined, PDINCLUDEDIR and # PDBINDIR will be evaluated as $(PDDIR)/src and $(PDDIR)/bin. # # PDINCLUDEDIR: @@ -230,9 +230,9 @@ version = 0.4.3 # Source files in directories other than current working directory must be # prefixed with their relative path. Do not rely on VPATH or vpath. # Object (.o) files are built in the directory of their source files. -# Executables are built in current working directory. +# Executables are built in current working directory. # -# Default search path for m_pd.h and other API header files is platform +# Default search path for m_pd.h and other API header files is platform # dependent, and overridable by PDINCLUDEDIR: # # Linux: /usr/include/pd @@ -301,7 +301,7 @@ version = 0.4.3 # are upper case. Use target 'allvars' to print all variables and their values. # # 'Fields' in data variables are separated by dots, like in 'foo.class.sources'. -# Words in variables expressing a function or command are separated by dashes, +# Words in variables expressing a function or command are separated by dashes, # like in 'make-lib-executable'. # # @@ -325,7 +325,7 @@ version = 0.4.3 # #=== end of documentation sections ============================================= # -# +# ################################################################################ ################################################################################ ################################################################################ @@ -340,7 +340,7 @@ ifneq ($(firstword $(sort 3.81 $(MAKE_VERSION))), 3.81) $(error GNU make version 3.81 or higher is required) endif -# Relative path to externals root dir in multi-lib source tree like +# Relative path to externals root dir in multi-lib source tree like # pd-extended SVN. Default is parent of current working directory. May be # defined differently in including makefile. externalsdir ?= .. @@ -357,7 +357,7 @@ Makefile.pdlibbuilder = true # strip possibles spaces from lib.name, they mess up calculated file names lib.name := $(strip $(lib.name)) -# if meta file exists, check library version +# if meta file exists, check library version metafile := $(wildcard $(lib.name)-meta.pd) ifdef metafile @@ -429,7 +429,7 @@ endif #=== flags per architecture ==================================================== -# Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, +# Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, # arch.c.flags are overriden below. machine := $(shell uname -m) @@ -451,7 +451,7 @@ endif # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions ifeq ($(findstring $(machine), ia64 x86_64), $(machine)) - arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 + arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 endif @@ -520,7 +520,7 @@ ifeq ($(system), Darwin) /Applications/Pd*.app/Contents/Resources/src)) extension = pd_darwin cpp.flags := -DUNIX -DMACOSX -I /sw/include - c.flags := + c.flags := c.ldflags := -undefined suppress -flat_namespace -bundle c.ldlibs := -lc cxx.ldflags := -undefined suppress -flat_namespace -bundle @@ -566,7 +566,7 @@ ifeq ($(system), Windows) endif endif -# On Windows we build 32 bit by default to match Pd(-extended) binary +# On Windows we build 32 bit by default to match Pd(-extended) binary # distributions. This may change in the future. # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) @@ -620,7 +620,7 @@ pdincludepathwithspaces := $(if $(word 2, $(PDINCLUDEDIR)), $(PDINCLUDEDIR)) # From GNU make docs: 'Users expect to be able to specify CFLAGS freely # themselves.' So we use CFLAGS to define options which are not strictly -# required for compilation: optimizations, architecture specifications, and +# required for compilation: optimizations, architecture specifications, and # warnings. CFLAGS can be safely overriden using a make command argument. # Variables cflags, ldflags and ldlibs may be defined in including makefile. @@ -679,7 +679,7 @@ compile-cxx := $(CXX) all: # To avoid unpredictable results, make sure the default target is not redefined -# by including makefile. +# by including makefile. ifneq ($(.DEFAULT_GOAL), all) $(error Default target must be 'all'.) endif @@ -753,8 +753,8 @@ MAKEFLAGS += --no-builtin-rules # Target all forces the build of targets [$(executables) post] in -# deterministic order. Target $(executables) builds class executables plus -# optional shared lib or alternatively a single lib executable when +# deterministic order. Target $(executables) builds class executables plus +# optional shared lib or alternatively a single lib executable when # make-lib-executable=true. Target post is optionally defined by # library makefile. @@ -960,7 +960,7 @@ endef %.pre:: %.cc force $(call make-preprocessor-file,cxx) -%.pre:: %.cpp force +%.pre:: %.cpp force $(call make-preprocessor-file,cxx) From cb839ed47085c7d2c70a5605d5715d823bbd2674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 22 Nov 2016 09:48:03 -0500 Subject: [PATCH 49/86] note (within the pd-lib-builder Makefile) how to update the file. --- Makefile.pdlibbuilder | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index dfcfb08..fe9a076 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -6,6 +6,9 @@ version = 0.4.3 # Inspired by Hans Christoph Steiner's Makefile Template and Stephan Beal's # ShakeNMake. # +# Grab the newest version of Makefile.pdlibbuilder from +# https://github.com/pure-data/pd-lib-builder/ +# # GNU make version >= 3.81 required. # # From 2c141109471b01896bfc0ff0d59e1b501d07f0b6 Mon Sep 17 00:00:00 2001 From: katjav Date: Tue, 22 Nov 2016 17:40:13 +0100 Subject: [PATCH 50/86] Use variable 'system' when evaluating 'for{Linux,Darwin,Windows} This evaluates correctly in the case where 'system' is defined for the purpose of cross compiling. This commit addresses issue #31. --- Makefile.pdlibbuilder | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index fe9a076..eba47f9 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-11-02 -version = 0.4.3 +# Makefile.pdlibbuilder dated 2016-11-22 +version = 0.4.4 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. @@ -462,27 +462,26 @@ endif # The following systems are defined: Linux, Darwin, Windows. GNU and -# GNU/kFreeBSD are treated as Linux to get the same options. System-specific -# multiline defines (optionally set in library makefile) are conditionally -# evaluated here. +# GNU/kFreeBSD are treated as Linux to get the same options. uname := $(shell uname) ifeq ($(findstring $(uname), Linux GNU GNU/kFreeBSD), $(uname)) system = Linux - $(eval $(forLinux)) endif ifeq ($(uname), Darwin) system = Darwin - $(eval $(forDarwin)) endif ifeq ($(findstring MINGW, $(uname)), MINGW) system = Windows - $(eval $(forWindows)) endif +# evaluate possible system-specific multiline defines from library makefile +$(eval $(for$(system))) + + # TODO: Cygwin, Android From 872c34b1d3851937251b45a28ba8a91f34c2e2a6 Mon Sep 17 00:00:00 2001 From: katjav Date: Tue, 22 Nov 2016 17:52:04 +0100 Subject: [PATCH 51/86] Update CHANGELOG.txt for v0.4.4 --- CHANGELOG.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 76e273c..58e8b98 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ Changelog for Makefile.pdlibbuilder. +v0.4.4, dated 2016-11-22 +Use variable 'system' when evaluating 'for{Linux,Darwin,Windows}' +(bugfix, issue #31, commit 2c14110) + v0.4.3, dated 2016-11-02 Replace flags '-fpic' by 'fPIC'. (bugfix, issue #29, commit 426b38b) From 4be3e99acb661df7da32ef3bfc4b111dbb0a1a89 Mon Sep 17 00:00:00 2001 From: katjav Date: Sat, 20 Jan 2018 17:18:34 +0100 Subject: [PATCH 52/86] Swap OS and machine detection so OS comes first This is in preparation for target architecture detection through gcc / g++. --- Makefile.pdlibbuilder | 69 ++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index eba47f9..2c052d2 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -425,39 +425,10 @@ endif ################################################################################ -### variables per platform ##################################################### +### platform detection ######################################################### ################################################################################ -#=== flags per architecture ==================================================== - - -# Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, -# arch.c.flags are overriden below. - -machine := $(shell uname -m) - -# Raspberry Pi 1st generation -ifeq ($(machine), armv6l) - arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard -endif - -# Beagle, Udoo, RPi2 etc. -ifeq ($(machine), armv7l) - arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -endif - -# Intel 32 bit, build with SSE and SSE2 instructions -ifeq ($(findstring $(machine), i386 i686), $(machine)) - arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 -endif - -# Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions -ifeq ($(findstring $(machine), ia64 x86_64), $(machine)) - arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 -endif - - #=== operating system ========================================================== @@ -485,6 +456,44 @@ $(eval $(for$(system))) # TODO: Cygwin, Android +#=== architecture ============================================================== + + +machine := $(shell uname -m) + + +################################################################################ +### variables per platform ##################################################### +################################################################################ + + +#=== flags per architecture ==================================================== + + +# Set architecture-dependent cflags, mainly for Linux. For Mac and Windows, +# arch.c.flags are overriden below. + +# Raspberry Pi 1st generation +ifeq ($(machine), armv6l) + arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard +endif + +# Beagle, Udoo, RPi2 etc. +ifeq ($(machine), armv7l) + arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard +endif + +# Intel 32 bit, build with SSE and SSE2 instructions +ifeq ($(findstring $(machine), i386 i686), $(machine)) + arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 +endif + +# Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions +ifeq ($(findstring $(machine), ia64 x86_64), $(machine)) + arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 +endif + + #=== flags and paths for Linux ================================================= From fa3c2ca71d231c067f07b62b689f930373737973 Mon Sep 17 00:00:00 2001 From: katjav Date: Sat, 20 Jan 2018 17:45:31 +0100 Subject: [PATCH 53/86] Introduce variable 'target.arch' It stores the first field of -- triplet as retrieved from command ' -dumpmachine' where is g++ or gcc. --- Makefile.pdlibbuilder | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 2c052d2..d9e67a1 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -449,6 +449,14 @@ ifeq ($(findstring MINGW, $(uname)), MINGW) system = Windows endif +# Unfortunately not all Mingw versions provide a link cc > gcc, therefore +# gcc is hardcoded here (but not if CC is redefined). +ifeq ($(system), Windows) + ifeq ($(origin CC), default) + CC = gcc + endif +endif + # evaluate possible system-specific multiline defines from library makefile $(eval $(for$(system))) @@ -459,7 +467,16 @@ $(eval $(for$(system))) #=== architecture ============================================================== -machine := $(shell uname -m) +# native architecture +machine := $(shell uname --machine) + +# Target architecture as reported by compiler. Give precedence to eventual +# user-defined compiler. The first field of -- is extracted. +ifneq ($(origin CXX), default) + target.arch = $(firstword $(subst -, ,$(shell $(CXX) -dumpmachine))) +else + target.arch = $(firstword $(subst -, ,$(shell $(CC) -dumpmachine))) +endif ################################################################################ @@ -582,8 +599,6 @@ endif # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) extension = dll - CC = gcc - CXX = g++ arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse cpp.flags := -DMSW -DNT c.flags := From ef21a16eb0d8d5f6745a8741e8ca75a5e9caf19f Mon Sep 17 00:00:00 2001 From: katjav Date: Sat, 20 Jan 2018 23:11:15 +0100 Subject: [PATCH 54/86] Introduce architecture dependent settings for Windows --- Makefile.pdlibbuilder | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index d9e67a1..66db349 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -594,13 +594,16 @@ ifeq ($(system), Windows) endif endif -# On Windows we build 32 bit by default to match Pd(-extended) binary -# distributions. This may change in the future. # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) + ifeq ($(findstring $(target.arch), ia64 x86_64), $(target.arch)) + cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 + arch.c.flags := -march=core2 -msse -msse2 -mfpmath=sse + else + cpp.flags := -DMSW -DNT + arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse + endif extension = dll - arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse - cpp.flags := -DMSW -DNT c.flags := c.ldflags = -static-libgcc -shared \ -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" From 37d23530c6be7a97e1cd29fee61db6acbe574283 Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 21 Jan 2018 11:19:43 +0100 Subject: [PATCH 55/86] Leave out architecture 'ia64' As per suggestion of Johannes Zmoelnig. It is not relevant and also not compatible with x86_64. --- Makefile.pdlibbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 66db349..8092166 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -506,7 +506,7 @@ ifeq ($(findstring $(machine), i386 i686), $(machine)) endif # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions -ifeq ($(findstring $(machine), ia64 x86_64), $(machine)) +ifeq ($(findstring $(machine), x86_64), $(machine)) arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 endif @@ -596,7 +596,7 @@ endif # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) - ifeq ($(findstring $(target.arch), ia64 x86_64), $(target.arch)) + ifeq ($(findstring $(target.arch), x86_64), $(target.arch)) cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 arch.c.flags := -march=core2 -msse -msse2 -mfpmath=sse else From f83d4293bdf8bd8b33252ac56d30717221eb95ed Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 21 Jan 2018 11:42:55 +0100 Subject: [PATCH 56/86] Introduce remainder architecture category for Windows And explicitly specify Intel 32 bit architectures, where 'mingw32' is included to support MSYS1. --- Makefile.pdlibbuilder | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 8092166..8bf8328 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -596,12 +596,14 @@ endif # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) - ifeq ($(findstring $(target.arch), x86_64), $(target.arch)) + cpp.flags := -DMSW -DNT + ifeq ($(findstring $(target.arch), i%86 mingw32), $(target.arch)) + arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse + else ifeq (x86_64, $(target.arch)) cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 arch.c.flags := -march=core2 -msse -msse2 -mfpmath=sse else - cpp.flags := -DMSW -DNT - arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse + arch.c.flags = endif extension = dll c.flags := From 867ad5e8e87bfa06770ca2f4c2d26beb5133fd6a Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 21 Jan 2018 11:54:01 +0100 Subject: [PATCH 57/86] Introduce general remainder architecture category --- Makefile.pdlibbuilder | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 8bf8328..4fc4e15 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -493,21 +493,22 @@ endif # Raspberry Pi 1st generation ifeq ($(machine), armv6l) arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard -endif # Beagle, Udoo, RPi2 etc. -ifeq ($(machine), armv7l) +else ifeq ($(machine), armv7l) arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -endif # Intel 32 bit, build with SSE and SSE2 instructions -ifeq ($(findstring $(machine), i386 i686), $(machine)) +else ifeq ($(findstring $(machine), i386 i686), $(machine)) arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 -endif - + # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions -ifeq ($(findstring $(machine), x86_64), $(machine)) +else ifeq ($(findstring $(machine), x86_64), $(machine)) arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 + +# if none of the above architectures detected +else + arch.c.flags = endif From 231e344b440cdf32dcdda9c564a9e67101d32474 Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 21 Jan 2018 12:34:45 +0100 Subject: [PATCH 58/86] Use variables 'build.arch' and 'target.arch' consistently --- Makefile.pdlibbuilder | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 4fc4e15..bce69dd 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -467,15 +467,23 @@ $(eval $(for$(system))) #=== architecture ============================================================== -# native architecture -machine := $(shell uname --machine) +# native architecture of the build machine +build.arch := $(shell uname --machine) # Target architecture as reported by compiler. Give precedence to eventual # user-defined compiler. The first field of -- is extracted. ifneq ($(origin CXX), default) - target.arch = $(firstword $(subst -, ,$(shell $(CXX) -dumpmachine))) + dumpmachine.cpu = $(firstword $(subst -, ,$(shell $(CXX) -dumpmachine))) else - target.arch = $(firstword $(subst -, ,$(shell $(CC) -dumpmachine))) + dumpmachine.cpu = $(firstword $(subst -, ,$(shell $(CC) -dumpmachine))) +endif + +# Target architecture as reported by compiler is only used for Windows at the +# moment. For other systems this still has to be tested. +ifeq ($(system), Windows) + target.arch = $(dumpmachine.cpu) +else + target.arch = $(build.arch) endif @@ -491,19 +499,19 @@ endif # arch.c.flags are overriden below. # Raspberry Pi 1st generation -ifeq ($(machine), armv6l) +ifeq ($(target.arch), armv6l) arch.c.flags = -march=armv6 -mfpu=vfp -mfloat-abi=hard # Beagle, Udoo, RPi2 etc. -else ifeq ($(machine), armv7l) +else ifeq ($(target.arch), armv7l) arch.c.flags = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard # Intel 32 bit, build with SSE and SSE2 instructions -else ifeq ($(findstring $(machine), i386 i686), $(machine)) +else ifeq ($(findstring $(target.arch), i386 i686), $(target.arch)) arch.c.flags = -march=pentium4 -mfpmath=sse -msse -msse2 # Intel/AMD 64 bit, build with SSE, SSE2 and SSE3 instructions -else ifeq ($(findstring $(machine), x86_64), $(machine)) +else ifeq ($(findstring $(target.arch), x86_64), $(target.arch)) arch.c.flags = -march=core2 -mfpmath=sse -msse -msse2 -msse3 # if none of the above architectures detected @@ -560,12 +568,12 @@ ifeq ($(system), Darwin) -compatibility_version 1 -current_version 1.0 stripflags = -x version.flag := $(filter $(cflags), -mmacosx-version-min=%) - ifeq ($(machine), i386) + ifeq ($(target.arch), i386) cxx.flags := -fcheck-new arch := ppc i386 x86_64 version.flag ?= -mmacosx-version-min=10.4 endif - ifeq ($(machine), x86_64) + ifeq ($(target.arch), x86_64) arch := i386 x86_64 version.flag ?= -mmacosx-version-min=10.5 endif From e4d42f22278d9b5a9f02408d7fab2ac94c6ffed8 Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 21 Jan 2018 14:59:38 +0100 Subject: [PATCH 59/86] Assume system is "Windows" when uname says "MSYS" Needed for building with pd-lib-builder on AppVeyor. --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index bce69dd..94c4116 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -445,7 +445,7 @@ ifeq ($(uname), Darwin) system = Darwin endif -ifeq ($(findstring MINGW, $(uname)), MINGW) +ifeq ($(findstring $(uname), MINGW MSYS), $(uname)) system = Windows endif From 77ff876401d991be5af4928e7fed077a19227f6c Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 21 Jan 2018 22:42:47 +0100 Subject: [PATCH 60/86] Fix conditional checks broken in commits e4d42f2 and f83d429 --- Makefile.pdlibbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 94c4116..ca89077 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -445,7 +445,7 @@ ifeq ($(uname), Darwin) system = Darwin endif -ifeq ($(findstring $(uname), MINGW MSYS), $(uname)) +ifeq ($(filter MINGW% MSYS, $(uname)), $(uname)) system = Windows endif @@ -606,7 +606,7 @@ endif # TODO: decide whether -mms-bitfields should be specified. ifeq ($(system), Windows) cpp.flags := -DMSW -DNT - ifeq ($(findstring $(target.arch), i%86 mingw32), $(target.arch)) + ifeq ($(filter i%86 mingw32, $(target.arch)), $(target.arch)) arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse else ifeq (x86_64, $(target.arch)) cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 From 13796bfee28884b8b5aff910cca2d3f6e7924f6c Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 21 Jan 2018 22:52:19 +0100 Subject: [PATCH 61/86] Add option '-msse3' for Windows on x86_64 architecture --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index ca89077..f192f02 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -610,7 +610,7 @@ ifeq ($(system), Windows) arch.c.flags := -march=pentium4 -msse -msse2 -mfpmath=sse else ifeq (x86_64, $(target.arch)) cpp.flags := -DMSW -DNT -DPD_LONGINTTYPE=__int64 - arch.c.flags := -march=core2 -msse -msse2 -mfpmath=sse + arch.c.flags := -march=core2 -msse -msse2 -msse3 -mfpmath=sse else arch.c.flags = endif From a01ee169cd48e4d40f1fc7530a503a1d32fc14c7 Mon Sep 17 00:00:00 2001 From: katjav Date: Mon, 22 Jan 2018 23:19:24 +0100 Subject: [PATCH 62/86] Revert 'uname --machine' to 'uname -m' (bug fix OSX) Long option name '--machine' was introduced in commit fa3c2ca for explicitness, however it is not supported by clang / OSX. --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index f192f02..1a669ab 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -468,7 +468,7 @@ $(eval $(for$(system))) # native architecture of the build machine -build.arch := $(shell uname --machine) +build.arch := $(shell uname -m) # Target architecture as reported by compiler. Give precedence to eventual # user-defined compiler. The first field of -- is extracted. From 80d7dc0a134d6594799a531036a788de2c6d0b2e Mon Sep 17 00:00:00 2001 From: katjav Date: Tue, 23 Jan 2018 21:25:23 +0100 Subject: [PATCH 63/86] Bump version to 0.5.0, ready for Windows 64 bit Update version number after merge commit 215bf3e. This is the first version handling 64 bit builds for Windows. --- CHANGELOG.txt | 5 +++++ Makefile.pdlibbuilder | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 58e8b98..41ac0e2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,10 @@ Changelog for Makefile.pdlibbuilder. +v0.5.0, dated 2018-01-23 +Implement target architecture detection for Windows builds, +and set appropriate options for 32 and 64 bit (used to be for 32 bit only). +(feature, issue #37 #38, merge commit 215bf3e) + v0.4.4, dated 2016-11-22 Use variable 'system' when evaluating 'for{Linux,Darwin,Windows}' (bugfix, issue #31, commit 2c14110) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 1a669ab..1db3f8c 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2016-11-22 -version = 0.4.4 +# Makefile.pdlibbuilder dated 2018-01-23 +version = 0.5.0 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties. From 1361dd399993846b75f451b0dfe121a89d0b2ed0 Mon Sep 17 00:00:00 2001 From: katjav Date: Wed, 24 Jan 2018 13:56:36 +0100 Subject: [PATCH 64/86] Remove unuseful variable 'PD_PATH' The variable was introduced in commit 41e9743 for compatibility with centralized build system as inherited from Pd-extended by Pd-L2ork and Purr Data. But it doesn't work in that context because $(PD_PATH)/bin is absent. Therefore better remove 'PD_PATH' and focus on making variables 'PDDIR' & Co. work as expected. --- Makefile.pdlibbuilder | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 1db3f8c..e7b04a8 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -213,10 +213,6 @@ version = 0.5.0 # INSTALL # Definition of install program. # -# PD_PATH: -# Equivalent to PDDIR. Supported for compatibility with pd-extended central -# makefile, but deprecated otherwise. -# # objectsdir: # Root directory for installation of Pd library directories, like PDLIBDIR but # not overridable by environment. Supported for compatibility with pd-extended @@ -634,10 +630,9 @@ endif # Platform-dependent default paths are specified above, but overridable. # Path variables in upper case can be defined as make command argument or in the -# environment. 'PD_PATH' and 'objectsdir' are supported for compatibility with +# environment. Variable 'objectsdir' is supported for compatibility with # the build system that pd-l2ork has inherited from pd-extended. -PDDIR ?= $(PD_PATH) PDINCLUDEDIR ?= $(pdincludepath) PDBINDIR ?= $(pdbinpath) PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir)) From 77401282570da724d399b14f80329f8f0a6c2250 Mon Sep 17 00:00:00 2001 From: katjav Date: Wed, 24 Jan 2018 22:50:20 +0100 Subject: [PATCH 65/86] Fix priority for user path variables 'PDDIR' & Co. The order of variable expansion prevented this for the path to binary 'pd.dll'. --- Makefile.pdlibbuilder | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index e7b04a8..cb9add5 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -591,12 +591,9 @@ endif # paths for 32-bit executables on 64-bit Windows aren't yet defined here (TODO) ifeq ($(system), Windows) pkglibdir := $(APPDATA)/Pd - ifndef pdbinpath - pdbinpath := $(shell ls -d "$(PROGRAMFILES)/pd/bin") - endif - ifndef pdincludepath - pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/src") - endif + pdbinpath := $(shell ls -d "$(PROGRAMFILES)/pd/bin") + pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/src") + PDBINDIR ?= $(pdbinpath) endif # TODO: decide whether -mms-bitfields should be specified. @@ -613,14 +610,14 @@ ifeq ($(system), Windows) extension = dll c.flags := c.ldflags = -static-libgcc -shared \ - -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" + -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new cxx.ldflags = -static-libstdc++ -shared \ - -Wl,--enable-auto-import "$(pdbinpath)/pd.dll" + -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" cxx.ldlibs := shared.extension = dll - shared.ldflags = -static-libgcc -shared "$(pdbinpath)/pd.dll" + shared.ldflags = -static-libgcc -shared "$(PDBINDIR)/pd.dll" stripflags = --strip-unneeded -R .note -R .comment endif @@ -634,7 +631,6 @@ endif # the build system that pd-l2ork has inherited from pd-extended. PDINCLUDEDIR ?= $(pdincludepath) -PDBINDIR ?= $(pdbinpath) PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir)) ifneq ($(PDDIR),) From 1bcf78f86eac9348e8422365b2c39f8c55f69801 Mon Sep 17 00:00:00 2001 From: katjav Date: Sat, 27 Jan 2018 00:07:21 +0100 Subject: [PATCH 66/86] Define default paths for 32 bit build on 64 bit Windows --- Makefile.pdlibbuilder | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index cb9add5..fe72833 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -588,11 +588,16 @@ endif # variables are assembled or re-expanded later, great care must be taken to put # quotes at appropriate points throughout the makefile. Thanks, Bill. -# paths for 32-bit executables on 64-bit Windows aren't yet defined here (TODO) +# default paths in Mingw environments ifeq ($(system), Windows) pkglibdir := $(APPDATA)/Pd - pdbinpath := $(shell ls -d "$(PROGRAMFILES)/pd/bin") - pdincludepath := $(shell ls -d "$(PROGRAMFILES)/pd/src") + ifeq ($(MINGW_CHOST), i686-w64-mingw32) + programfiles := ${ProgramFiles(x86)} + else + programfiles := $(PROGRAMFILES) + endif + pdbinpath := $(shell ls -d "$(programfiles)/Pd/bin") + pdincludepath := $(shell ls -d "$(programfiles)/Pd/src") PDBINDIR ?= $(pdbinpath) endif From f3887bbe7d7514e2bdf4b9ee80b4044aadcc7d79 Mon Sep 17 00:00:00 2001 From: katjav Date: Sat, 27 Jan 2018 12:40:46 +0100 Subject: [PATCH 67/86] Update Windows search path documentation in makefile --- Makefile.pdlibbuilder | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index fe72833..273d07a 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -238,7 +238,13 @@ version = 0.5.0 # # OSX: /Applications/Pd*.app/Contents/Resources/src # -# Windows: %PROGRAMFILES%/pd/src +# Windows: %PROGRAMFILES%/Pd/src +# %PROGRAMFILES(X86)%/Pd/src (32 bit builds on 64 bit Windows) +# +# Default search path for binary pd.dll (Windows), overridable by PDBINDIR +# +# %PROGRAMFILES%/Pd/bin +# %PROGRAMFILES(X86)%/Pd/bin (32 bit builds on 64 bit Windows) # # Default location to install pd libraries is platform dependent, and # overridable by PDLIBDIR: From 9240b64eba92aaee1e253b38bff728c69a25949f Mon Sep 17 00:00:00 2001 From: katjav Date: Sat, 27 Jan 2018 14:10:12 +0100 Subject: [PATCH 68/86] Evaluate 'PDBINDIR' before ld flags So ld flags can be evaluated as immediate variables. Otherwise it was too confusing, hard to understand why it worked at all. --- Makefile.pdlibbuilder | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 273d07a..1a306db 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -604,6 +604,16 @@ ifeq ($(system), Windows) endif pdbinpath := $(shell ls -d "$(programfiles)/Pd/bin") pdincludepath := $(shell ls -d "$(programfiles)/Pd/src") +endif + +# Store default path to pd.dll in PDBINDIR if the latter is not user-defined. +# For include path this is done in the platform-independent paths section below, +# but for PDBINDIR it is done here so ld flags can be evaluated as immediate +# variables. +ifeq ($(system), Windows) + ifdef PDDIR + PDBINDIR := $(PDDIR)/bin + endif PDBINDIR ?= $(pdbinpath) endif @@ -620,15 +630,15 @@ ifeq ($(system), Windows) endif extension = dll c.flags := - c.ldflags = -static-libgcc -shared \ + c.ldflags := -static-libgcc -shared \ -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new - cxx.ldflags = -static-libstdc++ -shared \ + cxx.ldflags := -static-libstdc++ -shared \ -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" cxx.ldlibs := shared.extension = dll - shared.ldflags = -static-libgcc -shared "$(PDBINDIR)/pd.dll" + shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd.dll" stripflags = --strip-unneeded -R .note -R .comment endif @@ -644,9 +654,8 @@ endif PDINCLUDEDIR ?= $(pdincludepath) PDLIBDIR ?= $(firstword $(objectsdir) $(pkglibdir)) -ifneq ($(PDDIR),) +ifdef PDDIR PDINCLUDEDIR := $(wildcard $(PDDIR)/src) - PDBINDIR := $(wildcard $(PDDIR)/bin) endif # base path where all components of the lib will be installed by default From fe45bcb376ec301dda21adf8f9bf348a485dae70 Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 28 Jan 2018 20:58:12 +0100 Subject: [PATCH 69/86] Avoid ls errors when default paths for Pd on Windows do not exist Such error messages are confusing if you do not intend to use default paths. Therefore the probes with ls are removed. Paths to m_pd.h and pd.dll are probed later in the process when they are possibly overriden by user definitions. --- Makefile.pdlibbuilder | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 1a306db..d1af670 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -602,8 +602,8 @@ ifeq ($(system), Windows) else programfiles := $(PROGRAMFILES) endif - pdbinpath := $(shell ls -d "$(programfiles)/Pd/bin") - pdincludepath := $(shell ls -d "$(programfiles)/Pd/src") + pdbinpath := $(programfiles)/Pd/bin + pdincludepath := $(programfiles)/Pd/src endif # Store default path to pd.dll in PDBINDIR if the latter is not user-defined. @@ -747,6 +747,11 @@ ifdef PDINCLUDEDIR mpdh := $(shell ls "$(PDINCLUDEDIR)/m_pd.h") endif +# store path to pd.dll; if not found, ls will give a useful error +ifeq ($(system), Windows) + pddll := $(shell ls "$(PDBINDIR)/pd.dll") +endif + # print Makefile.pdlibbuilder version $(info ++++ info: using Makefile.pdlibbuilder version $(version)) From 3e974fdf2149a971c78c7be1a4efcbe2d7c51f80 Mon Sep 17 00:00:00 2001 From: katjav Date: Wed, 31 Jan 2018 12:41:26 +0100 Subject: [PATCH 70/86] Update makefile comments related to paths --- Makefile.pdlibbuilder | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index d1af670..fbcb713 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -100,7 +100,6 @@ version = 0.5.0 # # Deprecated path variables: # -# - PD_PATH # - pdincludepath # - pdbinpath # - objectsdir @@ -323,7 +322,6 @@ version = 0.5.0 # - decide whether to use -static-libgcc or shared dll in MinGW # - cygwin support # - android support -# - Windows 64 bit support # - figure out how to handle '$' in filenames # - add makefile template targets dpkg-source dist libdir distclean tags? # @@ -589,12 +587,13 @@ endif # Standard paths on Windows contain spaces, and GNU make functions treat such # paths as lists, with unintended effects. Therefore we must use shell function -# ls instead of make's wildcard, and probe for each standard path individually. -# Using double quotes around paths with spaces is obligatory. Since some path -# variables are assembled or re-expanded later, great care must be taken to put -# quotes at appropriate points throughout the makefile. Thanks, Bill. +# ls instead of make's wildcard when probing for a path, and use double quotes +# when specifying a path in a command argument. -# default paths in Mingw environments +# Default paths in Mingw / Mingw-w64 environments. 'PROGRAMFILES' is standard +# location for builds with native architecture, 'ProgramFiles(x86)' for i686 +# builds on x86_64 Windows (detection method by Lucas Cordiviola). Curly braces +# required because of parentheses in variable name. ifeq ($(system), Windows) pkglibdir := $(APPDATA)/Pd ifeq ($(MINGW_CHOST), i686-w64-mingw32) From f1b0e3c7b6588f31287f237a8158555c1da41643 Mon Sep 17 00:00:00 2001 From: katjav Date: Thu, 1 Feb 2018 21:45:54 +0100 Subject: [PATCH 71/86] Add linker option '-static-libgcc' for C++ code on Windows It seems that standard C libs are needed for C++ externals because of 'extern "C"' functions (setup, Pd API). --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index fbcb713..13c4ef0 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -633,7 +633,7 @@ ifeq ($(system), Windows) -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" c.ldlibs := cxx.flags := -fcheck-new - cxx.ldflags := -static-libstdc++ -shared \ + cxx.ldflags := -static-libgcc -static-libstdc++ -shared \ -Wl,--enable-auto-import "$(PDBINDIR)/pd.dll" cxx.ldlibs := shared.extension = dll From 0493d4a1e81fdfc700bc84d2c06a60aaecc60be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 3 Oct 2016 15:49:36 +0200 Subject: [PATCH 72/86] Started a small tips&tricks page with handy commands to achieve specific goals --- tips-tricks.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tips-tricks.md diff --git a/tips-tricks.md b/tips-tricks.md new file mode 100644 index 0000000..a6728c8 --- /dev/null +++ b/tips-tricks.md @@ -0,0 +1,14 @@ +pd-lib-builder cheatsheet +========================= + + +## cross-compiling W32 binaries from linux + +I'm using the following to cross-compile W32 binaries on my Debian/64bit system, +using `mingw-w64`. + +Assuming you have unzipped a W32 package for Pd into `${WINPDPATH}`, run: + + make system=Windows pdbinpath="${WINPDPATH}/bin/" pdincludepath="${WINPDPATH}/src/" CC=i686-w64-mingw32-gcc + +(if the project uses C++, you might also need to sed `CXX=i686-w64-mingw32-g++`) From b2ce5007092fdd48a4435a604d1f8ab2a630d9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Mon, 3 Oct 2016 15:56:05 +0200 Subject: [PATCH 73/86] sections and TODOs --- tips-tricks.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tips-tricks.md b/tips-tricks.md index a6728c8..79b27d8 100644 --- a/tips-tricks.md +++ b/tips-tricks.md @@ -1,6 +1,7 @@ pd-lib-builder cheatsheet ========================= +# Creating special builds ## cross-compiling W32 binaries from linux @@ -12,3 +13,10 @@ Assuming you have unzipped a W32 package for Pd into `${WINPDPATH}`, run: make system=Windows pdbinpath="${WINPDPATH}/bin/" pdincludepath="${WINPDPATH}/src/" CC=i686-w64-mingw32-gcc (if the project uses C++, you might also need to sed `CXX=i686-w64-mingw32-g++`) + + +## TODO universal binaries on OSX + + +# Project management +## TODO Keeping pd-lib-builder uptodate From 07c5e784f3d42ce4441d06a0a36433893248195a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 15:46:22 +0100 Subject: [PATCH 74/86] document `git subtree` and `git submodule` with heavy WARNING signs --- tips-tricks.md | 167 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 1 deletion(-) diff --git a/tips-tricks.md b/tips-tricks.md index 79b27d8..7d1f8a5 100644 --- a/tips-tricks.md +++ b/tips-tricks.md @@ -19,4 +19,169 @@ Assuming you have unzipped a W32 package for Pd into `${WINPDPATH}`, run: # Project management -## TODO Keeping pd-lib-builder uptodate + +In general it is advised to put the `Makefile.pdlibbuilder` into a separate +subdirectory (e.g. `pd-lib-builder/`). +This makes it much easier to update the `Makefile.pdlibbuilder` later + +You *should* also use a variable to the actual path of the Makefile.pdlibbuilder +(even if you keep it in the root-directory), as this allows easy experimenting +with newer (or older) (or site-specific) versions of the pd-lib-builder +Makefile. + +~~~make +PDLIBBUILDER_DIR=pd-lib-builder/ +include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder +~~~ + +## Keeping pd-lib-builder up-to-date + +### ++`git submodule`++ [DISCOURAGED] + + +#### Initial setup/check-out +To add a new submodule to your repository, just run `git submodule add` and +commit the changes: + +~~~sh +git submodule add https://github.com/pure-data/pd-lib-builder +git commit .gitmodules pd-lib-builder/ -m "Added pd-lib-builder as git-submodule" +~~~ + +#### Cloning your repository with the submodule + +When doing a fresh clone of your repository, pass the `--recursive` option to +automatically fetch all submodules: + +~~~sh +git clone --recursive https://git.example.org/pd/superbonk~.git +~~~ + +If you've cloned non-recursively, you can initialize and update the submodules +manually: + +~~~sh +git submodule init +git submodule update +~~~ + +#### Updating pd-lib-builder +Submodules are usually fixed to a given commit in their repository. +To update the `pd-lib-builder` submodule to the current `master` do something +like: + +~~~sh +cd pd-lib-builder +git checkout master +git pull +cd .. +git status pd-lib-builder +git commit pd-lib-builder -m "Updated pd-lib-builder to current master" +~~~ + +#### Pulling the updated pd-lib-builder into existing clones +After you have pushed the submodule updates in your repository, other clones of +the repository can be updated as follows: + +~~~sh +git pull +~~~ + +The above will make your repository aware, that the submodule is out-of-sync. + +~~~sh +$ LANG=C git status pd-lib-builder +On branch master +Your branch is up to date with 'origin/master'. + +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: pd-lib-builder (new commits) +$ +~~~ + +In order to sync the submodule to the correct commit, run the following: + +~~~sh +git submodule update +~~~ + +#### Drawbacks +`git submodule` has a number of drawbacks: +- it requires special commands to synchronize the submodules, in addition to + synching your repository. +- you must make sure to use an URL for the submodule that is accessible to your + potential users. e.g. using `git@github.com:pure-data/pd-lib-builder` is bad, + because it requires everybody who wants to checkout your sources to have a + github-account - even if they could checkout *your* repository anonymously. +- submodules will be excluded from `git archive`. This means, that if you use a + mainstream git provider (like Github, GitLab, Bitbucket,...) and make releases + by creating a `git tag`, the automatically generated zipfiles with the sources + will lack the submodule - and your users will not be able to compile your + source code. + +In general, I would suggest to **avoid** `git submodule`, and instead use the +better `git subtree` (below). + +### `git subtree` + +With git-subtrees, you make the pd-lib-builder repository (or any other +repository for that matter) part of your own repository - with full history and +everything - put nicely into a distinct subdirectory. + +Support for *manipulating* subtrees has been added with Git-v1.7.11 (May 2012). +The nice thing however is, that from "outside" the subtree is part of your +repository like any other directory. E.g. older versions of Git can clone your +repository with the full subtree (and all it's history) just fine. +You can also use git-archive to make a complete snapshot of your repository +(including the subtree) - nice, if you e.g. want self-contained downloads of +your project from git hosting platforms (like Github, Gitlab, Bitbucket,...) + +In short, `git subtree` is the better `git submodule`. + +So here's how to do it: + +#### Initial setup/check-out +This will create a `pd-lib-builder/` directory containing the full history of +the pd-lib-builder repository up to its release `v0.5.0` + +~~~sh +git subtree add --prefix=pd-lib-builder/ https://github.com/pure-data/pd-lib-builder v0.5.0 +~~~ + +This will automatically merge the `pd-lib-builder/` history into your current +branch, so everything is ready to go. + +#### Cloning your repository with the subtree +Nothing special, really. +Just clone your repository as always: + +~~~sh +git clone https://git.example.org/pd/superbonk~.git +~~~ + +#### Updating pd-lib-builder +Time passes and sooner or later you will find, that there is a shiny new +pd-lib-builder with plenty of bugfixes and new features. +To update your local copy to pd-lib-builder's current `master`, simply run: + +~~~sh +git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master +~~~ + +#### Pulling the updated pd-lib-builder into existing clones +Again, nothing special. +Just pull as always: + +~~~sh +git pull +~~~ + + +#### Further reading +More on the power of `git subtree` can be found online +- https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844 +- https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree +- ... From e9a67fd0d6518aa6b9e9d6d1069c7f1dd74c8645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 15:49:12 +0100 Subject: [PATCH 75/86] use ~~ for strikethrough --- tips-tricks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tips-tricks.md b/tips-tricks.md index 7d1f8a5..8700bc8 100644 --- a/tips-tricks.md +++ b/tips-tricks.md @@ -36,7 +36,7 @@ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder ## Keeping pd-lib-builder up-to-date -### ++`git submodule`++ [DISCOURAGED] +### ~~`git submodule`~~ [DISCOURAGED] #### Initial setup/check-out From e90da163ac8fd7cd0067c96687e171afeeee33ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 15:51:42 +0100 Subject: [PATCH 76/86] Moved git-submodule down the page --- tips-tricks.md | 123 +++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/tips-tricks.md b/tips-tricks.md index 8700bc8..5b4d799 100644 --- a/tips-tricks.md +++ b/tips-tricks.md @@ -36,6 +36,67 @@ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder ## Keeping pd-lib-builder up-to-date +### `git subtree` + +With git-subtrees, you make the pd-lib-builder repository (or any other +repository for that matter) part of your own repository - with full history and +everything - put nicely into a distinct subdirectory. + +Support for *manipulating* subtrees has been added with Git-v1.7.11 (May 2012). +The nice thing however is, that from "outside" the subtree is part of your +repository like any other directory. E.g. older versions of Git can clone your +repository with the full subtree (and all it's history) just fine. +You can also use git-archive to make a complete snapshot of your repository +(including the subtree) - nice, if you e.g. want self-contained downloads of +your project from git hosting platforms (like Github, Gitlab, Bitbucket,...) + +In short, `git subtree` is the better `git submodule`. + +So here's how to do it: + +#### Initial setup/check-out +This will create a `pd-lib-builder/` directory containing the full history of +the pd-lib-builder repository up to its release `v0.5.0` + +~~~sh +git subtree add --prefix=pd-lib-builder/ https://github.com/pure-data/pd-lib-builder v0.5.0 +~~~ + +This will automatically merge the `pd-lib-builder/` history into your current +branch, so everything is ready to go. + +#### Cloning your repository with the subtree +Nothing special, really. +Just clone your repository as always: + +~~~sh +git clone https://git.example.org/pd/superbonk~.git +~~~ + +#### Updating pd-lib-builder +Time passes and sooner or later you will find, that there is a shiny new +pd-lib-builder with plenty of bugfixes and new features. +To update your local copy to pd-lib-builder's current `master`, simply run: + +~~~sh +git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master +~~~ + +#### Pulling the updated pd-lib-builder into existing clones +Again, nothing special. +Just pull as always: + +~~~sh +git pull +~~~ + + +#### Further reading +More on the power of `git subtree` can be found online +- https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844 +- https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree +- ... + ### ~~`git submodule`~~ [DISCOURAGED] @@ -123,65 +184,5 @@ git submodule update source code. In general, I would suggest to **avoid** `git submodule`, and instead use the -better `git subtree` (below). +better `git subtree` (above). -### `git subtree` - -With git-subtrees, you make the pd-lib-builder repository (or any other -repository for that matter) part of your own repository - with full history and -everything - put nicely into a distinct subdirectory. - -Support for *manipulating* subtrees has been added with Git-v1.7.11 (May 2012). -The nice thing however is, that from "outside" the subtree is part of your -repository like any other directory. E.g. older versions of Git can clone your -repository with the full subtree (and all it's history) just fine. -You can also use git-archive to make a complete snapshot of your repository -(including the subtree) - nice, if you e.g. want self-contained downloads of -your project from git hosting platforms (like Github, Gitlab, Bitbucket,...) - -In short, `git subtree` is the better `git submodule`. - -So here's how to do it: - -#### Initial setup/check-out -This will create a `pd-lib-builder/` directory containing the full history of -the pd-lib-builder repository up to its release `v0.5.0` - -~~~sh -git subtree add --prefix=pd-lib-builder/ https://github.com/pure-data/pd-lib-builder v0.5.0 -~~~ - -This will automatically merge the `pd-lib-builder/` history into your current -branch, so everything is ready to go. - -#### Cloning your repository with the subtree -Nothing special, really. -Just clone your repository as always: - -~~~sh -git clone https://git.example.org/pd/superbonk~.git -~~~ - -#### Updating pd-lib-builder -Time passes and sooner or later you will find, that there is a shiny new -pd-lib-builder with plenty of bugfixes and new features. -To update your local copy to pd-lib-builder's current `master`, simply run: - -~~~sh -git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master -~~~ - -#### Pulling the updated pd-lib-builder into existing clones -Again, nothing special. -Just pull as always: - -~~~sh -git pull -~~~ - - -#### Further reading -More on the power of `git subtree` can be found online -- https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844 -- https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree -- ... From fa7f798c54e4a9f9d2b2888823fd8c820af2ba49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 15:52:58 +0100 Subject: [PATCH 77/86] drop "pd-lib-builder" from headings when there's only general advise --- tips-tricks.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tips-tricks.md b/tips-tricks.md index 5b4d799..913abb4 100644 --- a/tips-tricks.md +++ b/tips-tricks.md @@ -73,7 +73,7 @@ Just clone your repository as always: git clone https://git.example.org/pd/superbonk~.git ~~~ -#### Updating pd-lib-builder +#### Updating the subtree Time passes and sooner or later you will find, that there is a shiny new pd-lib-builder with plenty of bugfixes and new features. To update your local copy to pd-lib-builder's current `master`, simply run: @@ -82,7 +82,7 @@ To update your local copy to pd-lib-builder's current `master`, simply run: git subtree pull --prefix pd-lib-builder/ https://github.com/pure-data/pd-lib-builder master ~~~ -#### Pulling the updated pd-lib-builder into existing clones +#### Pulling the updated subtree into existing clones Again, nothing special. Just pull as always: @@ -126,7 +126,7 @@ git submodule init git submodule update ~~~ -#### Updating pd-lib-builder +#### Updating the submodule Submodules are usually fixed to a given commit in their repository. To update the `pd-lib-builder` submodule to the current `master` do something like: @@ -140,7 +140,7 @@ git status pd-lib-builder git commit pd-lib-builder -m "Updated pd-lib-builder to current master" ~~~ -#### Pulling the updated pd-lib-builder into existing clones +#### Pulling the updated submodule into existing clones After you have pushed the submodule updates in your repository, other clones of the repository can be updated as follows: From 7e47b9878b70da44af8b7f597d316bc0cb0d9121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 16:02:26 +0100 Subject: [PATCH 78/86] how to build double/W64/double+W64 externals --- tips-tricks.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tips-tricks.md b/tips-tricks.md index 913abb4..7c1f1da 100644 --- a/tips-tricks.md +++ b/tips-tricks.md @@ -14,6 +14,29 @@ Assuming you have unzipped a W32 package for Pd into `${WINPDPATH}`, run: (if the project uses C++, you might also need to sed `CXX=i686-w64-mingw32-g++`) +## building double-precision externals + +At the time of writing (2018-02) there is no official Pd that supports +double-precision numbers yet. +However, if you do get hold of an experimental double-precision Pd, you can +easily build your externals for 64-bit numbers: + + make CPPFLAGS="-DPD_FLOATSIZE=64" + +## building externals for W64 (64-bit Windows) + +At the time of writing (2018-02) there is no official Pd that supports +W64 yet. +However, if you do get hold of an experimental W64 Pd, you can +easily build your externals for this environment with + + make CPPFLAGS="-DPD_LONGINTTYPE=__int64" CC=x86_64-w64-mingw32-gcc + + +To build a double-precision external for W64, use something like: + + make CPPFLAGS="-DPD_LONGINTTYPE=__int64 -DPD_FLOATSIZE=64" CC=x86_64-w64-mingw32-gcc + ## TODO universal binaries on OSX From b715b0e2caf36430ba0de49e4275d143c1123e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 16:18:37 +0100 Subject: [PATCH 79/86] sed -e's| sed | set |' --- tips-tricks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tips-tricks.md b/tips-tricks.md index 7c1f1da..084f9ef 100644 --- a/tips-tricks.md +++ b/tips-tricks.md @@ -12,7 +12,7 @@ Assuming you have unzipped a W32 package for Pd into `${WINPDPATH}`, run: make system=Windows pdbinpath="${WINPDPATH}/bin/" pdincludepath="${WINPDPATH}/src/" CC=i686-w64-mingw32-gcc -(if the project uses C++, you might also need to sed `CXX=i686-w64-mingw32-g++`) +(if the project uses C++, you might also need to set `CXX=i686-w64-mingw32-g++`) ## building double-precision externals From 1b9f3d8895f92af25d85ae45a2acf57bae443663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 21:45:58 +0100 Subject: [PATCH 80/86] Do wildcard-search for MSYS when checking Windows platform --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 13c4ef0..5ee3935 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -445,7 +445,7 @@ ifeq ($(uname), Darwin) system = Darwin endif -ifeq ($(filter MINGW% MSYS, $(uname)), $(uname)) +ifeq ($(filter MINGW% MSYS%, $(uname)), $(uname)) system = Windows endif From 44a32fd0094364bc31a7574996653cea8eadef09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 7 Feb 2018 16:23:51 +0100 Subject: [PATCH 81/86] fixed small typo --- Makefile.pdlibbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 5ee3935..ed084d5 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -166,7 +166,7 @@ version = 0.5.0 # Makefile.pdlibbuilder will try to build all classes into a single library # executable (but it will force exit if lib.setup.sources is undefined). # If your makefile defines 'make-lib-executable=yes' as the library default, -# this can still be overriden with 'make-lib-executable=no' as command argument +# this can still be overridden with 'make-lib-executable=no' as command argument # to build individual class executables (the Makefile.pdlibbuilder default.) # # suppress-wunused: From 6bfaba6df09afdb501e399c643e4782a36f9ca02 Mon Sep 17 00:00:00 2001 From: katjav Date: Sun, 18 Feb 2018 14:33:11 +0100 Subject: [PATCH 82/86] Introduce target 'install-strip' in the battle against Mingw-w64 bloat It seems that externals built with Mingw-w64 are ~10 times larger than equivalent builds on other platforms (including original Mingw). Stripping is therefore desirable. As suggested by IOhannes Zmoelnig stripping is not done by default, instead this alternative installation target is provided (like in autotools). --- Makefile.pdlibbuilder | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index ed084d5..8849983 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -268,6 +268,7 @@ version = 0.5.0 # .lst: make asm/source output file in current working directory # # install: install executables and data files +# install-strip: install executables (stripped) and data files # clean: remove build products from source tree # # help: print help text @@ -538,7 +539,6 @@ ifeq ($(system), Linux) cxx.ldlibs := -lc -lm -lstdc++ shared.extension = so shared.ldflags := -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib) - stripflags = --strip-unneeded -R .note -R .comment endif @@ -566,7 +566,6 @@ ifeq ($(system), Darwin) shared.ldflags = -dynamiclib -undefined dynamic_lookup \ -install_name @loader_path/$(shared.lib) \ -compatibility_version 1 -current_version 1.0 - stripflags = -x version.flag := $(filter $(cflags), -mmacosx-version-min=%) ifeq ($(target.arch), i386) cxx.flags := -fcheck-new @@ -638,7 +637,6 @@ ifeq ($(system), Windows) cxx.ldlibs := shared.extension = dll shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd.dll" - stripflags = --strip-unneeded -R .note -R .comment endif @@ -1055,8 +1053,11 @@ endef # -p = preserve time stamps # -m = set permission mode (as in chmod) # -d = create all components of specified directories + +# Use recursive expansion for INSTALL_PROGRAM because variable 'stripflags' is +# not defined yet, it is target-specific for 'install-strip'. INSTALL = install -INSTALL_PROGRAM := $(INSTALL) -p -m 644 +INSTALL_PROGRAM = $(INSTALL) $(stripflags) -p -m 644 INSTALL_DATA := $(INSTALL) -p -m 644 INSTALL_DIR := $(INSTALL) -m 755 -d @@ -1092,6 +1093,13 @@ install-datadirs: all $(info ++++ info: data directories of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) +# definition of strip command must be overridable from environment +STRIP ?= strip + +# install everything while stripping symbols of executables +install-strip: stripflags := --strip-program=$(STRIP) -s +install-strip: install + ################################################################################ ### rules: distribution targets ################################################ From f334dd4e475dedbc98ee3ef31d56312c18536deb Mon Sep 17 00:00:00 2001 From: katjav Date: Mon, 12 Mar 2018 08:47:08 +0100 Subject: [PATCH 83/86] Revert "Introduce target 'install-strip' in the battle against Mingw-w64 bloat" This reverts commit 6bfaba6. Target 'install-strip' wasn't a good idea. A library makefile may want to define a post install target. Makefile.pdlibbuilder should define only one installation target, that can be defined as prerequisite for other targets. A stripping method is still needed, but not this one. --- Makefile.pdlibbuilder | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 8849983..ed084d5 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -268,7 +268,6 @@ version = 0.5.0 # .lst: make asm/source output file in current working directory # # install: install executables and data files -# install-strip: install executables (stripped) and data files # clean: remove build products from source tree # # help: print help text @@ -539,6 +538,7 @@ ifeq ($(system), Linux) cxx.ldlibs := -lc -lm -lstdc++ shared.extension = so shared.ldflags := -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib) + stripflags = --strip-unneeded -R .note -R .comment endif @@ -566,6 +566,7 @@ ifeq ($(system), Darwin) shared.ldflags = -dynamiclib -undefined dynamic_lookup \ -install_name @loader_path/$(shared.lib) \ -compatibility_version 1 -current_version 1.0 + stripflags = -x version.flag := $(filter $(cflags), -mmacosx-version-min=%) ifeq ($(target.arch), i386) cxx.flags := -fcheck-new @@ -637,6 +638,7 @@ ifeq ($(system), Windows) cxx.ldlibs := shared.extension = dll shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd.dll" + stripflags = --strip-unneeded -R .note -R .comment endif @@ -1053,11 +1055,8 @@ endef # -p = preserve time stamps # -m = set permission mode (as in chmod) # -d = create all components of specified directories - -# Use recursive expansion for INSTALL_PROGRAM because variable 'stripflags' is -# not defined yet, it is target-specific for 'install-strip'. INSTALL = install -INSTALL_PROGRAM = $(INSTALL) $(stripflags) -p -m 644 +INSTALL_PROGRAM := $(INSTALL) -p -m 644 INSTALL_DATA := $(INSTALL) -p -m 644 INSTALL_DIR := $(INSTALL) -m 755 -d @@ -1093,13 +1092,6 @@ install-datadirs: all $(info ++++ info: data directories of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) -# definition of strip command must be overridable from environment -STRIP ?= strip - -# install everything while stripping symbols of executables -install-strip: stripflags := --strip-program=$(STRIP) -s -install-strip: install - ################################################################################ ### rules: distribution targets ################################################ From 397b72eb9e1f30062c6dc053fda3134454eab4c9 Mon Sep 17 00:00:00 2001 From: katjav Date: Mon, 12 Mar 2018 09:34:57 +0100 Subject: [PATCH 84/86] Strip when 'stripflags' is defined (default for Windows only) Stripping of installed binaries for Windows is done by default because their unstripped size is ridiculously large when built with Mingw-w64. This default behavior can still be overriden by defining 'stripflags' empty during install. --- Makefile.pdlibbuilder | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index ed084d5..f5f7edd 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -538,7 +538,6 @@ ifeq ($(system), Linux) cxx.ldlibs := -lc -lm -lstdc++ shared.extension = so shared.ldflags := -rdynamic -fPIC -shared -Wl,-soname,$(shared.lib) - stripflags = --strip-unneeded -R .note -R .comment endif @@ -566,7 +565,6 @@ ifeq ($(system), Darwin) shared.ldflags = -dynamiclib -undefined dynamic_lookup \ -install_name @loader_path/$(shared.lib) \ -compatibility_version 1 -current_version 1.0 - stripflags = -x version.flag := $(filter $(cflags), -mmacosx-version-min=%) ifeq ($(target.arch), i386) cxx.flags := -fcheck-new @@ -638,7 +636,7 @@ ifeq ($(system), Windows) cxx.ldlibs := shared.extension = dll shared.ldflags := -static-libgcc -shared "$(PDBINDIR)/pd.dll" - stripflags = --strip-unneeded -R .note -R .comment + stripflags = --strip-all endif @@ -1048,10 +1046,33 @@ endef ################################################################################ +#=== strip ===================================================================== + + +# Stripping of installed binaries will only be done when variable 'stripflags' +# is defined non-empty. No default definition is provided except for Windows +# where the unstripped binaries are large, especially in the case of Mingw-w64. + +# Note: while stripping all symbols ('-s' or '--strip-all') is possible for +# Linux and Windows, in the case of OSX only non-global symbols can be stripped +# (option '-x' or '--discard-all'). + +# Make definition of strip command overridable so it can be defined in an +# environment for cross-compilation. +STRIP ?= strip + +# Commands in 'strip-executables' will be executed conditionally in the rule for +# target 'install-executables'. +strip-executables = cd "$(installpath)" && \ + $(foreach v, $(executables), $(STRIP) $(stripflags) '$v';) + + +#=== install =================================================================== + + # Install targets depend on successful exit status of target all because nothing # must be installed in case of a build error. - # -p = preserve time stamps # -m = set permission mode (as in chmod) # -d = create all components of specified directories @@ -1077,6 +1098,7 @@ install-executables: all $(INSTALL_PROGRAM) '$v' "$(installpath)";) $(info ++++ info: executables of lib $(lib.name) installed \ from $(CURDIR) to $(installpath)) + $(if $(stripflags), $(strip-executables),) install-datafiles: all $(INSTALL_DIR) -v "$(installpath)" From 5b4f636ed80e1c37cb0b73a0a36fe4c0b3faf23b Mon Sep 17 00:00:00 2001 From: katjav Date: Thu, 15 Mar 2018 09:39:11 +0100 Subject: [PATCH 85/86] Document 'STRIP' variable --- Makefile.pdlibbuilder | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index f5f7edd..3ddddfc 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -96,6 +96,7 @@ version = 0.5.0 # - CC # - CXX # - INSTALL +# - STRIP # - DESTDIR # # Deprecated path variables: @@ -212,6 +213,10 @@ version = 0.5.0 # INSTALL # Definition of install program. # +# STRIP +# Name of strip program. Default 'strip' can be overridden in cross compilation +# environments. +# # objectsdir: # Root directory for installation of Pd library directories, like PDLIBDIR but # not overridable by environment. Supported for compatibility with pd-extended From b19fe37198aed1f848e5a66bc4d5aad9b1a3f2ee Mon Sep 17 00:00:00 2001 From: katjav Date: Thu, 15 Mar 2018 22:04:08 +0100 Subject: [PATCH 86/86] Bump version to 0.5.1 for several Windows fixes --- CHANGELOG.txt | 10 ++++++++++ Makefile.pdlibbuilder | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 41ac0e2..971cf80 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,15 @@ Changelog for Makefile.pdlibbuilder. +v0.5.1, dated 2018-03-15 +Fixes and improvements for Windows builds: +- properly evaluate variables 'PDDIR' and 'PDBINDIR' to find pd.dll +- define default path of 32 bit Pd on 64 bit Windows +- link C++ externals with standard C libs on Windows, they don't load otherwise +- strip installed Windows binaries by default +(issues #34, #39, #41, #42 respectively) +Warning for all platforms: variable 'PD_PATH' is no longer supported, use the +equivalent 'PDDIR'. + v0.5.0, dated 2018-01-23 Implement target architecture detection for Windows builds, and set appropriate options for 32 and 64 bit (used to be for 32 bit only). diff --git a/Makefile.pdlibbuilder b/Makefile.pdlibbuilder index 3ddddfc..f81edfe 100644 --- a/Makefile.pdlibbuilder +++ b/Makefile.pdlibbuilder @@ -1,5 +1,5 @@ -# Makefile.pdlibbuilder dated 2018-01-23 -version = 0.5.0 +# Makefile.pdlibbuilder dated 2018-03-15 +version = 0.5.1 # Helper makefile for Pure Data external libraries. # Written by Katja Vetter March-June 2015 for the public domain. No warranties.