A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

Make simulator compile on MacOS

Tested on MacOS Sequoia (Apple Silicon) with the
latest Xcode command line tools, gcc 14
(Homebrew GCC 14.2.0_1) and sdl2 (Homebrew 2.30.9)

Make sure 'gcc' (and 'gcc-ar') is in your PATH
ahead of the Xcode-provided "gcc"(clang). E.g.
by setting up symlinks in /usr/local/bin that
point to gcc-14 and gcc-ar-14.

Notes:
- The appropriate bmp from uisimulator/bitmaps
has to be manually copied to your build folder
and renamed to UI256.bmp, if you want the sim
background to be displayed

Change-Id: I559f33d2165065f913f30c016b85906af380fb81

authored by

Christian Soffke and committed by
Solomon Peachy
1745b745 f9ae6d65

+75 -8
+6
apps/playback.c
··· 3989 3989 3990 3990 /* How many tracks exist on the buffer - full or partial */ 3991 3991 unsigned int audio_track_count(void) 3992 + #ifndef __APPLE__ 3992 3993 __attribute__((alias("track_list_count"))); 3994 + #else 3995 + { 3996 + return track_list_count(); 3997 + } 3998 + #endif 3993 3999 3994 4000 /* Return total ringbuffer space occupied - ridx to widx */ 3995 4001 long audio_filebufused(void)
+11
apps/plugin.h
··· 46 46 #undef strncmp 47 47 #undef strchr 48 48 #undef strtok_r 49 + #ifdef __APPLE__ 50 + #undef strncpy 51 + #undef snprintf 52 + #undef strcpy 53 + #undef strcat 54 + #undef memset 55 + #undef memcpy 56 + #undef memmove 57 + #undef vsnprintf 58 + #undef vsprintf 59 + #endif 49 60 50 61 char* strncpy(char *, const char *, size_t); 51 62 void* plugin_get_buffer(size_t *buffer_size);
+1 -1
apps/plugins/imageviewer/imageviewer.make
··· 32 32 IMGDEC_OUTLDS = $(IMGVBUILDDIR)/%.link 33 33 IMGDEC_OVLFLAGS = -T$(IMGVBUILDDIR)/$*.link -Wl,--gc-sections -Wl,-Map,$(IMGVBUILDDIR)/$*.map 34 34 else 35 - IMGDEC_OVLFLAGS = $(PLUGINLDFLAGS) -Wl,-Map,$(IMGVBUILDDIR)/$*.map 35 + IMGDEC_OVLFLAGS = $(PLUGINLDFLAGS) -Wl,$(LDMAP_OPT),$(IMGVBUILDDIR)/$*.map 36 36 endif 37 37 38 38 $(IMGVBUILDDIR)/%.ovl: $(IMGDEC_OUTLDS)
+1 -1
apps/plugins/plugins.make
··· 145 145 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PLUGINFLAGS) -c $< -o $@ 146 146 147 147 ifdef APP_TYPE 148 - PLUGINLDFLAGS = $(SHARED_LDFLAGS) -Wl,-Map,$*.map 148 + PLUGINLDFLAGS = $(SHARED_LDFLAGS) -Wl,$(LDMAP_OPT),$*.map 149 149 PLUGINFLAGS += $(SHARED_CFLAGS) # <-- from Makefile 150 150 else 151 151 PLUGINLDFLAGS = -T$(PLUGINLINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map
+2 -2
apps/plugins/puzzles/puzzles.make
··· 48 48 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(PUZZLES_OBJDIR)/$*.elf \ 49 49 $(filter %.o, $^) \ 50 50 $(filter %.a, $+) \ 51 - -lgcc $(filter-out -Wl%.map, $(PLUGINLDFLAGS)) -Wl,-Map,$(PUZZLES_OBJDIR)/src/$*.map 51 + -lgcc $(filter-out -Wl%.map, $(PLUGINLDFLAGS)) -Wl,$(LDMAP_OPT),$(PUZZLES_OBJDIR)/src/$*.map 52 52 $(SILENT)$(call objcopy,$(PUZZLES_OBJDIR)/$*.elf,$@) 53 53 54 54 $(PUZZLES_OBJDIR)/sgt-%.rock: $(PUZZLES_OBJDIR)/src/unfinished/%.o $(PUZZLES_SHARED_OBJ) $(TLSFLIB) 55 55 $(call PRINTS,LD $(@F))$(CC) $(PLUGINFLAGS) -o $(PUZZLES_OBJDIR)/$*.elf \ 56 56 $(filter %.o, $^) \ 57 57 $(filter %.a, $+) \ 58 - -lgcc $(filter-out -Wl%.map, $(PLUGINLDFLAGS)) -Wl,-Map,$(PUZZLES_OBJDIR)/src/$*.map 58 + -lgcc $(filter-out -Wl%.map, $(PLUGINLDFLAGS)) -Wl,$(LDMAP_OPT),$(PUZZLES_OBJDIR)/src/$*.map 59 59 $(SILENT)$(call objcopy,$(PUZZLES_OBJDIR)/$*.elf,$@) 60 60 61 61 $(PUZZLES_SRCDIR)/rbcompat.h: $(APPSDIR)/plugin.h \
+4
firmware/include/rbendian.h
··· 28 28 #endif 29 29 30 30 #ifndef __MINGW32__ 31 + #ifdef __APPLE__ 32 + #include <sys/types.h> 33 + #else 31 34 #include <endian.h> 35 + #endif 32 36 #endif 33 37 34 38 /* clear these out since we redefine them to be truely constant compatible */
+15
firmware/target/hosted/filesystem-unix.c
··· 19 19 * 20 20 ****************************************************************************/ 21 21 #define RB_FILESYSTEM_OS 22 + #ifdef __APPLE__ 23 + #include <sys/param.h> 24 + #include <sys/mount.h> 25 + #else 22 26 #include <sys/statfs.h> /* lowest common denominator */ 27 + #endif 23 28 #include <sys/stat.h> 24 29 #include <string.h> 25 30 #include <errno.h> ··· 218 223 if (os_volume_path(IF_MV(volume,) volpath, sizeof (volpath)) >= 0 219 224 && !statfs(volpath, &fs)) 220 225 { 226 + #ifdef __APPLE__ 227 + DEBUGF("statvfs: frsize=%d blocks=%ld bfree=%ld\n", 228 + (int)fs.f_bsize, (long)fs.f_blocks, (long)fs.f_bfree); 229 + if (sizep) 230 + size = (fs.f_blocks / 2) * (fs.f_bsize / 512); 231 + 232 + if (freep) 233 + free = (fs.f_bfree / 2) * (fs.f_bsize / 512); 234 + #else 221 235 DEBUGF("statvfs: frsize=%d blocks=%ld bfree=%ld\n", 222 236 (int)fs.f_frsize, (long)fs.f_blocks, (long)fs.f_bfree); 223 237 if (sizep) ··· 225 239 226 240 if (freep) 227 241 free = (fs.f_bfree / 2) * (fs.f_frsize / 512); 242 + #endif 228 243 } 229 244 230 245 if (sizep)
+3 -1
firmware/target/hosted/rtc.c
··· 24 24 #include <sys/time.h> 25 25 #if !defined(WIN32) 26 26 #include <sys/ioctl.h> 27 + #if !defined(__APPLE__) 27 28 #include <linux/rtc.h> 29 + #endif 28 30 #include <fcntl.h> 29 31 #include <unistd.h> 30 32 #include <stdbool.h> ··· 47 49 48 50 int rtc_write_datetime(const struct tm *tm) 49 51 { 50 - #if !defined(WIN32) 52 + #if !defined(WIN32) && !defined(__APPLE__) 51 53 struct timeval tv; 52 54 struct tm *tm_time; 53 55
+5 -1
lib/rbcodec/codecs/codecs.make
··· 26 26 -I$(RBCODECLIB_DIR)/codecs -I$(RBCODECLIB_DIR)/codecs/lib -DCODEC 27 27 28 28 ifdef APP_TYPE 29 - CODECLDFLAGS = $(SHARED_LDFLAGS) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map 29 + ifeq ($(UNAME), Darwin) 30 + CODECLDFLAGS = $(SHARED_LDFLAGS) -Wl,-map,$(CODECDIR)/$*.map 31 + else 32 + CODECLDFLAGS = $(SHARED_LDFLAGS) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map 33 + endif 30 34 CODECFLAGS += $(SHARED_CFLAGS) # <-- from Makefile 31 35 else 32 36 CODECLDFLAGS = -T$(CODECLINK_LDS) -Wl,--gc-sections -Wl,-Map,$(CODECDIR)/$*.map
+7
lib/rbcodec/codecs/lib/codeclib.h
··· 47 47 void* codec_realloc(void* ptr, size_t size); 48 48 void codec_free(void* ptr); 49 49 50 + #ifdef __APPLE__ 51 + #undef memcpy 52 + #undef strcat 53 + #undef memset 54 + #undef memmove 55 + #undef strcpy 56 + #endif 50 57 void *memcpy(void *dest, const void *src, size_t n); 51 58 void *memset(void *s, int c, size_t n); 52 59 int memcmp(const void *s1, const void *s2, size_t n);
+7 -2
tools/configure
··· 14 14 LDOPTS="" 15 15 # LD options for the core + plugins 16 16 GLOBAL_LDOPTS="" 17 + LDMAP_OPT="-Map" 17 18 18 19 extradefines="" 19 20 use_logf="#undef ROCKBOX_HAS_LOGF" ··· 260 261 261 262 app_type=$1 262 263 winbuild="" 264 + macbuild="" 263 265 GCCOPTS=`echo $CCOPTS | sed -e s/\ -ffreestanding// -e s/\ -nostdlib// -e s/\ -Wundef//` 264 266 265 267 if [ "yes" = "$use_debug" ]; then ··· 391 393 sigaltstack=`check_sigaltstack` 392 394 echo "Darwin host detected" 393 395 LDOPTS="$LDOPTS -ldl" 394 - SHARED_LDFLAGS="-dynamiclib -Wl\,-single_module" 396 + SHARED_LDFLAGS="-dynamiclib -Wl,-no_warn_duplicate_libraries" 397 + LDMAP_OPT="-map" 398 + macbuild="yes" 395 399 ;; 396 400 397 401 SunOS) ··· 409 413 esac 410 414 fi 411 415 412 - if [ "$winbuild" != "yes" ]; then 416 + if [ "$winbuild" != "yes" ] && [ "$macbuild" != "yes" ]; then 413 417 GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs" 414 418 if [ "`uname -m`" = "i686" ]; then 415 419 echo "Enabling MMX support" ··· 4875 4879 export SHARED_CFLAGS=${SHARED_CFLAGS} 4876 4880 export LDOPTS=${LDOPTS} 4877 4881 export GLOBAL_LDOPTS=${GLOBAL_LDOPTS} 4882 + export LDMAP_OPT=${LDMAP_OPT} 4878 4883 export GCCVER=${gccver} 4879 4884 export GCCNUM=${gccnum} 4880 4885 export UNAME=${uname}
+5
tools/mkspl-x1000.c
··· 25 25 #include <string.h> 26 26 #include <stdarg.h> 27 27 #include <stdlib.h> 28 + #ifdef __APPLE__ 29 + #include <libkern/OSByteOrder.h> 30 + #define htole32(x) OSSwapHostToLittleInt32(x) 31 + #else 28 32 #include <endian.h> /* TODO: find portable alternative */ 33 + #endif 29 34 30 35 #define SPL_HEADER_SIZE 512 31 36 #define SPL_KEY_SIZE 1536
+8
uisimulator/uisimulator.make
··· 21 21 ifeq (yes,$(APPLICATION)) 22 22 UIBMP= 23 23 else 24 + ifeq ($(UNAME), Darwin) 25 + UIBMP= 26 + else 24 27 UIBMP=$(BUILDDIR)/UI256.bmp 28 + endif 25 29 endif 26 30 27 31 .SECONDEXPANSION: # $$(OBJ) is not populated until after this ··· 31 35 $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null 32 36 33 37 $(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS) $(SIMLIB) 38 + ifeq ($(UNAME), Darwin) 39 + $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(SIMLIB) $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-map,$(BUILDDIR)/rockbox.map 40 + else 34 41 $(call PRINTS,LD $(BINARY))$(CC) -o $@ -Wl,--start-group $^ -Wl,--end-group $(LDOPTS) $(GLOBAL_LDOPTS) \ 35 42 -Wl,-Map,$(BUILDDIR)/rockbox.map 43 + endif 36 44 $(SILENT)$(call objcopy,$@,$@) 37 45 38 46 $(BUILDDIR)/uisimulator/%.o: $(ROOTDIR)/uisimulator/%.c