summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-06-11 11:33:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-06-11 11:33:34 +0200
commitb697fba4a5c5395a9db271efa286870191418040 (patch)
tree50c542f5736bb3df0a5bcf47bc93248788900b93 /scripts
parent543a7c8e10e0dbc1af8207e4a30e439c4c66c473 (diff)
parent70e4e1e4f54ff8e4040b137a2b4d0f48baa74e0c (diff)
downloadbarebox-b697fba4a5c5395a9db271efa286870191418040.tar.gz
barebox-b697fba4a5c5395a9db271efa286870191418040.tar.xz
Merge branch 'for-next/macos'
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.lib4
-rw-r--r--scripts/bareboxcrc32.c2
-rw-r--r--scripts/bareboximd.c3
-rwxr-xr-xscripts/check_size2
-rw-r--r--scripts/compiler.h36
-rwxr-xr-xscripts/extract_symbol_offset2
-rwxr-xr-xscripts/file-size.sh4
-rw-r--r--scripts/fix_size.c3
-rwxr-xr-xscripts/gen-dtb-s4
-rw-r--r--scripts/imx/imx-image.c2
-rw-r--r--scripts/imx/imx-usb-loader.c3
-rw-r--r--scripts/include/linux/err.h2
-rw-r--r--scripts/include/linux/string.h6
-rw-r--r--scripts/include/linux/types.h14
-rw-r--r--scripts/kwbimage.c8
-rw-r--r--scripts/mkimage.c12
-rw-r--r--scripts/omap3-usb-loader.c6
17 files changed, 79 insertions, 34 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 95eaf522ab..87bff2d296 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -341,7 +341,7 @@ cmd_env=$(srctree)/scripts/genenv $(srctree) $(objtree) $@ $<
size_append = printf $(shell \
dec_size=0; \
for F in $1; do \
- fsize=$$(stat -c "%s" $$F); \
+ fsize=$$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $$F);\
dec_size=$$(expr $$dec_size + $$fsize); \
done; \
printf "%08x\n" $$dec_size | \
@@ -446,7 +446,7 @@ quiet_cmd_check_size = CHKSIZE $2
# Check size of a file
quiet_cmd_check_file_size = CHKFILESIZE $2
cmd_check_file_size = set -e; \
- size=`stat -c%s $2`; \
+ size=`${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $2`; \
max_size=`printf "%d" $3`; \
if [ $$size -gt $$max_size ] ; \
then \
diff --git a/scripts/bareboxcrc32.c b/scripts/bareboxcrc32.c
index e00ffafeb7..1b105a452b 100644
--- a/scripts/bareboxcrc32.c
+++ b/scripts/bareboxcrc32.c
@@ -38,7 +38,7 @@
int main(int argc, char *argv[])
{
- loff_t start = 0, size = ~0;
+ ulong start = 0, size = ~0;
ulong crc = 0, total = 0;
char *filename = NULL;
int i;
diff --git a/scripts/bareboximd.c b/scripts/bareboximd.c
index 7d4cbeb9a8..5ef91831c4 100644
--- a/scripts/bareboximd.c
+++ b/scripts/bareboximd.c
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <sys/types.h>
#include <stdint.h>
-#include <asm-generic/errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -58,7 +57,7 @@ int imd_command_setenv(const char *variable_name, const char *value)
return -EINVAL;
}
-static int read_file_2(const char *filename, size_t *size, void **outbuf, loff_t max_size)
+static int read_file_2(const char *filename, size_t *size, void **outbuf, size_t max_size)
{
off_t fsize;
ssize_t rsize;
diff --git a/scripts/check_size b/scripts/check_size
index 54f02a63c5..8530435d3a 100755
--- a/scripts/check_size
+++ b/scripts/check_size
@@ -5,7 +5,7 @@ file="$2"
max="$3"
# extract symbol offset from file, remove leading zeros
-ofs=$(nm -t d $file | grep "$symbol" | cut -d ' ' -f1 | sed "s/^[0]*//")
+ofs=$(${CROSS_COMPILE}nm -t d $file | grep "$symbol" | cut -d ' ' -f1 | sed "s/^[0]*//")
if [ -z "${ofs}" ]; then
echo "symbol $symbol not found in $file"
diff --git a/scripts/compiler.h b/scripts/compiler.h
index 4cf179bb9b..0ad25f9e8d 100644
--- a/scripts/compiler.h
+++ b/scripts/compiler.h
@@ -13,8 +13,6 @@
defined(__sun__) || \
defined(__APPLE__)
# include <inttypes.h>
-#elif defined(__linux__) || defined(__WIN32__) || defined(__MINGW32__)
-# include <stdint.h>
#endif
#include <errno.h>
@@ -40,16 +38,38 @@
#define O_BINARY 0
#endif
-#ifdef __linux__
+#if defined(__MACH__)
+# ifdef __APPLE__
+# include <libkern/OSByteOrder.h>
+# define htobe16(x) OSSwapHostToBigInt16(x)
+# define htole16(x) OSSwapHostToLittleInt16(x)
+# define be16toh(x) OSSwapBigToHostInt16(x)
+# define le16toh(x) OSSwapLittleToHostInt16(x)
+# define htobe32(x) OSSwapHostToBigInt32(x)
+# define htole32(x) OSSwapHostToLittleInt32(x)
+# define be32toh(x) OSSwapBigToHostInt32(x)
+# define le32toh(x) OSSwapLittleToHostInt32(x)
+# define htobe64(x) OSSwapHostToBigInt64(x)
+# define htole64(x) OSSwapHostToLittleInt64(x)
+# define be64toh(x) OSSwapBigToHostInt64(x)
+# define le64toh(x) OSSwapLittleToHostInt64(x)
+# else /* non apple __MACH__ */
+# include <machine/endian.h>
+# endif /* __APPLE__ */
+typedef unsigned long ulong;
+typedef unsigned int uint;
+#elif defined(__OpenBSD__) || defined(__FreeBSD__) || \
+ defined(__NetBSD__) || defined(__DragonFly__)
+# include <sys/endian.h>
+#else /* assume Linux */
# include <endian.h>
# include <byteswap.h>
-#elif defined(__MACH__)
-# include <machine/endian.h>
+#endif
+
+#if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
# define __BYTE_ORDER BYTE_ORDER
-# define __LITTLE_ENDIAN LITTLE_ENDIAN
# define __BIG_ENDIAN BIG_ENDIAN
-typedef unsigned long ulong;
-typedef unsigned int uint;
+# define __LITTLE_ENDIAN LITTLE_ENDIAN
#endif
typedef uint8_t __u8;
diff --git a/scripts/extract_symbol_offset b/scripts/extract_symbol_offset
index 1a1260f526..78b866830e 100755
--- a/scripts/extract_symbol_offset
+++ b/scripts/extract_symbol_offset
@@ -4,7 +4,7 @@ symbol="$1"
file="$2"
# extract symbol offset from file, remove leading zeros
-ofs=$(nm -t d $file | grep "$symbol" | cut -d ' ' -f1 | sed "s/^[0]*//")
+ofs=$(${CROSS_COMPILE}nm -t d $file | grep "$symbol" | cut -d ' ' -f1 | sed "s/^[0]*//")
if [ -z "${ofs}" ]; then
echo "symbol $symbol not found in $file"
diff --git a/scripts/file-size.sh b/scripts/file-size.sh
new file mode 100755
index 0000000000..7eb7423416
--- /dev/null
+++ b/scripts/file-size.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+set -- $(ls -dn "$1")
+printf '%s\n' "$5"
diff --git a/scripts/fix_size.c b/scripts/fix_size.c
index cb074e3cbc..e33edecf65 100644
--- a/scripts/fix_size.c
+++ b/scripts/fix_size.c
@@ -9,7 +9,8 @@
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
-#include <endian.h>
+
+#include "compiler.h"
int main(int argc, char**argv)
{
diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index 307b1f6866..b2dd253c27 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -55,8 +55,8 @@ lzop -f -9 $dtb -o $dtb.lzo
if [ $? != 0 ]; then
exit 1
fi
-compressed=$(stat $dtb.lzo -c "%s")
-uncompressed=$(stat $dtb -c "%s")
+compressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb.lzo)
+uncompressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb)
echo ".section .dtbz.rodata.${name},\"a\""
echo ".balign STRUCT_ALIGNMENT"
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 90be8a9b9b..6a258bd823 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -26,10 +26,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <endian.h>
#include <linux/kernel.h>
#include <sys/file.h>
#include <mach/imx_cpu_types.h>
+#include "../compiler.h"
#include "imx.h"
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index e3d3b8fce1..70883bf883 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -26,16 +26,15 @@
#include <unistd.h>
#include <ctype.h>
-#include <sys/io.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <libusb.h>
#include <getopt.h>
-#include <endian.h>
#include <arpa/inet.h>
#include <linux/kernel.h>
+#include "../compiler.h"
#include "imx.h"
#define get_min(a, b) (((a) < (b)) ? (a) : (b))
diff --git a/scripts/include/linux/err.h b/scripts/include/linux/err.h
index bdc3dd8131..9982ab17ba 100644
--- a/scripts/include/linux/err.h
+++ b/scripts/include/linux/err.h
@@ -4,7 +4,7 @@
#include <linux/compiler.h>
#include <linux/types.h>
-#include <asm/errno.h>
+#include <errno.h>
/*
* Original kernel header comment:
diff --git a/scripts/include/linux/string.h b/scripts/include/linux/string.h
index e26223f1f2..649287b80a 100644
--- a/scripts/include/linux/string.h
+++ b/scripts/include/linux/string.h
@@ -8,7 +8,11 @@ void *memdup(const void *src, size_t len);
int strtobool(const char *s, bool *res);
-#ifndef __UCLIBC__
+/*
+ * glibc based builds needs the extern while uClibc doesn't.
+ * However uClibc headers also define __GLIBC__ hence the hack below
+ */
+#if defined(__GLIBC) && !defined(__UCLIBC__)
extern size_t strlcpy(char *dest, const char *src, size_t size);
#endif
diff --git a/scripts/include/linux/types.h b/scripts/include/linux/types.h
index 8ebf6278b2..e81d7e8101 100644
--- a/scripts/include/linux/types.h
+++ b/scripts/include/linux/types.h
@@ -5,8 +5,18 @@
#include <stddef.h>
#include <stdint.h>
-#define __SANE_USERSPACE_TYPES__ /* For PPC64, to get LL64 types */
-#include <asm/types.h>
+typedef uint64_t __u64;
+typedef int64_t __s64;
+typedef uint32_t __u32;
+typedef int32_t __s32;
+typedef uint16_t __u16;
+typedef int16_t __s16;
+typedef uint8_t __u8;
+typedef int8_t __s8;
+
+#ifndef __linux__
+typedef long long loff_t;
+#endif
struct page;
struct kmem_cache;
diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 2a052a7ff3..6ba4abaa30 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -860,12 +860,16 @@ static void *image_create_v1(struct image_cfg_element *image_cfg,
ret = stat(binarye->binary.file, &s);
if (ret < 0) {
- char *cwd = get_current_dir_name();
+ char *buf, *cwd = NULL;
+ size_t size = (size_t)pathconf(".", _PC_PATH_MAX);
+ buf = malloc(size);
+ if (buf)
+ cwd = getcwd(buf, size);
fprintf(stderr,
"Didn't find the file '%s' in '%s' which is mandatory to generate the image\n"
"This file generally contains the DDR3 training code, and should be extracted from an existing bootable\n"
"image for your board. See 'kwbimage -x' to extract it from an existing image.\n",
- binarye->binary.file, cwd);
+ binarye->binary.file, cwd ? cwd : "current working directory");
free(cwd);
return NULL;
}
diff --git a/scripts/mkimage.c b/scripts/mkimage.c
index 891d7b6de7..7d283c5509 100644
--- a/scripts/mkimage.c
+++ b/scripts/mkimage.c
@@ -572,7 +572,11 @@ NXTARG: ;
}
/* We're a bit of paranoid */
-#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
+#if defined(_POSIX_SYNCHRONIZED_IO) && \
+ !defined(__sun__) && \
+ !defined(__FreeBSD__) && \
+ !defined(__OpenBSD__) && \
+ !defined(__APPLE__)
(void) fdatasync (ifd);
#else
(void) fsync (ifd);
@@ -622,7 +626,11 @@ NXTARG: ;
(void) munmap((void *)ptr, sbuf.st_size);
/* We're a bit of paranoid */
-#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__)
+#if defined(_POSIX_SYNCHRONIZED_IO) && \
+ !defined(__sun__) && \
+ !defined(__FreeBSD__) && \
+ !defined(__OpenBSD__) && \
+ !defined(__APPLE__)
(void) fdatasync (ifd);
#else
(void) fsync (ifd);
diff --git a/scripts/omap3-usb-loader.c b/scripts/omap3-usb-loader.c
index 3ba9af0652..ae6f1258df 100644
--- a/scripts/omap3-usb-loader.c
+++ b/scripts/omap3-usb-loader.c
@@ -33,10 +33,6 @@
#define OMAP_IS_BIG_ENDIAN
#endif
-#ifdef OMAP_IS_BIG_ENDIAN
-#include <arpa/inet.h>
-#endif
-
#include <unistd.h> /* for usleep and friends */
#include <getopt.h>
#include <errno.h>
@@ -403,7 +399,7 @@ static int transfer_first_stage(libusb_device_handle * handle, struct arg_state
data = file->data;
dbuf = data;
- if (le32toh(dbuf[5]) == 0x45534843) {
+ if (le32_to_cpu(dbuf[5]) == 0x45534843) {
int chsettingssize = 512 + 2 * sizeof(uint32_t);
log_info("CHSETTINGS image detected. Skipping header\n");