Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 1 | ##===- projects/sample/Makefile ----------------------------*- Makefile -*-===## |
| 2 | # |
| 3 | # This is a sample Makefile for a project that uses LLVM. |
| 4 | # |
| 5 | ##===----------------------------------------------------------------------===## |
| 6 | |
| 7 | # |
| 8 | # Indicates our relative path to the top of the project's root directory. |
| 9 | # |
| 10 | LEVEL = ../../.. |
| 11 | |
| 12 | # |
| 13 | # Directories that needs to be built. |
| 14 | # |
| 15 | DIRS = |
| 16 | |
| 17 | # |
| 18 | # Include the Master Makefile that knows how to build all. |
| 19 | # |
| 20 | include $(LEVEL)/Makefile.common |
| 21 | |
| 22 | LOGIC_TESTS = eq ne le ge gt lt false true |
| 23 | BITWISE_TESTS = shl shr xor or and |
| 24 | ARITHMETIC_TESTS = abs neg add sub mul div mod star_slash incr decr min max |
| 25 | STACK_TESTS = drop drop2 nip nip2 dup dup2 swap swap2 over over2 rot rot2 \ |
| 26 | rrot rrot2 tuck tuck2 roll pick select |
| 27 | MEMORY_TESTS = memory |
| 28 | CONTROL_TESTS = while return |
| 29 | IO_TESTS = space tab out_chr out_num out_str |
| 30 | |
| 31 | TESTS = $(LOGIC_TESTS) $(ARITHMETIC_TESTS) $(BITWISE_TESTS) $(STACK_TESTS) \ |
| 32 | $(MEMORY_TESTS) $(CONTROL_TESTS) $(IO_TESTS) |
| 33 | |
| 34 | all :: test_each |
| 35 | |
| 36 | test_each: $(TESTS) |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 37 | @$(ECHO) "Running Tests..." |
| 38 | $(VERB)$(BUILD_SRC_DIR)/runtests $(BUILD_OBJ_DIR) $(TESTS) |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 39 | |
| 40 | % : %.s testing.s |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 41 | @$(ECHO) "Compiling and Linking $< to $*" |
| 42 | $(VERB)gcc -ggdb -L$(BUILD_OBJ_ROOT)/lib/Debug testing.s -lstkr_runtime -o $* $*.s |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 43 | |
| 44 | %.s : %.bc |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 45 | @$(ECHO) "Compiling $< to $*.s" |
| 46 | $(VERB)llc -f -o $*.s $< |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 47 | |
| 48 | ifdef OPTIMIZE |
| 49 | %.bc : %.st $(BUILD_OBJ_ROOT)/tools/Debug/stkrc |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 50 | @$(ECHO) "Compiling and Optimizing $< to $*.bc" |
| 51 | $(VERB)stkrc -e -o - $< | opt -stats -q -f -o $*.bc -adce -branch-combine -cee -constmerge -constprop -dce -die -gcse -globaldce -instcombine -pre |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 52 | else |
| 53 | %.bc : %.st $(BUILD_OBJ_ROOT)/tools/Debug/stkrc |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 54 | @$(ECHO) "Compiling $< to $*.bc" |
| 55 | $(VERB)stkrc -e -f -o $*.bc $< |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 56 | endif |
| 57 | |
| 58 | %.ll : %.bc |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 59 | @$(ECHO) "Disassembling $< to $*.ll" |
| 60 | $(VERB)llvm-dis -o $*.ll $< |
| 61 | |
| 62 | TESTS_LL = $(TESTS:%=%.ll) |
| 63 | TESTS_BC = $(TESTS:%=%.bc) |
| 64 | TESTS_S = $(TESTS:%=%.s) |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 65 | |
| 66 | clean :: |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 67 | $(VERB)rm -f gmon.out $(TESTS_LL) $(TESTS_BC) $(TESTS_S) $(TESTS) testing.bc testing.s testing.ll |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 68 | |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 69 | .SUFFIXES: .st .s .ll .bc |
Chris Lattner | e44f1db | 2003-11-23 18:12:22 +0000 | [diff] [blame] | 70 | .PRECIOUS: %.s %.ll %.bc %.st |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 71 | .PHONY: test_each |