Apply patches from PR136
[oota-llvm.git] / projects / Stacker / samples / Makefile
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 SAMPLES = fibonacci hello prime
18
19 all :: $(SAMPLES)
20
21 ifdef OPTIMIZE
22 %.bc : %.st 
23         @$(ECHO) "Compiling and Optimizing $< to $*.bc"
24         $(VERB)stkrc -e -o - $< | opt -stats -q -f -o $*.bc \
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
31         @$(ECHO) "Compiling $< to $*.bc"
32         $(VERB)stkrc -e -f -o $*.bc $< 
33 endif
34
35 %.s : %.bc
36         @$(ECHO) "Compiling $< to $*.s"
37         $(VERB)llc -f -o $*.s $<
38
39 % : %.s
40         @$(ECHO) "Compiling and Linking $< to $*"
41         $(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/Debug -lstkr_runtime -o $* $*.s
42
43 %.ll : %.bc
44         @$(ECHO) "Disassembling $< to $*.ll"
45         $(VERB)llvm-dis -f -o $*.ll $<
46
47 %.bc :  $(BUILD_OBJ_ROOT)/tools/Debug/stkrc
48
49 .PRECIOUS: %.bc %.s %.ll %.st
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)
57 #
58 # Include the Master Makefile that knows how to build all.
59 #
60 include $(LEVEL)/Makefile.common