Chris Lattner | c1e20ac | 2002-03-08 23:20:52 +0000 | [diff] [blame] | 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 |
Chris Lattner | 20fa5da | 2003-05-22 20:27:30 +0000 | [diff] [blame] | 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. |
Chris Lattner | c1e20ac | 2002-03-08 23:20:52 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 20fa5da | 2003-05-22 20:27:30 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 881a2ba | 2003-05-29 15:16:45 +0000 | [diff] [blame] | 34 | # Standard set of postlink optimizations... |
| 35 | LLINK_OPTS += -inline -globaldce -funcresolve -deadtypeelim -instcombine -simplifycfg |
| 36 | |
Chris Lattner | c1e20ac | 2002-03-08 23:20:52 +0000 | [diff] [blame] | 37 | # Link the library, then perform postlink optimization... |
Chris Lattner | 20fa5da | 2003-05-22 20:27:30 +0000 | [diff] [blame] | 38 | $(DESTLIBNAME): $(DESTLIBDIR)/.dir $(LObjects) $(LLINK) $(LOPT) |
Chris Lattner | c5208d4 | 2002-05-20 21:45:44 +0000 | [diff] [blame] | 39 | $(LLINK) -f $(LObjects) $(LDFLAGS) | \ |
Chris Lattner | 881a2ba | 2003-05-29 15:16:45 +0000 | [diff] [blame] | 40 | $(LOPT) -f -q $(LLINK_OPTS) -o $@ |
Chris Lattner | c1e20ac | 2002-03-08 23:20:52 +0000 | [diff] [blame] | 41 | |
Chris Lattner | 74075dd | 2003-05-14 13:09:57 +0000 | [diff] [blame] | 42 | # Install target for libraries: Copy into the gcc install directory. |
Chris Lattner | c1e20ac | 2002-03-08 23:20:52 +0000 | [diff] [blame] | 43 | # |
Chris Lattner | 74075dd | 2003-05-14 13:09:57 +0000 | [diff] [blame] | 44 | INSTALL_DIR := $(LLVMGCCDIR)/bytecode-libs/ |
Chris Lattner | c1e20ac | 2002-03-08 23:20:52 +0000 | [diff] [blame] | 45 | |
| 46 | install:: $(DESTLIBNAME) |
Chris Lattner | 853f9be | 2002-07-30 00:53:26 +0000 | [diff] [blame] | 47 | cp $(DESTLIBNAME) $(INSTALL_DIR) |