1#
2# Makefile for generating ir using llvm
3#
4
5system := $(shell uname -s)
6system := $(shell echo $(system) | grep MINGW > /dev/null && echo MINGW || echo $(system))
7ifeq ($(system), MINGW)
8 FAUST ?= ../../build/bin/faust.exe
9 COMPARE := ./filesCompare.exe
10else
11 FAUST ?= ../../build/bin/faust
12 COMPARE := ./filesCompare
13endif
14MAKE ?= make
15
16outdir ?= llvm
17lang ?= llvm
18precision ?=		# filesCompare precision (empty by default)
19FAUSTOPTIONS ?=
20
21.PHONY: test
22
23dspfiles := $(wildcard dsp/*.dsp)
24listfiles = $(dspfiles:dsp/%.dsp=ir/$1/%.ir)
25
26SRCDIR := tools
27
28#########################################################################
29llvm:  impulsellvm ir/$(outdir) $(call listfiles,$(outdir))
30
31test:
32	@echo $(call listfiles,$(outdir))
33
34help:
35	@echo "-------- FAUST impulse response tests --------"
36	@echo "Available targets are:"
37	@echo " 'llvm' (default): check the double output using the llvm backend"
38	@echo
39	@echo "Options:"
40	@echo " 'outdir' 	   : define the output directory (default to 'llvm')"
41	@echo " 'FAUSTOPTIONS' : define additional faust options (empty by default)"
42    @echo " 'precision'    : define filesCompare expected precision (empty by default)"
43
44#########################################################################
45# output directories
46ir/$(outdir):
47	mkdir -p ir/$(outdir)
48
49#########################################################################
50# tools
51filesCompare: $(SRCDIR)/filesCompare.cpp
52	$(MAKE) filesCompare
53
54impulsellvm: $(SRCDIR)/impulsellvm.cpp $(LIB)
55	$(MAKE) impulsellvm
56
57#########################################################################
58# precision issues
59
60#########################################################################
61# rules for llvm
62
63# Specific rule to test 'control' primitive that currently uses the -lang ocpp backend (still compiling in scalar mode...)
64ir/$(outdir)/control.ir: dsp/control.dsp reference/control.ir
65	@echo "Cannot be tested with the LLVM backend"
66
67# Specific rule to test 'enable/control' primitives that currently only work in scalar mode
68ir/$(outdir)/osc_enable.ir: dsp/osc_enable.dsp reference/osc_enable.ir
69	@echo "Can only be tested in scalar mode"
70	cd $(dir $<); ../impulsellvm $(notdir $<) -I dsp -double > ../$@ || (rm -f ../$@; false)
71	$(COMPARE) $@ reference/$(notdir $@) $(precision) || (rm -f $@; false)
72
73ir/llvm/inpl/reverb_tester.ir:
74	@echo ">>> skip reverb_tester in inpl mode (crash)"
75
76ir/llvm/inpl/midi_tester.ir:
77	@echo ">>> skip midi_tester in inpl mode (crash)"
78
79ir/$(outdir)/%.ir: dsp/%.dsp reference/%.ir
80	cd $(dir $<); ../impulsellvm $(notdir $<) -I dsp -double $(FAUSTOPTIONS) > ../$@ || (rm -f ../$@; false)
81	$(COMPARE) $@ reference/$(notdir $@) $(precision) || (rm -f $@; false)
82
83
84
85