Makefile (1891B)
1 ## Copyright 2018 Brian Swetland <swetland@frotz.net> 2 ## 3 ## Licensed under the Apache License, Version 2.0 4 ## http://www.apache.org/licenses/LICENSE-2.0 5 6 7 #### Projects #### 8 9 include build/init.mk 10 11 help: list-all-targets 12 13 all: build-all-buildable 14 15 test: run-all-tests 16 17 $(foreach p,$(wildcard project/*.def),$(call project,$p)) 18 19 clean:: 20 rm -rf out 21 22 ALL_TARGETS := $(sort $(ALL_TARGETS)) tools cpu16-tests all 23 TARGET_all_DESC := build all 'build' targets 24 TARGET_tools_DESC := build tools: out/{a16,d16,icetool} 25 TARGET_cpu16-tests_DESC := run cpu16 test suite 26 27 list-all-targets:: 28 @true 29 $(info All Possible Targets) 30 $(info --------------------) 31 $(foreach x,$(ALL_TARGETS),$(info $(shell printf "%-25s %s\n" "$(x)" "$(TARGET_$(x)_DESC)"))) 32 33 #### Tools #### 34 35 out/a16: src/a16v5.c src/d16v5.c 36 @mkdir -p out 37 gcc -g -Wall -O1 -o out/a16 src/a16v5.c src/d16v5.c 38 39 out/d16: src/d16v5.c 40 @mkdir -p out 41 gcc -g -Wall -O1 -o out/d16 -DSTANDALONE=1 src/d16v5.c 42 43 out/udebug: src/udebug.c 44 @mkdir -p out 45 gcc -g -Wall -Wno-unused-result -O1 -o out/udebug src/udebug.c 46 47 out/icetool: src/icetool.c src/ftdi.c src/ftdi.h 48 @mkdir -p out 49 gcc -g -Wall -O1 -o out/icetool src/icetool.c src/ftdi.c -lusb-1.0 -lrt 50 51 out/crctool: src/crctool.c 52 @mkdir -p out 53 gcc -g -Wall -O1 -o out/crctool src/crctool.c 54 55 tools:: out/a16 out/d16 out/icetool out/udebug out/crctool 56 57 build-all-buildable:: $(ALL_BUILDS) tools 58 59 run-all-tests:: $(patsubst %,%-vsim,$(filter test-%,$(ALL_BUILDS))) 60 61 #### CPU16 TESTS #### 62 63 CPU16_TEST_DEPS := out/cpu16-vsim out/a16 out/d16 tests/runtest 64 65 CPU16_TESTS := $(sort $(wildcard tests/*.s)) 66 67 CPU16_RESULTS := $(patsubst %.s,out/%.s.status,$(CPU16_TESTS)) 68 69 out/tests/%.s.status: tests/%.s $(CPU16_TEST_DEPS) 70 @./tests/runtest $< 71 72 cpu16-tests: $(CPU16_RESULTS) 73 @echo "" 74 @echo TESTS FAILED: `grep FAIL out/tests/*.status | wc -l` 75 @echo TESTS PASSED: `grep PASS out/tests/*.status | wc -l` 76