2003-11-23 17:55:19 +00:00
|
|
|
##===- projects/sample/Makefile ----------------------------*- Makefile -*-===##
|
|
|
|
#
|
|
|
|
# This is a sample Makefile for a project that uses LLVM.
|
|
|
|
#
|
|
|
|
##===----------------------------------------------------------------------===##
|
|
|
|
|
|
|
|
#
|
|
|
|
# Indicates our relative path to the top of the project's root directory.
|
|
|
|
#
|
|
|
|
LEVEL = ../../..
|
|
|
|
|
|
|
|
#
|
|
|
|
# Directories that needs to be built.
|
|
|
|
#
|
|
|
|
DIRS =
|
|
|
|
|
2003-11-24 02:57:25 +00:00
|
|
|
SAMPLES = fibonacci hello prime
|
2003-11-23 17:55:19 +00:00
|
|
|
|
2003-12-08 07:08:00 +00:00
|
|
|
LLC_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/llc
|
|
|
|
OPT_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/opt
|
|
|
|
STKRC_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/stkrc
|
|
|
|
LLVMDIS_EXEC = $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)/llvm-dis
|
|
|
|
|
2003-11-24 02:57:25 +00:00
|
|
|
all :: $(SAMPLES)
|
2003-11-23 17:55:19 +00:00
|
|
|
|
|
|
|
ifdef OPTIMIZE
|
2004-10-27 23:18:45 +00:00
|
|
|
% : %.st
|
2003-11-24 02:57:25 +00:00
|
|
|
@$(ECHO) "Compiling and Optimizing $< to $*.bc"
|
2003-12-08 07:08:00 +00:00
|
|
|
$(VERB)$(STKRC_EXEC) -e -o - $< | opt -stats -q -f -o $*.bc \
|
2003-11-23 17:55:19 +00:00
|
|
|
-aa-eval -adce -branch-combine -cee -constmerge -constprop -dce -die -ds-aa \
|
|
|
|
-ds-opt -gcse -globaldce -indvars -inline -instcombine \
|
|
|
|
-ipconstprop -licm -loopsimplify -mem2reg -pre -sccp -simplifycfg \
|
|
|
|
-tailcallelim -verify
|
|
|
|
else
|
|
|
|
%.bc : %.st
|
2003-11-24 02:57:25 +00:00
|
|
|
@$(ECHO) "Compiling $< to $*.bc"
|
2003-12-08 07:08:00 +00:00
|
|
|
$(VERB)$(STKRC_EXEC) -e -f -o $*.bc $<
|
2003-11-23 17:55:19 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
%.s : %.bc
|
2003-11-24 02:57:25 +00:00
|
|
|
@$(ECHO) "Compiling $< to $*.s"
|
2003-12-08 07:08:00 +00:00
|
|
|
$(VERB)$(LLC_EXEC) -f -o $*.s $<
|
2003-11-23 17:55:19 +00:00
|
|
|
|
|
|
|
% : %.s
|
2003-11-24 02:57:25 +00:00
|
|
|
@$(ECHO) "Compiling and Linking $< to $*"
|
2003-12-08 07:08:00 +00:00
|
|
|
$(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION) -lstkr_runtime -o $* $*.s
|
2003-11-23 17:55:19 +00:00
|
|
|
|
|
|
|
%.ll : %.bc
|
2003-11-24 02:57:25 +00:00
|
|
|
@$(ECHO) "Disassembling $< to $*.ll"
|
2003-12-08 07:08:00 +00:00
|
|
|
$(VERB)$(LLVMDIS_EXEC) -f -o $*.ll $<
|
2003-11-23 17:55:19 +00:00
|
|
|
|
2003-12-08 07:08:00 +00:00
|
|
|
%.bc : $(STKRC_EXEC)
|
2003-11-23 17:55:19 +00:00
|
|
|
|
|
|
|
.PRECIOUS: %.bc %.s %.ll %.st
|
2003-11-24 02:57:25 +00:00
|
|
|
|
|
|
|
SAMPLES_LL = $(SAMPLES:%=%.ll)
|
|
|
|
SAMPLES_BC = $(SAMPLES:%=%.bc)
|
|
|
|
SAMPLES_S = $(SAMPLES:%=%.s)
|
|
|
|
|
|
|
|
clean ::
|
|
|
|
$(VERB)rm -f gmon.out $(SAMPLES_LL) $(SAMPLES_BC) $(SAMPLES_S) $(SAMPLES)
|
2003-11-23 17:55:19 +00:00
|
|
|
#
|
|
|
|
# Include the Master Makefile that knows how to build all.
|
|
|
|
#
|
|
|
|
include $(LEVEL)/Makefile.common
|