summaryrefslogtreecommitdiff
path: root/projects/Stacker/samples/Makefile
blob: 22190a78dbb2ecef43f1da6bbdf18284c0ff5d97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
##===- 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 = 

SAMPLES = fibonacci hello prime

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

all :: $(SAMPLES)

ifdef OPTIMIZE
% : %.st 
	@$(ECHO) "Compiling and Optimizing $< to $*.bc"
	$(VERB)$(STKRC_EXEC) -e -o - $< | opt -stats -q -f -o $*.bc \
	    -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
	@$(ECHO) "Compiling $< to $*.bc"
	$(VERB)$(STKRC_EXEC) -e -f -o $*.bc $< 
endif

%.s : %.bc
	@$(ECHO) "Compiling $< to $*.s"
	$(VERB)$(LLC_EXEC) -f -o $*.s $<

% : %.s
	@$(ECHO) "Compiling and Linking $< to $*"
	$(VERB)gcc -g -L$(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION) -lstkr_runtime -o $* $*.s

%.ll : %.bc
	@$(ECHO) "Disassembling $< to $*.ll"
	$(VERB)$(LLVMDIS_EXEC) -f -o $*.ll $<

%.bc :  $(STKRC_EXEC)

.PRECIOUS: %.bc %.s %.ll %.st

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)
#
# Include the Master Makefile that knows how to build all.
#
include $(LEVEL)/Makefile.common