Major addition to bugpoint: ability to debug code generators (LLC and LLI).
[oota-llvm.git] / runtime / Makefile.libs
1 #                          test/Libraries/Makefile.libs
2 #
3 # This makefile should be used by subdirectories, which are libraries that are
4 # to be compiled to llvm bytecode and linked together with a specified name.
5 #
6 # Variables to be defined before including this makefile:
7 #
8 # 1. LEVEL - Must be set as per normal semantics: The depth from the top of tree
9 # 2. LIBNAME - Name of library to link together.  Forms lib<LIBNAME>.bc
10 # 3. EXPORTED_SYMBOL_LIST - If this symbol is defined, it contains a comma
11 #    separated list of symbols that are exported by the library.  All other
12 #    symbols are marked internal, reducing namespace pollution.
13 #
14
15 DESTLIBDIR  := $(LEVEL)/test/Libraries/Output
16 DESTLIBNAME := $(LEVEL)/test/Libraries/Output/lib$(LIBNAME).bc
17
18 all:: $(DESTLIBNAME)
19
20 include $(LEVEL)/test/Makefile.tests
21
22 # Figure out what object files we want to build...
23 LObjs    := $(sort $(addsuffix .bc, $(basename $(Source))))
24 LObjects := $(addprefix Output/,$(LObjs))
25
26 .PRECIOUS: $(LObjects)
27
28 # If the library specified a list of symbols to export, add an internalize pass
29 # to the link options.
30 ifdef EXPORTED_SYMBOL_LIST
31 LLINK_OPTS += -internalize -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
32 endif
33
34 # Standard set of postlink optimizations...
35 LLINK_OPTS +=  -inline -globaldce -funcresolve -deadtypeelim -instcombine -simplifycfg
36
37 # Link the library, then perform postlink optimization...
38 $(DESTLIBNAME): $(DESTLIBDIR)/.dir $(LObjects) $(LLINK) $(LOPT)
39         $(LLINK) -f $(LObjects) $(LDFLAGS) | \
40          $(LOPT) -f -q $(LLINK_OPTS) -o $@
41
42 # Install target for libraries: Copy into the gcc install directory.
43 #
44 INSTALL_DIR := $(LLVMGCCDIR)/bytecode-libs/
45
46 install:: $(DESTLIBNAME)
47         cp $(DESTLIBNAME) $(INSTALL_DIR)