Compatibility with FreeBSD
authorMatheus Garcia <37114863+Krush206@users.noreply.github.com>
Sat, 21 Oct 2023 15:40:07 +0000 (15:40 +0000)
committernotaz <notasas@gmail.com>
Sat, 21 Oct 2023 18:19:08 +0000 (21:19 +0300)
Makefile
configure
frontend/menu.c
plugins/gpulib/gpulib.mak

index bf528b1..af1216f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -302,10 +302,10 @@ ifneq ($(PLUGINS),)
 plugins_: $(PLUGINS)
 
 $(PLUGINS):
-       make -C $(dir $@)
+       $(MAKE) -C $(dir $@)
 
 clean_plugins:
-       make -C plugins/gpulib/ clean
+       $(MAKE) -C plugins/gpulib/ clean
        for dir in $(PLUGINS) ; do \
                $(MAKE) -C $$(dirname $$dir) clean; done
 else
index 39587aa..420a07c 100755 (executable)
--- a/configure
+++ b/configure
@@ -66,15 +66,27 @@ optimize_cortexa8="no"
 optimize_arm926ej="no"
 
 # hardcoded stuff
-CC="${CC-${CROSS_COMPILE}gcc}"
-CXX="${CXX-${CROSS_COMPILE}g++}"
+if [ ${OSTYPE} = "FreeBSD" ]; then
+       CC="clang"
+       CXX="clang++"
+       CFLAGS="-I/usr/local/include -L/usr/local/lib"
+       MAKE=gmake
+else
+       CC="${CC-${CROSS_COMPILE}gcc}"
+       CXX="${CXX-${CROSS_COMPILE}g++}"
+fi
 AS="${AS-${CROSS_COMPILE}as}"
 AR="${AS-${CROSS_COMPILE}ar}"
 MAIN_LDLIBS="$LDLIBS -ldl -lm -lpthread"
 config_mak="config.mak"
 
-SYSROOT="$(${CC} --print-sysroot)"
-[ "x${SDL_CONFIG}" = "x" ] && SDL_CONFIG="${SYSROOT}/usr/bin/sdl-config"
+if [ ${OSTYPE} = "FreeBSD" ]; then
+       SYSROOT="$sysroot"
+       [ "x${SDL_CONFIG}" = "x" ] && SDL_CONFIG="${SYSROOT}/usr/local/bin/sdl-config"
+else
+       SYSROOT="$(${CC} --print-sysroot)"
+       [ "x${SDL_CONFIG}" = "x" ] && SDL_CONFIG="${SYSROOT}/usr/bin/sdl-config"
+fi
 
 fail()
 {
index 6bc20c5..6516e34 100644 (file)
@@ -9,6 +9,11 @@
  */
 
 #define _GNU_SOURCE 1
+#ifdef __FreeBSD__
+#define STAT stat
+#else
+#define STAT stat64
+#endif
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
@@ -214,7 +219,7 @@ static int optional_cdimg_filter(struct dirent **namelist, int count,
        const char *ext, *p;
        char buf[256], buf2[256];
        int i, d, ret, good_cue;
-       struct stat64 statf;
+       struct STAT statf;
        FILE *f;
 
        if (count <= 1)
@@ -263,7 +268,7 @@ static int optional_cdimg_filter(struct dirent **namelist, int count,
                                        p = buf2;
 
                                snprintf(buf, sizeof(buf), "%s/%s", basedir, p);
-                               ret = stat64(buf, &statf);
+                               ret = STAT(buf, &statf);
                                if (ret == 0) {
                                        rm_namelist_entry(namelist, count, p);
                                        good_cue = 1;
@@ -541,7 +546,7 @@ static int menu_do_last_cd_img(int is_get)
 {
        static const char *defaults[] = { "/media", "/mnt/sd", "/mnt" };
        char path[256];
-       struct stat64 st;
+       struct STAT st;
        FILE *f;
        int i, ret = -1;
 
@@ -564,7 +569,7 @@ static int menu_do_last_cd_img(int is_get)
 out:
        if (is_get) {
                for (i = 0; last_selected_fname[0] == 0
-                      || stat64(last_selected_fname, &st) != 0; i++)
+                      || STAT(last_selected_fname, &st) != 0; i++)
                {
                        if (i >= ARRAY_SIZE(defaults))
                                break;
index 6377274..4e1c659 100644 (file)
@@ -49,7 +49,7 @@ $(BIN_GPULIB): $(SRC) $(SRC_GPULIB) $(GPULIB_A)
 endif
 
 $(GPULIB_A):
-       make -C ../gpulib/ all
+       $(MAKE) -C ../gpulib/ all
 
 clean:
        $(RM) $(TARGETS)