Mercurial > vanilla
changeset 551:8ca04a2c9ed6
lib/libnl: initial import, closes #1658
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 23 Jun 2019 16:57:04 +0200 |
parents | a4a6fe4119f6 |
children | 317831fa1a64 |
files | lib/libnl/libnl.sh lib/libnl/musl.patch |
diffstat | 2 files changed, 157 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/libnl/libnl.sh Sun Jun 23 16:57:04 2019 +0200 @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Copyright (c) 2019 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +PKGNAME=libnl +PKGVERSION=3.4.0 +PKGREVISION=1 +PKGLICENSE="netlink library" +PKGSUMMARY="LGPLv21" +PKGDOWNLOAD="https://github.com/thom311/libnl/releases/download/libnl3_4_0/$PKGNAME-$PKGVERSION.tar.gz" +PKGDEPENDS="dev/bison:build" + +: ${CHOST:=$(uname -m)-linux-musl} +: ${CBUILD:=$(uname -m)-linux-musl} +: ${CC:=clang} +: ${CFLAGS:=-O2} +: ${LDFLAGS:=} +: ${LIBS:=} + +build() +{ + rm -rf $PKGNAME-$PKGVERSION + tar xvaf $PKGNAME-$PKGVERSION.tar.gz + pushd $PKGNAME-$PKGVERSION + + # https://git.alpinelinux.org/aports/plain/main/libnl3/libnl3-musl.patch + patch -p1 < ../musl.patch + CC="$CC" \ + CFLAGS="$CFLAGS" \ + LDFLAGS="$LDFLAGS" \ + LIBS="$LIBS" \ + ./configure \ + --build=$CBUILD \ + --host=$CHOST \ + --prefix= + make + make install DESTDIR=$DESTDIR + + popd + rm -rf $PKGNAME-$PKGVERSION +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/libnl/musl.patch Sun Jun 23 16:57:04 2019 +0200 @@ -0,0 +1,103 @@ +diff -Naur libnl-3.3.0_rc1.orig/include/linux-private/linux/if_ether.h libnl-3.3.0_rc1/include/linux-private/linux/if_ether.h +--- libnl-3.3.0_rc1.orig/include/linux-private/linux/if_ether.h 2017-03-08 19:56:31.824516933 -0800 ++++ libnl-3.3.0_rc1/include/linux-private/linux/if_ether.h 2017-03-08 20:07:01.938237767 -0800 +@@ -22,6 +22,7 @@ + #define _LINUX_IF_ETHER_H + + #include <linux/types.h> ++#include <linux/libc-compat.h> + + /* + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble +@@ -117,10 +118,12 @@ + * This is an Ethernet frame header. + */ + ++#if __UAPI_DEF_ETHHDR + struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + __be16 h_proto; /* packet type ID field */ + } __attribute__((packed)); ++#endif + + #endif /* _LINUX_IF_ETHER_H */ +diff -Naur libnl-3.3.0_rc1.orig/include/linux-private/linux/libc-compat.h libnl-3.3.0_rc1/include/linux-private/linux/libc-compat.h +--- libnl-3.3.0_rc1.orig/include/linux-private/linux/libc-compat.h 2017-03-08 19:56:31.823516923 -0800 ++++ libnl-3.3.0_rc1/include/linux-private/linux/libc-compat.h 2017-03-08 20:12:30.376843489 -0800 +@@ -48,10 +48,18 @@ + #ifndef _LIBC_COMPAT_H + #define _LIBC_COMPAT_H + +-/* We have included glibc headers... */ +-#if defined(__GLIBC__) ++/* We're used from userspace... */ ++#if !defined(__KERNEL__) + +-/* Coordinate with glibc netinet/in.h header. */ ++/* Coordinate with libc netinet/if_ether.h */ ++#ifdef _NETINET_IF_ETHER_H /* musl */ ++#define __UAPI_DEF_ETHHDR 0 ++#else ++/* glibc uses __NETINET_IF_ETHER_H, and uses the uapi header. */ ++#define __UAPI_DEF_ETHHDR 1 ++#endif ++ ++/* Coordinate with libc netinet/in.h header. */ + #if defined(_NETINET_IN_H) + + /* GLIBC headers included first so don't define anything +@@ -64,15 +72,7 @@ + #define __UAPI_DEF_IN_CLASS 0 + + #define __UAPI_DEF_IN6_ADDR 0 +-/* The exception is the in6_addr macros which must be defined +- * if the glibc code didn't define them. This guard matches +- * the guard in glibc/inet/netinet/in.h which defines the +- * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */ +-#if defined(__USE_MISC) || defined (__USE_GNU) + #define __UAPI_DEF_IN6_ADDR_ALT 0 +-#else +-#define __UAPI_DEF_IN6_ADDR_ALT 1 +-#endif + #define __UAPI_DEF_SOCKADDR_IN6 0 + #define __UAPI_DEF_IPV6_MREQ 0 + #define __UAPI_DEF_IPPROTO_V6 0 +@@ -83,7 +83,7 @@ + #else + + /* Linux headers included first, and we must define everything +- * we need. The expectation is that glibc will check the ++ * we need. The expectation is that libc will check the + * __UAPI_DEF_* defines and adjust appropriately. */ + #define __UAPI_DEF_IN_ADDR 1 + #define __UAPI_DEF_IN_IPPROTO 1 +@@ -93,7 +93,7 @@ + #define __UAPI_DEF_IN_CLASS 1 + + #define __UAPI_DEF_IN6_ADDR 1 +-/* We unconditionally define the in6_addr macros and glibc must ++/* We unconditionally define the in6_addr macros and libc must + * coordinate. */ + #define __UAPI_DEF_IN6_ADDR_ALT 1 + #define __UAPI_DEF_SOCKADDR_IN6 1 +@@ -115,7 +115,10 @@ + /* If we did not see any headers from any supported C libraries, + * or we are being included in the kernel, then define everything + * that we need. */ +-#else /* !defined(__GLIBC__) */ ++#else /* defined(__KERNEL__) */ ++ ++/* Definitions for if/ether.h */ ++#define __UAPI_DEF_ETHHDR 1 + + /* Definitions for in.h */ + #define __UAPI_DEF_IN_ADDR 1 +@@ -138,6 +141,6 @@ + /* Definitions for xattr.h */ + #define __UAPI_DEF_XATTR 1 + +-#endif /* __GLIBC__ */ ++#endif /* defined(__KERNEL__) */ + + #endif /* _LIBC_COMPAT_H */