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
5 # This is true for the normal recipes as well as the native ones.
7 # All regular installation directories are prefixed with 'llvm${LLVM_RELEASE}'
8 # e.g. "${STAGING_BINDIR}/llvm2.5" or "${STAGING_INCDIR}/llvm2.5"
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
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.
20 DESCRIPTION = "The Low Level Virtual Machine"
21 HOMEPAGE = "http://llvm.org"
23 DEPENDS = "llvm-common llvm${LLVM_RELEASE}-native"
26 LICENSE = "University of Illinois/NCSA Open Source License"
28 SRC_URI = "http://llvm.org/releases/${PV}/llvm-${PV}.tar.gz"
30 S = "${WORKDIR}/llvm-${PV}"
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)}"
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}"
44 # llvm *must* be built out of tree
45 OECMAKE_SOURCEPATH = ".."
46 OECMAKE_BUILDPATH = "build"
48 -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/llvm${LLVM_RELEASE}/tblgen \
49 -DLLVM_TARGETS_TO_BUILD=${LLVM_ARCH} \
50 -DCMAKE_LINKER:FILEPATH=${LD} \
51 -DCMAKE_AR:FILEPATH=${AR} \
52 -DCMAKE_OBJCOPY:FILEPATH=${OBJCOPY} \
53 -DCMAKE_OBJDUMP:FILEPATH=${OBJDUMP} \
54 -DCMAKE_RANLIB:FILEPATH=${RANLIB} \
55 -DCMAKE_STRIP:FILEPATH=${STRIP} \
56 -DNM_PATH:FILEPATH=${NM} \
57 -DLLVM_ENABLE_PIC:BOOL=ON \
61 # Install into a private directory to be able to reorganize the files.
62 oe_runmake DESTDIR=${WORKDIR}/llvm-install install
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}
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}/
75 # llvm somehow forgets these
76 # find include/llvm -name "*.h" -maxdepth 1 -exec \
77 # install {} ${STAGING_INCDIR}/llvm${LLVM_RELEASE}/llvm \;
79 find ${WORKDIR}/llvm-install/${prefix}/lib -name "*" -maxdepth 1 -exec \
80 install {} ${STAGING_LIBDIR}/llvm${LLVM_RELEASE} \;
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} \;
86 # LLVM does not install this by default.
87 install bin/tblgen ${STAGING_BINDIR}/llvm${LLVM_RELEASE}
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
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 bin/llvm-config > bin/llvm-config${LLVM_RELEASE}
100 cd ${OECMAKE_BUILDPATH}
104 install -d ${STAGING_BINDIR_CROSS}
105 install -m 0755 bin/llvm-config${LLVM_RELEASE} ${STAGING_BINDIR_CROSS}
108 # Retrieve the target in a way that is compatible to the arch
109 # value in llvm (>= 2.5)
110 def get_llvm_arch(d):
113 arch = bb.data.getVar('TARGET_ARCH', d, 1)
114 if arch == "x86_64" or arch == "i486" or arch == "i586" or arch == "i686":
118 elif arch == "mipsel":
120 elif arch == "powerpc":
123 oefatal("Your target architecture is not supported by this recipe");