blob: d5b9b6ed0a126c91392b5b0d70fd41540de0bc5e [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
Chris Lattner0c82ee72003-12-08 07:08:00 +000019LLC_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/llc
20OPT_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/opt
21STKRC_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/stkrc
22LLVMDIS_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/llvm-dis
23
Brian Gaeke3e4a2712003-11-24 02:57:25 +000024all :: $(SAMPLES)
Chris Lattner9d014e72003-11-23 17:55:19 +000025
26ifdef OPTIMIZE
27%.bc : %.st
Brian Gaeke3e4a2712003-11-24 02:57:25 +000028 @$(ECHO) "Compiling and Optimizing $< to $*.bc"
Chris Lattner0c82ee72003-12-08 07:08:00 +000029 $(VERB)$(STKRC_EXEC) -e -o - $< | opt -stats -q -f -o $*.bc \
Chris Lattner9d014e72003-11-23 17:55:19 +000030 -aa-eval -adce -branch-combine -cee -constmerge -constprop -dce -die -ds-aa \
31 -ds-opt -gcse -globaldce -indvars -inline -instcombine \
32 -ipconstprop -licm -loopsimplify -mem2reg -pre -sccp -simplifycfg \
33 -tailcallelim -verify
34else
35%.bc : %.st
Brian Gaeke3e4a2712003-11-24 02:57:25 +000036 @$(ECHO) "Compiling $< to $*.bc"
Chris Lattner0c82ee72003-12-08 07:08:00 +000037 $(VERB)$(STKRC_EXEC) -e -f -o $*.bc $<
Chris Lattner9d014e72003-11-23 17:55:19 +000038endif
39
40%.s : %.bc
Brian Gaeke3e4a2712003-11-24 02:57:25 +000041 @$(ECHO) "Compiling $< to $*.s"
Chris Lattner0c82ee72003-12-08 07:08:00 +000042 $(VERB)$(LLC_EXEC) -f -o $*.s $<
Chris Lattner9d014e72003-11-23 17:55:19 +000043
44% : %.s
Brian Gaeke3e4a2712003-11-24 02:57:25 +000045 @$(ECHO) "Compiling and Linking $< to $*"
Chris Lattner0c82ee72003-12-08 07:08:00 +000046 $(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION) -lstkr_runtime -o $* $*.s
Chris Lattner9d014e72003-11-23 17:55:19 +000047
48%.ll : %.bc
Brian Gaeke3e4a2712003-11-24 02:57:25 +000049 @$(ECHO) "Disassembling $< to $*.ll"
Chris Lattner0c82ee72003-12-08 07:08:00 +000050 $(VERB)$(LLVMDIS_EXEC) -f -o $*.ll $<
Chris Lattner9d014e72003-11-23 17:55:19 +000051
Chris Lattner0c82ee72003-12-08 07:08:00 +000052%.bc : $(STKRC_EXEC)
Chris Lattner9d014e72003-11-23 17:55:19 +000053
54.PRECIOUS: %.bc %.s %.ll %.st
Brian Gaeke3e4a2712003-11-24 02:57:25 +000055
56SAMPLES_LL = $(SAMPLES:%=%.ll)
57SAMPLES_BC = $(SAMPLES:%=%.bc)
58SAMPLES_S = $(SAMPLES:%=%.s)
59
60clean ::
61 $(VERB)rm -f gmon.out $(SAMPLES_LL) $(SAMPLES_BC) $(SAMPLES_S) $(SAMPLES)
Chris Lattner9d014e72003-11-23 17:55:19 +000062#
63# Include the Master Makefile that knows how to build all.
64#
65include $(LEVEL)/Makefile.common