Michael Ellerman | 84f887b | 2015-03-04 21:41:31 +1100 | [diff] [blame] | 1 | # This mimics the top-level Makefile. We do it explicitly here so that this |
| 2 | # Makefile can operate with or without the kbuild infrastructure. |
| 3 | CC := $(CROSS_COMPILE)gcc |
| 4 | |
Michael Ellerman | 5e29a91 | 2015-03-11 15:05:59 +1100 | [diff] [blame] | 5 | define RUN_TESTS |
| 6 | @for TEST in $(TEST_PROGS); do \ |
| 7 | (./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \ |
| 8 | done; |
| 9 | endef |
| 10 | |
| 11 | run_tests: all |
| 12 | $(RUN_TESTS) |
| 13 | |
Michael Ellerman | 32dcfba | 2015-03-11 15:06:00 +1100 | [diff] [blame] | 14 | define INSTALL_RULE |
Bamvor Jian Zhang | 900d65e | 2015-09-09 21:06:28 +0800 | [diff] [blame] | 15 | @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ |
| 16 | mkdir -p ${INSTALL_PATH}; \ |
| 17 | echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \ |
| 18 | rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \ |
Bamvor Jian Zhang | a7d0f07 | 2015-08-14 21:43:35 +0800 | [diff] [blame] | 19 | fi |
Michael Ellerman | 32dcfba | 2015-03-11 15:06:00 +1100 | [diff] [blame] | 20 | endef |
| 21 | |
| 22 | install: all |
| 23 | ifdef INSTALL_PATH |
| 24 | $(INSTALL_RULE) |
| 25 | else |
| 26 | $(error Error: set INSTALL_PATH to use install) |
| 27 | endif |
| 28 | |
| 29 | define EMIT_TESTS |
| 30 | @for TEST in $(TEST_PROGS); do \ |
| 31 | echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \ |
| 32 | done; |
| 33 | endef |
| 34 | |
| 35 | emit_tests: |
| 36 | $(EMIT_TESTS) |
| 37 | |
| 38 | .PHONY: run_tests all clean install emit_tests |