blob: b6b03c42bf231be4ca5fc973735238a8ad120d89 [file] [log] [blame]
Chris Lattner9d014e72003-11-23 17:55:19 +00001##===- 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#
10LEVEL = ../../..
11
12#
13# Directories that needs to be built.
14#
15DIRS =
16
Brian Gaeke3e4a2712003-11-24 02:57:25 +000017SAMPLES = fibonacci hello prime
Chris Lattner9d014e72003-11-23 17:55:19 +000018
Brian Gaeke3e4a2712003-11-24 02:57:25 +000019all :: $(SAMPLES)
Chris Lattner9d014e72003-11-23 17:55:19 +000020
21ifdef OPTIMIZE
22%.bc : %.st
Brian Gaeke3e4a2712003-11-24 02:57:25 +000023 @$(ECHO) "Compiling and Optimizing $< to $*.bc"
24 $(VERB)stkrc -e -o - $< | opt -stats -q -f -o $*.bc \
Chris Lattner9d014e72003-11-23 17:55:19 +000025 -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
29else
30%.bc : %.st
Brian Gaeke3e4a2712003-11-24 02:57:25 +000031 @$(ECHO) "Compiling $< to $*.bc"
32 $(VERB)stkrc -e -f -o $*.bc $<
Chris Lattner9d014e72003-11-23 17:55:19 +000033endif
34
35%.s : %.bc
Brian Gaeke3e4a2712003-11-24 02:57:25 +000036 @$(ECHO) "Compiling $< to $*.s"
37 $(VERB)llc -f -o $*.s $<
Chris Lattner9d014e72003-11-23 17:55:19 +000038
39% : %.s
Brian Gaeke3e4a2712003-11-24 02:57:25 +000040 @$(ECHO) "Compiling and Linking $< to $*"
41 $(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/Debug -lstkr_runtime -o $* $*.s
Chris Lattner9d014e72003-11-23 17:55:19 +000042
43%.ll : %.bc
Brian Gaeke3e4a2712003-11-24 02:57:25 +000044 @$(ECHO) "Disassembling $< to $*.ll"
45 $(VERB)llvm-dis -f -o $*.ll $<
Chris Lattner9d014e72003-11-23 17:55:19 +000046
47%.bc : $(BUILD_OBJ_ROOT)/tools/Debug/stkrc
48
49.PRECIOUS: %.bc %.s %.ll %.st
Brian Gaeke3e4a2712003-11-24 02:57:25 +000050
51SAMPLES_LL = $(SAMPLES:%=%.ll)
52SAMPLES_BC = $(SAMPLES:%=%.bc)
53SAMPLES_S = $(SAMPLES:%=%.s)
54
55clean ::
56 $(VERB)rm -f gmon.out $(SAMPLES_LL) $(SAMPLES_BC) $(SAMPLES_S) $(SAMPLES)
Chris Lattner9d014e72003-11-23 17:55:19 +000057#
58# Include the Master Makefile that knows how to build all.
59#
60include $(LEVEL)/Makefile.common