summaryrefslogtreecommitdiff
path: root/recipes/llvm/llvm_2.5.bb
blob: ece64422b5055a11c4ec7f617b0d6f6af41f2b5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
DESCRIPTION = "The Low Level Virtual Machine"
HOMEPAGE = "http://llvm.org"
LICENSE = "various"

SRC_URI = "\
  http://llvm.org/releases/${PV}/llvm-${PV}.tar.gz \
  file://fix-build.patch;patch=1 \
"

PR = "r2"

DEPENDS = "llvm-native"

inherit cmake

OECMAKE_SOURCEPATH = ".."
OECMAKE_BUILDPATH = "build"
EXTRA_OEMAKE = "-C build"
EXTRA_OECMAKE = "\
  -DLLVM_TABLEGEN=${STAGING_BINDIR_NATIVE}/tblgen \
  -DLLVM_TARGETS_TO_BUILD=${@get_llvm_arch(d)} \
  -DCMAKE_LINKER:FILEPATH=${LD} \
  -DCMAKE_AR:FILEPATH=${AR} \
  -DCMAKE_OBJCOPY:FILEPATH=${OBJCOPY} \
  -DCMAKE_OBJDUMP:FILEPATH=${OBJDUMP} \
  -DCMAKE_RANLIB:FILEPATH=${RANLIB} \
  -DCMAKE_STRIP:FILEPATH=${STRIP} \
"

do_stage() {
  oe_runmake DESTDIR="${STAGING_DIR_HOST}" install

  install -d ${STAGING_INCDIR}/llvm
	find include/llvm -name "*.h" -maxdepth 1 -exec \
    install {} ${STAGING_INCDIR}/llvm \;

  install -d ${STAGING_BINDIR_CROSS}

  # Fix some paths in the script to make it work correctly
  sed -e's^my.*ABS_RUN_DIR =.*^my $ABS_RUN_DIR = "${STAGING_DIR_TARGET}";^' \
      -e's^my.*INCLUDEDIR =.*^my $INCLUDEDIR = "${STAGING_INCDIR}";^' \
      -e's^my.*LIBDIR.*^my $LIBDIR = "${STAGING_LIBDIR}";^' \
      -e's^my.*BINDIR.*^my $BINDIR = "${STAGING_BINDIR}";^' \
      build/bin/llvm-config > ${STAGING_BINDIR_CROSS}/llvm-config

  chmod +x ${STAGING_BINDIR_CROSS}/llvm-config
}

# Retrieve the target in a way that is compatible to the arch
# value in llvm (>= 2.5)
def get_llvm_arch(d):
  import bb;

  arch = bb.data.getVar('TARGET_ARCH', d, 1)
  if arch == "x86_64" or arch == "i486" or arch == "i586" or arch == "i686":
    arch = "X86"
  elif arch == "arm":
    arch = "ARM"
  elif arch == "mipsel":
    arch = "Mips"
  elif arch == "powerpc":
    arch = "PowerPC"
  else:
    oefatal("Your target architecture is not supported by this recipe");

  return arch