blob: 52766e16bfcec25758329df5e553d78c76baf07d [file] [log] [blame]
Chris Lattnerc1e20ac2002-03-08 23:20:52 +00001# 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
Chris Lattner20fa5da2003-05-22 20:27:30 +000010# 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.
Chris Lattnerc1e20ac2002-03-08 23:20:52 +000013#
14
15DESTLIBDIR := $(LEVEL)/test/Libraries/Output
16DESTLIBNAME := $(LEVEL)/test/Libraries/Output/lib$(LIBNAME).bc
17
18all:: $(DESTLIBNAME)
19
20include $(LEVEL)/test/Makefile.tests
21
22# Figure out what object files we want to build...
23LObjs := $(sort $(addsuffix .bc, $(basename $(Source))))
24LObjects := $(addprefix Output/,$(LObjs))
25
26.PRECIOUS: $(LObjects)
27
Chris Lattner20fa5da2003-05-22 20:27:30 +000028# If the library specified a list of symbols to export, add an internalize pass
29# to the link options.
30ifdef EXPORTED_SYMBOL_LIST
31LLINK_OPTS += -internalize -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
32endif
33
Chris Lattner881a2ba2003-05-29 15:16:45 +000034# Standard set of postlink optimizations...
35LLINK_OPTS += -inline -globaldce -funcresolve -deadtypeelim -instcombine -simplifycfg
36
Chris Lattnerc1e20ac2002-03-08 23:20:52 +000037# Link the library, then perform postlink optimization...
Chris Lattner20fa5da2003-05-22 20:27:30 +000038$(DESTLIBNAME): $(DESTLIBDIR)/.dir $(LObjects) $(LLINK) $(LOPT)
Chris Lattnerc5208d42002-05-20 21:45:44 +000039 $(LLINK) -f $(LObjects) $(LDFLAGS) | \
Chris Lattner881a2ba2003-05-29 15:16:45 +000040 $(LOPT) -f -q $(LLINK_OPTS) -o $@
Chris Lattnerc1e20ac2002-03-08 23:20:52 +000041
Chris Lattner74075dd2003-05-14 13:09:57 +000042# Install target for libraries: Copy into the gcc install directory.
Chris Lattnerc1e20ac2002-03-08 23:20:52 +000043#
Chris Lattner74075dd2003-05-14 13:09:57 +000044INSTALL_DIR := $(LLVMGCCDIR)/bytecode-libs/
Chris Lattnerc1e20ac2002-03-08 23:20:52 +000045
46install:: $(DESTLIBNAME)
Chris Lattner853f9be2002-07-30 00:53:26 +000047 cp $(DESTLIBNAME) $(INSTALL_DIR)