1# Copyright (C) 2018 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4SUMMARY = "Minimal libssp_nonshared.a must needed for ssp to work with gcc on musl"
5LICENSE = "BSD-3-Clause"
6LIC_FILES_CHKSUM = "file://stack_chk.c;beginline=1;endline=30;md5=97e59d9deee678a9332c9ddb2ab6360d"
7SECTION = "libs"
8
9# Sourced from https://github.com/intel/linux-sgx/blob/master/sdk/compiler-rt/stack_chk.c
10SRC_URI = "file://stack_chk.c"
11
12INHIBIT_DEFAULT_DEPS = "1"
13
14DEPENDS = "virtual/${TARGET_PREFIX}binutils \
15           virtual/${TARGET_PREFIX}gcc \
16"
17
18do_configure[noexec] = "1"
19
20S = "${WORKDIR}"
21
22do_compile() {
23	${CC} ${CPPFLAGS} ${CFLAGS} -fPIE -c stack_chk.c -o stack_chk.o
24	${AR} r libssp_nonshared.a stack_chk.o
25}
26do_install() {
27	install -Dm 0644 ${B}/libssp_nonshared.a ${D}${base_libdir}/libssp_nonshared.a
28}
29#
30# We will skip parsing for non-musl systems
31#
32COMPATIBLE_HOST = ".*-musl.*"
33RDEPENDS:${PN}-staticdev = ""
34RDEPENDS:${PN}-dev = ""
35RRECOMMENDS:${PN}-dbg = "${PN}-staticdev (= ${EXTENDPKGV})"
36