2001-11-05 08:35:56 +08:00
|
|
|
## -*-Makefile-*-
|
|
|
|
##------------------------------------------------------------------------
|
|
|
|
## Common rules for generating, linking, and compiling via LLVM.
|
|
|
|
##------------------------------------------------------------------------
|
|
|
|
|
2001-11-05 08:18:30 +08:00
|
|
|
.PHONY: clean default
|
|
|
|
|
|
|
|
|
|
|
|
TOOLS = $(LEVEL)/tools/Debug
|
|
|
|
|
|
|
|
LLC = $(TOOLS)/llc
|
|
|
|
LAS = $(TOOLS)/as
|
|
|
|
LDIS = $(TOOLS)/dis
|
|
|
|
LOPT = $(TOOLS)/opt
|
|
|
|
LLINK = $(TOOLS)/link
|
|
|
|
LLCFLAGS =
|
|
|
|
|
|
|
|
LCC = /home/vadve/lattner/cvs/gcc_install/bin/gcc
|
2001-11-05 08:35:56 +08:00
|
|
|
LCFLAGS = -O2 $(LOCAL_CFLAGS) -Wall
|
2001-11-05 08:18:30 +08:00
|
|
|
|
|
|
|
LLCLIB = $(LEVEL)/test/runtime.o
|
|
|
|
LIBS = $(LLCLIB) $(LOCAL_LIBS)
|
|
|
|
|
|
|
|
ifeq ($(TRACE), yes)
|
|
|
|
LLCFLAGS := $(LLCFLAGS) -trace
|
|
|
|
endif
|
|
|
|
|
|
|
|
CC = /opt/SUNWspro/bin/cc
|
|
|
|
AS = /opt/SUNWspro/bin/cc
|
|
|
|
DIS = /usr/ccs/bin/dis
|
|
|
|
CFLAGS = -g -xarch=v9
|
|
|
|
CCFLAGS = $(CFLAGS)
|
|
|
|
LDFLAGS = $(CFLAGS)
|
|
|
|
ASFLAGS = -c $(CFLAGS)
|
|
|
|
|
2001-11-06 03:43:24 +08:00
|
|
|
## Special targets to build a program from multiple source files
|
|
|
|
##
|
|
|
|
ifdef PROG
|
|
|
|
|
|
|
|
default: $(PROG).clean.bc $(PROG).native
|
|
|
|
#.SECONDARY: $(PROG).clean.bc ## keep %.clean.bc from being deleted
|
|
|
|
|
|
|
|
$(PROG).bc: $(OBJS)
|
|
|
|
$(LLINK) -f $(OBJS) -o $@
|
|
|
|
|
|
|
|
$(PROG).native: $(OBJS:.o=.c)
|
|
|
|
gcc -o $@ $(OBJS:.o=.c) -O2 $(LOCAL_CFLAGS) -Wall
|
|
|
|
endif
|
2001-11-05 08:18:30 +08:00
|
|
|
|
|
|
|
## Special target to force target-dependent library to be compiled
|
|
|
|
## directly to native code.
|
|
|
|
##
|
|
|
|
$(LLCLIB):
|
|
|
|
cd $(LEVEL)/test; $(MAKE) $(@F)
|
|
|
|
|
|
|
|
runtime.o: runtime.c
|
|
|
|
$(CC) -c $(CCFLAGS) $<
|
|
|
|
|
|
|
|
clean :
|
|
|
|
rm -f *.[123] *.bc *.mc *.s *.o a.out core $(PROG)
|
|
|
|
|
|
|
|
%.mc: %.bc $(LLC) $(AS)
|
|
|
|
@echo "Generating machine instructions for $<"
|
|
|
|
$(LLC) -f -dsched y $(LLCFLAGS) $< > $@
|
|
|
|
|
|
|
|
%.trace.bc: %.bc $(LLC)
|
|
|
|
$(LLC) -f -trace $(LLCFLAGS) $<
|
|
|
|
|
|
|
|
%.o: %.c
|
2001-11-06 16:34:56 +08:00
|
|
|
$(LCC) $(LCFLAGS) $< -c -o $@
|
2001-11-05 08:18:30 +08:00
|
|
|
|
|
|
|
%.bc: %.ll
|
|
|
|
$(LAS) -f $<
|
|
|
|
|
|
|
|
%.clean.bc: %.bc
|
|
|
|
$(LOPT) -cleangcc -raise -constprop -dce < $< > $@
|
|
|
|
|
|
|
|
%.s: %.bc
|
|
|
|
$(LLC) -f $(LLCOPTS) $<
|
|
|
|
|
|
|
|
%: %.o $(LIBS)
|
|
|
|
$(CC) -o $@ $(LDFLAGS) $< $(LIBS)
|
|
|
|
|
|
|
|
##
|
|
|
|
## Use a single rule to go from %.bc to % to avoid ambiguity in
|
|
|
|
## llvm bytecode files and native object code files, both named %.o
|
|
|
|
##
|
|
|
|
%: %.clean.bc $(LIBS)
|
|
|
|
$(LLC) -f $(LLCFLAGS) -o $*.s $<
|
|
|
|
$(AS) $(ASFLAGS) $*.s
|
|
|
|
$(CC) -o $@ $(LDFLAGS) $*.o $(LIBS)
|
|
|
|
|
|
|
|
## Cancel built-in implicit rule that overrides the above rule
|
|
|
|
%: %.s
|
|
|
|
|
|
|
|
## The next two rules are for disassembling an executable or an object file
|
|
|
|
%.dis: %
|
|
|
|
$(DIS) $< > $@
|
|
|
|
|
|
|
|
%.dis: %.o
|
|
|
|
$(DIS) $< > $@
|
|
|
|
|
|
|
|
|