Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +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 | |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 17 | SAMPLES = fibonacci hello prime |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 18 | |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 19 | all :: $(SAMPLES) |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 20 | |
| 21 | ifdef OPTIMIZE |
| 22 | %.bc : %.st |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 23 | @$(ECHO) "Compiling and Optimizing $< to $*.bc" |
| 24 | $(VERB)stkrc -e -o - $< | opt -stats -q -f -o $*.bc \ |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 25 | -aa-eval -adce -branch-combine -cee -constmerge -constprop -dce -die -ds-aa \ |
| 26 | -ds-opt -gcse -globaldce -indvars -inline -instcombine \ |
| 27 | -ipconstprop -licm -loopsimplify -mem2reg -pre -sccp -simplifycfg \ |
| 28 | -tailcallelim -verify |
| 29 | else |
| 30 | %.bc : %.st |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 31 | @$(ECHO) "Compiling $< to $*.bc" |
| 32 | $(VERB)stkrc -e -f -o $*.bc $< |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 33 | endif |
| 34 | |
| 35 | %.s : %.bc |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 36 | @$(ECHO) "Compiling $< to $*.s" |
| 37 | $(VERB)llc -f -o $*.s $< |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 38 | |
| 39 | % : %.s |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 40 | @$(ECHO) "Compiling and Linking $< to $*" |
| 41 | $(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/Debug -lstkr_runtime -o $* $*.s |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 42 | |
| 43 | %.ll : %.bc |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 44 | @$(ECHO) "Disassembling $< to $*.ll" |
| 45 | $(VERB)llvm-dis -f -o $*.ll $< |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 46 | |
| 47 | %.bc : $(BUILD_OBJ_ROOT)/tools/Debug/stkrc |
| 48 | |
| 49 | .PRECIOUS: %.bc %.s %.ll %.st |
Brian Gaeke | 3e4a271 | 2003-11-24 02:57:25 +0000 | [diff] [blame^] | 50 | |
| 51 | SAMPLES_LL = $(SAMPLES:%=%.ll) |
| 52 | SAMPLES_BC = $(SAMPLES:%=%.bc) |
| 53 | SAMPLES_S = $(SAMPLES:%=%.s) |
| 54 | |
| 55 | clean :: |
| 56 | $(VERB)rm -f gmon.out $(SAMPLES_LL) $(SAMPLES_BC) $(SAMPLES_S) $(SAMPLES) |
Chris Lattner | 9d014e7 | 2003-11-23 17:55:19 +0000 | [diff] [blame] | 57 | # |
| 58 | # Include the Master Makefile that knows how to build all. |
| 59 | # |
| 60 | include $(LEVEL)/Makefile.common |