Fix build on OSX host

FreeBSD's stat command doesn't support -c/--format option and use %z specifier for file size

Change-Id: I368b6eef0a692df0f16bc1c3d5b5399fcf91e051
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4326
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Semion Dimov 2021-08-14 16:22:51 +03:00 committed by Jérôme Duval
parent dbd1ff0988
commit c39da9b7a0
2 changed files with 14 additions and 9 deletions

View File

@ -1531,6 +1531,16 @@ rule BuildFloppyBootImage image : haikuLoader : archive
#MakeLocateDebug $(image) ;
FLOPPY_IMAGE_SIZE on $(image) = $(HAIKU_BOOT_FLOPPY_IMAGE_SIZE) ;
ARCHIVE_IMAGE_OFFSET on $(image) = $(HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET) ;
# FreeBSD's stat command doesn't support -c/--format option
# and use %z specifier for file size
if $(HOST_PLATFORM) = freebsd || $(HOST_PLATFORM) = darwin
|| $(HOST_PLATFORM) = openbsd {
STAT_GET_SIZE = "stat -f %z" ;
} else {
STAT_GET_SIZE = "stat -c %s" ;
}
BuildFloppyBootImage1 $(image) : $(haikuLoader) $(archive) ;
if $(HAIKU_KERNEL_PLATFORM) = atari_m68k {
Depends $(image) : <build>fixup_tos_boot_checksum ;
@ -1546,14 +1556,9 @@ rule BuildFloppyBootImage image : haikuLoader : archive
actions BuildFloppyBootImage1
{
haiku_loader_size=`stat -c %s "$(>[1])"`
drivers_tgz_size=`stat -c %s "$(>[2])"`
if [ $? -ne 0 ] ; then
# FreeBSD's stat command don't support -c/--format option
# and use %z specifier for file size
haiku_loader_size=`stat -f %z "$(>[1])"`
drivers_tgz_size=`stat -f %z "$(>[2])"`
fi
haiku_loader_size=`$(STAT_GET_SIZE) "$(>[1])"`
drivers_tgz_size=`$(STAT_GET_SIZE) "$(>[2])"`
archive_image_offset=`echo "$(ARCHIVE_IMAGE_OFFSET) * 1024" | bc`
floppy_tgz_size=\
`echo "($(FLOPPY_IMAGE_SIZE) - $(ARCHIVE_IMAGE_OFFSET)) * 1024" | bc`

View File

@ -6,8 +6,8 @@
#include <KernelExport.h>
#include <ctype.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "encodings.h"