increase dvbapp PR.
[vuplus_openembedded] / recipes / llvm / llvm.inc
1 # LLVM does not provide ABI stability between different versions. For this
2 # reason OE makes it possible to build and install different llvm versions
3 # at the same time.
4 #
5 # This is true for the normal recipes as well as the native ones.
6 #
7 # All regular installation directories are prefixed with 'llvm${LLVM_RELEASE}'
8 # e.g. "${STAGING_BINDIR}/llvm2.5" or "${STAGING_INCDIR}/llvm2.5"
9 #
10 # For your program or library that makes use of llvm you do should not need to
11 # modify anything as long as it uses the results of various llvm-config
12 # invocations. If you need customizations something is wrong and it needs to be
13 # fixed (report bug).
14 #
15 # However the *recipe* for your program/library *must* declare
16 # export WANT_LLVM_RELEASE = "<valid version number>
17 # The version number is picked up by a generic wrapper script which just calls
18 # the variant of the specified version.
19
20 DESCRIPTION = "The Low Level Virtual Machine"
21 HOMEPAGE = "http://llvm.org"
22
23 DEPENDS = "llvm-common llvm${LLVM_RELEASE}-native"
24
25 # 3-clause BSD-like
26 LICENSE = "University of Illinois/NCSA Open Source License"
27
28 SRC_URI = "http://llvm.org/releases/${PV}/llvm-${PV}.tar.gz"
29
30 S = "${WORKDIR}/llvm-${PV}"
31
32 inherit cmake
33
34 # Defines the LLVM supported arches. By now we always build either for ${BUILD}
35 # (native) or ${TARGET}. In the future it may make sense to enable all backends
36 # for the non-native build. The decision which backends are used is made by
37 # the 3rd party program or library that uses llvm anyway.
38 LLVM_ARCH = "${@get_llvm_arch(d)}"
39
40 # This is used for generating the install directory for the llvm libraries,
41 # binaries and headers. It makes side by side installation of those possible.
42 LLVM_RELEASE = "${PV}"
43
44 # llvm *must* be built out of tree
45 OECMAKE_SOURCEPATH = ".."
46 OECMAKE_BUILDPATH = "build"
47 EXTRA_OEMAKE = "-C build"
48 EXTRA_OECMAKE = "\
49   -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm${LLVM_RELEASE}/tblgen \
50   -DLLVM_TARGETS_TO_BUILD=${LLVM_ARCH} \
51   -DCMAKE_LINKER:FILEPATH=${LD} \
52   -DCMAKE_AR:FILEPATH=${AR} \
53   -DCMAKE_OBJCOPY:FILEPATH=${OBJCOPY} \
54   -DCMAKE_OBJDUMP:FILEPATH=${OBJDUMP} \
55   -DCMAKE_RANLIB:FILEPATH=${RANLIB} \
56   -DCMAKE_STRIP:FILEPATH=${STRIP} \
57   -DLLVM_ENABLE_PIC:BOOL=ON \
58 "
59
60 llvm_stage() {
61         # Install into a private directory to be able to reorganize the files.
62   oe_runmake DESTDIR=${WORKDIR}/llvm-install install
63
64         # Create our custom target directories
65         install -d ${STAGING_BINDIR}/llvm${LLVM_RELEASE}
66   install -d ${STAGING_INCDIR}/llvm${LLVM_RELEASE}
67         install -d ${STAGING_LIBDIR}/llvm${LLVM_RELEASE}
68
69         #       Move headers into their own directory
70         cp -r ${WORKDIR}/llvm-install/${prefix}/include/llvm \
71     ${STAGING_INCDIR}/llvm${LLVM_RELEASE}/
72         cp -r ${WORKDIR}/llvm-install/${prefix}/include/llvm-c \
73     ${STAGING_INCDIR}/llvm${LLVM_RELEASE}/
74
75         # llvm somehow forgets these
76 #       find include/llvm -name "*.h" -maxdepth 1 -exec \
77 #    install {} ${STAGING_INCDIR}/llvm${LLVM_RELEASE}/llvm \;
78
79         find ${WORKDIR}/llvm-install/${prefix}/lib -name "*" -maxdepth 1 -exec \
80     install {} ${STAGING_LIBDIR}/llvm${LLVM_RELEASE} \;
81
82         #       I dont know another way out. Binaries are installed into a special subdir
83         find ${WORKDIR}/llvm-install/${prefix}/bin -name "*" -maxdepth 1 -exec \
84     install {} ${STAGING_BINDIR}/llvm${LLVM_RELEASE} \;
85
86         # LLVM does not install this by default.
87   install build/bin/tblgen ${STAGING_BINDIR}/llvm${LLVM_RELEASE}
88
89   # Fix the paths in the config script to make it find the binaries and
90   # library files. Doing so allows 3rd party configure scripts working
91   # unmodified.
92   sed -e's!my.*ABS_RUN_DIR =.*!my $ABS_RUN_DIR = "${STAGING_DIR_TARGET}";!' \
93       -e's!my.*INCLUDEDIR =.*!my $INCLUDEDIR = "${STAGING_INCDIR}/llvm${LLVM_RELEASE}";!' \
94       -e's!my.*LIBDIR.*!my $LIBDIR = "${STAGING_LIBDIR}/llvm${LLVM_RELEASE}";!' \
95       -e's!my.*BINDIR.*!my $BINDIR = "${STAGING_BINDIR}/llvm${LLVM_RELEASE}";!' \
96       build/bin/llvm-config > build/bin/llvm-config${LLVM_RELEASE}
97 }
98
99 do_stage() {
100   llvm_stage
101
102   install -d ${STAGING_BINDIR_CROSS}
103         install -m 0755 build/bin/llvm-config${LLVM_RELEASE} ${STAGING_BINDIR_CROSS}
104 }
105
106 # Retrieve the target in a way that is compatible to the arch
107 # value in llvm (>= 2.5)
108 def get_llvm_arch(d):
109   import bb;
110
111   arch = bb.data.getVar('TARGET_ARCH', d, 1)
112   if arch == "x86_64" or arch == "i486" or arch == "i586" or arch == "i686":
113     arch = "X86"
114   elif arch == "arm":
115     arch = "ARM"
116   elif arch == "mipsel":
117     arch = "Mips"
118   elif arch == "powerpc":
119     arch = "PowerPC"
120   else:
121     oefatal("Your target architecture is not supported by this recipe");
122
123   return arch
124