1 ##===- projects/sample/Makefile ----------------------------*- Makefile -*-===##
3 # This is a sample Makefile for a project that uses LLVM.
5 ##===----------------------------------------------------------------------===##
8 # Indicates our relative path to the top of the project's root directory.
13 # Directories that needs to be built.
17 SAMPLES = fibonacci hello prime
19 LLC_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/llc
20 OPT_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/opt
21 STKRC_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/stkrc
22 LLVMDIS_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/llvm-dis
28 @$(ECHO) "Compiling and Optimizing $< to $*.bc"
29 $(VERB)$(STKRC_EXEC) -e -o - $< | opt -stats -q -f -o $*.bc \
30 -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 \
36 @$(ECHO) "Compiling $< to $*.bc"
37 $(VERB)$(STKRC_EXEC) -e -f -o $*.bc $<
41 @$(ECHO) "Compiling $< to $*.s"
42 $(VERB)$(LLC_EXEC) -f -o $*.s $<
45 @$(ECHO) "Compiling and Linking $< to $*"
46 $(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION) -lstkr_runtime -o $* $*.s
49 @$(ECHO) "Disassembling $< to $*.ll"
50 $(VERB)$(LLVMDIS_EXEC) -f -o $*.ll $<
54 .PRECIOUS: %.bc %.s %.ll %.st
56 SAMPLES_LL = $(SAMPLES:%=%.ll)
57 SAMPLES_BC = $(SAMPLES:%=%.bc)
58 SAMPLES_S = $(SAMPLES:%=%.s)
61 $(VERB)rm -f gmon.out $(SAMPLES_LL) $(SAMPLES_BC) $(SAMPLES_S) $(SAMPLES)
63 # Include the Master Makefile that knows how to build all.
65 include $(LEVEL)/Makefile.common