| 1 |
# |
| 2 |
# FAUST compiler makefile |
| 3 |
# |
| 4 |
|
| 5 |
ARCHS ?= |
| 6 |
LLVM ?= |
| 7 |
|
| 8 |
LLVM_PACKAGE_VERSION ?= |
| 9 |
LLVM_DIR ?= |
| 10 |
LLVM_LIB_DIR ?= |
| 11 |
LLVM_INCLUDE_DIRS ?= |
| 12 |
LLVM_LIBS ?= |
| 13 |
LLVM_DEFINITIONS ?= |
| 14 |
LLVM_LD_FLAGS ?= |
| 15 |
INCLUDE_LLVM ?= OFF |
| 16 |
USE_LLVM_CONFIG ?= ON |
| 17 |
|
| 18 |
BUILD_HTTP_STATIC ?= OFF |
| 19 |
USE_STATIC_SNDFILE ?= 0 |
| 20 |
MAXSDK ?= $(shell echo $(PWD)/../max-sdk-base/c74support) |
| 21 |
|
| 22 |
# start to determine the current platform |
| 23 |
system := $(shell uname -s) |
| 24 |
# normalizes MINGW versions |
| 25 |
system := $(shell echo $(system) | grep MINGW > /dev/null && echo MINGW || echo $(system)) |
| 26 |
|
| 27 |
#=============================================================== |
| 28 |
# output directories |
| 29 |
FAUSTDIR ?= faustdir |
| 30 |
IOSDIR := iosdir |
| 31 |
VERSION := 2.85.9 |
| 32 |
|
| 33 |
#=============================================================== |
| 34 |
# current generator and backends |
| 35 |
CACHE = $(FAUSTDIR)/CMakeCache.txt |
| 36 |
BCACHE = $(FAUSTDIR)/backends.txt |
| 37 |
TCACHE = $(FAUSTDIR)/targets.txt |
| 38 |
LCACHE = $(FAUSTDIR)/libsdir.txt |
| 39 |
ifeq ($(system), MINGW) |
| 40 |
GENERATOR ?= $(shell [ -f $(CACHE) ] && (grep CMAKE_GENERATOR:INTERNAL $(CACHE) | cut -d= -f2) || echo MSYS Makefiles) |
| 41 |
NATIVEPACK = winpack |
| 42 |
else |
| 43 |
PREFIX ?= /usr/local |
| 44 |
GENERATOR ?= $(shell [ -f $(CACHE) ] && (grep CMAKE_GENERATOR:INTERNAL $(CACHE) | cut -d= -f2) || echo Unix Makefiles) |
| 45 |
endif |
| 46 |
DESTDIR ?= |
| 47 |
|
| 48 |
ifeq ($(system), MINGW) |
| 49 |
NATIVEPACK = winpack |
| 50 |
else ifeq ($(system), Darwin) |
| 51 |
NATIVEPACK = macpack |
| 52 |
else |
| 53 |
NATIVEPACK = linuxpack |
| 54 |
endif |
| 55 |
DESTDIR ?= |
| 56 |
|
| 57 |
.PHONY: faust install uninstall osc http package wasmglue cmake |
| 58 |
|
| 59 |
MAKE ?= make |
| 60 |
CMAKE ?= $(shell which cmake) |
| 61 |
|
| 62 |
WORKLET ?= no |
| 63 |
WORKLETOPT = "-DWORKLET=off" |
| 64 |
ifeq ($(WORKLET), on) |
| 65 |
WORKLETOPT = "-DWORKLET=on" |
| 66 |
endif |
| 67 |
|
| 68 |
NONDETERMINISM_LINT ?= no |
| 69 |
NONDETERMINISM_LINT_OPT = |
| 70 |
CXX_COMPILER_OPT = |
| 71 |
ifeq ($(NONDETERMINISM_LINT), yes) |
| 72 |
NONDETERMINISM_LINT_OPT = "-DNONDETERMINISM_LINT=ON" |
| 73 |
CXX_COMPILER_OPT = "-DCMAKE_CXX_COMPILER=$(shell llvm-config --bindir)/clang++" |
| 74 |
endif |
| 75 |
|
| 76 |
RELEASE_TYPE ?= Release |
| 77 |
#RELEASE_TYPE ?= Debug |
| 78 |
CMAKEOPT ?= |
| 79 |
BUILDOPT ?= --config $(RELEASE_TYPE) |
| 80 |
CMAKEOPTS = -DCMAKE_BUILD_TYPE=$(RELEASE_TYPE) $(WORKLETOPT) $(CMAKEOPT) $(NONDETERMINISM_LINT_OPT) $(CXX_COMPILER_OPT) |
| 81 |
|
| 82 |
#CMAKEOPT ?= -DCMAKE_BUILD_TYPE=Debug $(WORKLETOPT) |
| 83 |
#BUILDOPT ?= --config Debug |
| 84 |
|
| 85 |
#=============================================================== |
| 86 |
# options |
| 87 |
BACKENDS ?= $(shell [ -f $(BCACHE) ] && (grep BACKENDS $(BCACHE) | cut -d= -f2) || echo regular.cmake) |
| 88 |
TARGETS ?= $(shell [ -f $(TCACHE) ] && (grep TARGETS $(TCACHE) | cut -d= -f2) || echo regular.cmake) |
| 89 |
LIBSDIR ?= $(shell [ -f $(LCACHE) ] && (grep LIBSDIR $(LCACHE) | cut -d= -f2) || echo lib) |
| 90 |
EMCC ?= emcc |
| 91 |
|
| 92 |
#=============================================================== |
| 93 |
ifeq ($(GENERATOR), Xcode) |
| 94 |
PROJ = $(FAUSTDIR)/faust.xcodeproj |
| 95 |
endif |
| 96 |
ifneq (,$(findstring Makefile, $(GENERATOR))) |
| 97 |
PROJ = $(FAUSTDIR)/Makefile |
| 98 |
endif |
| 99 |
ifneq (,$(findstring Visual Studio,$(GENERATOR))) |
| 100 |
PROJ = $(FAUSTDIR)/faust.sln |
| 101 |
endif |
| 102 |
|
| 103 |
#=============================================================== |
| 104 |
# main targets |
| 105 |
all: $(PROJ) |
| 106 |
$(CMAKE) --build $(FAUSTDIR) $(BUILDOPT) |
| 107 |
|
| 108 |
full: |
| 109 |
$(MAKE) cmake BACKENDS=all.cmake TARGETS=all.cmake |
| 110 |
$(CMAKE) --build $(FAUSTDIR) $(BUILDOPT) |
| 111 |
|
| 112 |
clean: |
| 113 |
$(CMAKE) --build $(FAUSTDIR) --target clean |
| 114 |
rm -f lib/libfaustwithllvm.a |
| 115 |
|
| 116 |
distclean: |
| 117 |
rm -rf $(FAUSTDIR) |
| 118 |
|
| 119 |
#=============================================================== |
| 120 |
help: |
| 121 |
@echo "-------- FAUST compiler makefile --------" |
| 122 |
@echo "Available targets are:" |
| 123 |
@echo " 'all' (default) : builds the current targets (as defined by your targets setup)." |
| 124 |
@echo " 'full' : builds the all targets with all backends." |
| 125 |
@echo |
| 126 |
@echo "Targets that require specific setup (see TARGETS option):" |
| 127 |
@echo " 'faust' : builds the Faust compiler." |
| 128 |
@echo " 'osc' : builds the static Faust OSC libraries" |
| 129 |
@echo " 'http' : builds the static Faust HTTPD libraries" |
| 130 |
@echo " 'staticlib' : builds the libfaust library in static mode." |
| 131 |
@echo " 'dynamiclib' : builds the libfaust library in dynamic mode." |
| 132 |
@echo " 'oscdynamic' : builds the OSC library in dynamic mode." |
| 133 |
@echo " 'httpdynamic': builds the HTTPD library in dynamic mode." |
| 134 |
@echo " 'oscandroid' : builds the OSC library for Android." |
| 135 |
@echo " 'ioslib' : builds the libfaust static lib for iOS (makes use of the ios.cmake backend)" |
| 136 |
@echo |
| 137 |
@echo "Cleaning:" |
| 138 |
@echo " 'clean' : removes the output of the 'all' targets" |
| 139 |
@echo " 'distclean' : removes the 'FAUSTDIR' folder ($(FAUSTDIR)) but preserves the bin and lib folders" |
| 140 |
@echo |
| 141 |
@echo "Targets excluded from all:" |
| 142 |
@echo " 'wasmlib' : builds libfaust as a WebAssembly library" |
| 143 |
@echo " 'wasmglue' : builds the WebAssembly glue library." |
| 144 |
@echo |
| 145 |
@echo "Available options:" |
| 146 |
@echo " FAUSTDIR=<dir> : the compilation directory. Default to '$(FAUSTDIR)'" |
| 147 |
@echo " LIBSDIR : the libraries destination directory, default: $(LIBSDIR)" |
| 148 |
@echo " GENERATOR=<a cmake generator>: see cmake -h. Default to '$(GENERATOR)'" |
| 149 |
@echo " CMAKEOPT=<cmake options> : pass extra options to cmake for project generation." |
| 150 |
@echo " RELEASE_TYPE : cmake release type (defaults to Release)." |
| 151 |
@echo " BUILDOPT=<cmake options> : pass options to cmake at build time (default to $(BUILDOPT))." |
| 152 |
@echo " BACKENDS=<backends file> : see 'Backends' below" |
| 153 |
@echo " TARGETS=<targets file> : see 'Targets' below" |
| 154 |
@echo " WORKLET : Compile wasm glue library for worklet (default is off)" |
| 155 |
@echo |
| 156 |
@echo "Backends:" |
| 157 |
@echo " the Faust backends currently included are described in the '$(BACKENDS)' file" |
| 158 |
@echo " you can freely customize this file or use another file with the BACKENDS option" |
| 159 |
@echo |
| 160 |
@echo "Targets:" |
| 161 |
@echo " the targets currently included are described in the '$(TARGETS)' file" |
| 162 |
@echo " you can freely customize this file or use another file with the TARGETS option" |
| 163 |
@echo |
| 164 |
@echo "Utilities targets:" |
| 165 |
@echo " 'cmake' : regenerate the project using the current config" |
| 166 |
@echo " 'universal' : [macOS] set the universal binaries option ON (x86_64 and arm64)." |
| 167 |
@echo " 'native' : [macOS] set the universal binaries option OFF." |
| 168 |
@echo " 'verbose' : turn the verbose makefile option ON." |
| 169 |
@echo " 'silent' : turn the verbose makefile option OFF." |
| 170 |
@echo " 'jsscripts' : to rebuild javascript resources (from architecture/httpdlib)." |
| 171 |
@echo |
| 172 |
@echo "Installation targets:" |
| 173 |
@echo " 'install' : install faust to the target directory (default to $(DESTDIR)$(PREFIX))," |
| 174 |
@echo " 'uninstall' : remove previously installed files," |
| 175 |
@echo "Installation options:" |
| 176 |
@echo " 'DESTDIR' : the destination directory," |
| 177 |
@echo " 'PREFIX' : the destination prefix," |
| 178 |
@echo " Note that when using a relative path, it is relative to FAUSTDIR ($(FAUSTDIR))" |
| 179 |
@echo "------ see also the README.md file ------" |
| 180 |
@echo |
| 181 |
@echo "Packaging targets:" |
| 182 |
@echo " 'package' : build a Faust package for the current platform" |
| 183 |
@echo " 'release' : build a Faust release (macOS only)" |
| 184 |
@echo " includes faust, faustgen and dist packages" |
| 185 |
|
| 186 |
|
| 187 |
faust: $(PROJ) |
| 188 |
$(CMAKE) --build $(FAUSTDIR) --target faust $(BUILDOPT) |
| 189 |
|
| 190 |
osc: $(PROJ) |
| 191 |
$(CMAKE) --build $(FAUSTDIR) --target oscstatic $(BUILDOPT) |
| 192 |
|
| 193 |
oscdynamic: $(PROJ) |
| 194 |
$(CMAKE) --build $(FAUSTDIR) --target oscdynamic $(BUILDOPT) |
| 195 |
|
| 196 |
oscandroid: $(PROJ) |
| 197 |
cd ../architecture/osclib/android/&& ndk-build |
| 198 |
|
| 199 |
http: $(PROJ) |
| 200 |
$(CMAKE) --build $(FAUSTDIR) --target httpstatic $(BUILDOPT) |
| 201 |
|
| 202 |
httpdynamic: $(PROJ) |
| 203 |
$(CMAKE) --build $(FAUSTDIR) --target httpdynamic $(BUILDOPT) |
| 204 |
|
| 205 |
jsscripts: |
| 206 |
$(MAKE) -C ../architecture/httpdlib/src/hexa |
| 207 |
|
| 208 |
#=============================================================== |
| 209 |
# packaging |
| 210 |
#=============================================================== |
| 211 |
# don't change the PACK variable, files are put at first hierarchy level |
| 212 |
PACK := package/Faust-$(VERSION) |
| 213 |
package: |
| 214 |
$(MAKE) $(NATIVEPACK) |
| 215 |
|
| 216 |
winpack: |
| 217 |
cd $(FAUSTDIR) && $(CMAKE) -DUSE_LLVM_CONFIG=off -DPACK=on -C ../backends/most.cmake -C ../targets/most.cmake .. |
| 218 |
$(MAKE) |
| 219 |
cd $(FAUSTDIR) && cpack -G NSIS64 |
| 220 |
mv $(FAUSTDIR)/Faust-*.exe . |
| 221 |
|
| 222 |
macpack: package/README.html |
| 223 |
-[ -d $(PACK) ] && rm -rf $(PACK) |
| 224 |
$(MAKE) cmake BACKENDs=all.cmake TARGETS=all.cmake |
| 225 |
$(MAKE) install PREFIX=../$(PACK)/Faust-$(VERSION) |
| 226 |
$(MAKE) mactools FAUSTDIR=../../build/$(PACK)/Faust-$(VERSION) |
| 227 |
cp package/INSTALL.html $(PACK) |
| 228 |
cp package/README.html $(PACK) |
| 229 |
for i in {1..30}; do hdiutil create Faust-$(VERSION).dmg -fs HFS+ -srcfolder $(PACK) -format UDBZ -ov -quiet && break; sleep 2; done |
| 230 |
|
| 231 |
mactools: |
| 232 |
$(MAKE) -C ../tools/benchmark FAUSTDIR=$(FAUSTDIR) TARGETS="dynamic-faust faustbench-llvm interp-tracer" LLVM="$(LLVM)" ARCHS="$(ARCHS)" USE_STATIC_SNDFILE=$(USE_STATIC_SNDFILE) |
| 233 |
$(MAKE) -C ../tools/benchmark install PREFIX=$(FAUSTDIR) FAUSTDIR=$(FAUSTDIR) TARGETS="dynamic-faust faustbench-llvm interp-tracer" LLVM="$(LLVM)" ARCHS="$(ARCHS)" USE_STATIC_SNDFILE=$(USE_STATIC_SNDFILE) |
| 234 |
$(MAKE) -C ../tools/sound2faust TARGETS="sound2faust sound2file" ARCHS="$(ARCHS)" USE_STATIC_SNDFILE=$(USE_STATIC_SNDFILE) |
| 235 |
$(MAKE) -C ../tools/sound2faust install PREFIX=$(FAUSTDIR) TARGETS="sound2faust sound2file" ARCHS="$(ARCHS)" USE_STATIC_SNDFILE=$(USE_STATIC_SNDFILE) |
| 236 |
|
| 237 |
linuxpack: |
| 238 |
@echo Linux packaging not implemented. |
| 239 |
|
| 240 |
package/README.html: ../README.md |
| 241 |
echo "<!DOCTYPE html><html><xmp>" > package/README.html |
| 242 |
cat ../README.md >> package/README.html |
| 243 |
echo "</xmp>" >> package/README.html |
| 244 |
echo "<script type=\"text/javascript\">" >> package/README.html |
| 245 |
cat package/strapdown.min.js >> package/README.html |
| 246 |
echo "</script>" >> package/README.html |
| 247 |
echo "</html>" >> package/README.html |
| 248 |
|
| 249 |
|
| 250 |
#=============================================================== |
| 251 |
# release |
| 252 |
#=============================================================== |
| 253 |
FAUSTLIVE ?=../../faustlive |
| 254 |
FAUSTGEN ?=../embedded/faustgen |
| 255 |
release: APATH=$(shell pwd) |
| 256 |
release: |
| 257 |
@echo "################## Building faust package ###################" |
| 258 |
$(MAKE) cmake BACKENDS=all.cmake TARGETS=all.cmake |
| 259 |
$(MAKE) all |
| 260 |
$(MAKE) package |
| 261 |
@[ -d Release-$(VERSION) ] || mkdir Release-$(VERSION) |
| 262 |
rm -rf Release-$(VERSION)/* |
| 263 |
cp Faust-$(VERSION).dmg Release-$(VERSION) |
| 264 |
$(MAKE) install PREFIX=$(HOME)/Faust-$(VERSION) |
| 265 |
@echo "################## Building faust src distribution ###################" |
| 266 |
$(MAKE) -C .. dist |
| 267 |
mv ../faust-$(VERSION).tar.gz Release-$(VERSION) |
| 268 |
$(MAKE) faustgen |
| 269 |
# $(MAKE) faustlive # todo: |
| 270 |
|
| 271 |
faustgen: |
| 272 |
@echo "################## Building faustgen package ###################" |
| 273 |
$(MAKE) -C $(FAUSTGEN) clean |
| 274 |
$(MAKE) -C $(FAUSTGEN) FAUST_PATH_IS_ABSOLUTE=1 FAUST=$(HOME)/Faust-$(VERSION)/bin/faust USE_STATIC_SNDFILE=$(USE_STATIC_SNDFILE) MAXSDK="$(MAXSDK)" |
| 275 |
$(MAKE) -C $(FAUSTGEN) package |
| 276 |
cp $(FAUSTGEN)/package/*.dmg Release-$(VERSION) |
| 277 |
|
| 278 |
faustlive: APATH=$(shell pwd) |
| 279 |
faustlive: |
| 280 |
@echo "################## Building faustlive package ###################" |
| 281 |
$(MAKE) -C $(FAUSTLIVE)/Build release FAUST=$(HOME)/Faust-$(VERSION)/bin/faust DEST=$(APATH)/Release-$(VERSION) |
| 282 |
|
| 283 |
|
| 284 |
#=============================================================== |
| 285 |
# building universal binaries on macos |
| 286 |
#=============================================================== |
| 287 |
universal: $(FAUSTDIR) |
| 288 |
cd $(FAUSTDIR) && $(CMAKE) -DUNIVERSAL=ON .. |
| 289 |
|
| 290 |
native: $(FAUSTDIR) |
| 291 |
cd $(FAUSTDIR) && $(CMAKE) -DUNIVERSAL=OFF .. |
| 292 |
|
| 293 |
|
| 294 |
#=============================================================== |
| 295 |
# building libraries |
| 296 |
#=============================================================== |
| 297 |
staticlib: $(PROJ) |
| 298 |
$(CMAKE) --build $(FAUSTDIR) --target staticlib $(BUILDOPT) |
| 299 |
|
| 300 |
dynamiclib: $(PROJ) |
| 301 |
$(CMAKE) --build $(FAUSTDIR) --target dynamiclib $(BUILDOPT) |
| 302 |
|
| 303 |
|
| 304 |
#=============================================================== |
| 305 |
# building libfaust.a for ios |
| 306 |
#=============================================================== |
| 307 |
ioslib: $(IOSDIR) $(IOSDIR)/faust.xcodeproj |
| 308 |
$(CMAKE) --build $(IOSDIR) --target staticlib $(BUILDOPT) |
| 309 |
$(CMAKE) --build $(IOSDIR) --target oscstatic $(BUILDOPT) |
| 310 |
|
| 311 |
$(IOSDIR)/faust.xcodeproj: CMakeLists.txt backends/ios.cmake |
| 312 |
cd $(IOSDIR) && $(CMAKE) -C ../backends/ios.cmake .. -DINCLUDE_STATIC=on -DINCLUDE_HTTP=off -G Xcode |
| 313 |
|
| 314 |
|
| 315 |
#=============================================================== |
| 316 |
# misc targets |
| 317 |
#=============================================================== |
| 318 |
$(FAUSTDIR): |
| 319 |
mkdir $(FAUSTDIR) |
| 320 |
|
| 321 |
$(IOSDIR): |
| 322 |
mkdir $(IOSDIR) |
| 323 |
|
| 324 |
$(PROJ): |
| 325 |
$(MAKE) cmake |
| 326 |
|
| 327 |
verbose: $(FAUSTDIR) |
| 328 |
cd $(FAUSTDIR) && $(CMAKE) -DCMAKE_VERBOSE_MAKEFILE=ON .. |
| 329 |
|
| 330 |
silent: $(FAUSTDIR) |
| 331 |
cd $(FAUSTDIR) && $(CMAKE) -DCMAKE_VERBOSE_MAKEFILE=OFF .. |
| 332 |
|
| 333 |
cmake: $(FAUSTDIR) |
| 334 |
cd $(FAUSTDIR) && $(CMAKE) -C ../backends/$(BACKENDS) -C ../targets/$(TARGETS) $(CMAKEOPTS) -DCMAKE_BUILD_TYPE=$(RELEASE_TYPE) $(WORKLETOPT) -DINCLUDE_LLVM=$(INCLUDE_LLVM) -DUSE_LLVM_CONFIG=$(USE_LLVM_CONFIG) -DLLVM_PACKAGE_VERSION=$(LLVM_PACKAGE_VERSION) -DLLVM_LIBS="$(LLVM_LIBS)" -DLLVM_LIB_DIR="$(LLVM_LIB_DIR)" -DLLVM_INCLUDE_DIRS="$(LLVM_INCLUDE_DIRS)" -DLLVM_DEFINITIONS="$(LLVM_DEFINITIONS)" -DLLVM_LD_FLAGS="$(LLVM_LD_FLAGS)" $(DEPLOYMENT) -DLIBSDIR=$(LIBSDIR) -DBUILD_HTTP_STATIC=$(BUILD_HTTP_STATIC) -G '$(GENERATOR)' .. |
| 335 |
@echo BACKENDS=$(BACKENDS) > $(BCACHE) |
| 336 |
@echo TARGETS=$(TARGETS) > $(TCACHE) |
| 337 |
@echo LIBSDIR=$(LIBSDIR) > $(LCACHE) |
| 338 |
|
| 339 |
|
| 340 |
#=============================================================== |
| 341 |
# building faust with emscripten |
| 342 |
#=============================================================== |
| 343 |
WASMFS := wasm-filesystem |
| 344 |
WASMLIBDIR := share/faust |
| 345 |
wasmlib: $(FAUSTDIR) $(FAUSTDIR)/Makefile |
| 346 |
@$(MAKE) checkemcc |
| 347 |
mkdir -p $(WASMFS)/$(WASMLIBDIR) && cp ../libraries/*.lib ../libraries/dx7/*.lib ../libraries/old/*.lib $(WASMFS)/$(WASMLIBDIR) |
| 348 |
mkdir -p $(WASMFS)/rsrc && cp ../architecture/webaudio/mixer32.wasm $(WASMFS)/rsrc && cp ../architecture/webaudio/mixer64.wasm $(WASMFS)/rsrc |
| 349 |
$(CMAKE) --build $(FAUSTDIR) --target wasmlib $(BUILDOPT) -- $(JOBS) |
| 350 |
cp $(FAUSTDIR)/emcc/libfaust-wasm.* lib |
| 351 |
rm -rf $(WASMFS) |
| 352 |
|
| 353 |
wasmglue: $(FAUSTDIR) $(FAUSTDIR)/Makefile |
| 354 |
@$(MAKE) checkemcc |
| 355 |
$(CMAKE) --build $(FAUSTDIR) --target wasmglue $(BUILDOPT) |
| 356 |
|
| 357 |
checkemcc: |
| 358 |
@which $(EMCC) > /dev/null || (echo "### emcc must be available from your PATH."; false;) |
| 359 |
|
| 360 |
|
| 361 |
#=============================================================== |
| 362 |
# faust install |
| 363 |
#=============================================================== |
| 364 |
installLog := $(FAUSTDIR)/install_manifest.txt |
| 365 |
install: |
| 366 |
if test -d ../.git; then git submodule update --init; fi |
| 367 |
cd $(FAUSTDIR) && $(CMAKE) .. -DCMAKE_INSTALL_PREFIX=$(PREFIX) $(CMAKEOPTS) |
| 368 |
$(CMAKE) --build $(FAUSTDIR) --target install |
| 369 |
|
| 370 |
uninstall: $(installLog) |
| 371 |
$(shell cat $(installLog) | xargs rm -f) |
| 372 |
rm -f $(installLog) |
| 373 |
|
| 374 |
#=============================================================== |
| 375 |
undefined: |
| 376 |
$(error System is undefined, not target available) |