1 # test/Libraries/Makefile.libs
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.
6 # Variables to be defined before including this makefile:
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.
15 DESTLIBDIR := $(LEVEL)/test/Libraries/Output
16 DESTLIBNAME := $(LEVEL)/test/Libraries/Output/lib$(LIBNAME).bc
20 include $(LEVEL)/test/Makefile.tests
22 # Figure out what object files we want to build...
23 LObjs := $(sort $(addsuffix .bc, $(basename $(Source))))
24 LObjects := $(addprefix Output/,$(LObjs))
26 .PRECIOUS: $(LObjects)
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)
34 # Standard set of postlink optimizations...
35 LLINK_OPTS += -inline -globaldce -funcresolve -deadtypeelim -instcombine -simplifycfg
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 $@
42 # Install target for libraries: Copy into the gcc install directory.
44 INSTALL_DIR := $(LLVMGCCDIR)/bytecode-libs/
46 install:: $(DESTLIBNAME)
47 cp $(DESTLIBNAME) $(INSTALL_DIR)