Hacks to allow OS X build for 32-bit.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Jun 2019 20:31:00 +0000 (21:31 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 8 Mar 2020 08:20:08 +0000 (09:20 +0100)
Makefile
cscript
toolchain/osx.cmake
toolchain/osx32.cmake [new file with mode: 0644]

index 5cd1efb5d16a52cbf8dc97cf78c743d3fbe1fd03..0c468398528f900ad669ae0d4f14cb4ef2a429c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,56 +33,53 @@ endef
 generic:
        $(call generate_common,$@)
 
-osx:   
+osx:
        $(call generate_common,$@)
 
+osx32:
+       $(call generate_common,$@,-DCMAKE_OSX_ARCHITECTURES=i386)
+
 cortex-m0:
        $(call generate_common,$@)
-       
+
 cortex-m0+:
        $(call generate_common,$@)
-       
+
 cortex-m3:
        $(call generate_common,$@)
-       
+
 cortex-m4:
        $(call generate_common,$@)
-       
+
 cortex-m4f:
        $(call generate_common,$@)
-       
+
 cortex-m7:
        $(call generate_common,$@)
 
 arm-sim:
        $(call generate_common,$@)
 
-avrxmega7: 
+avrxmega7:
        $(call generate_common,$@)
 
 msp430:
        $(call generate_common,$@)
-       
+
 mingw:
        $(call generate_common,$@,-DWIN32=1)
-       
+
 lib_only:
        rm -R -f build_lib_only
        mkdir build_lib_only
        cd build_lib_only && cmake $(COMMON_DEFINITIONS) -DLIB_ONLY=TRUE ..
 
-all: 
+all:
        generic
 
 clean:
        rm -R -f build_*
        rm -R -f ext_images
 
-       
-include fs_test.mk
-
-
-       
 
-       
-       
+include fs_test.mk
diff --git a/cscript b/cscript
index fc799023e2c5fe8efd9a63bbbfcae2753985c900..5cc18c6286d3f8846c7c76991d7c4a3f0ee6852b 100644 (file)
--- a/cscript
+++ b/cscript
@@ -24,7 +24,10 @@ def build(target, options):
         ext = 'so'
         device = 'dev'
     elif target.platform == 'osx':
-        type = 'generic'
+        if target.bits == 64:
+            type = 'osx'
+        else:
+            type = 'osx32'
         blockdev = 'linux'
         ext = 'dylib'
         device = 'dev'
index 43c9ea7717b0fd13548dfcc9a9077c8cabd670c3..c9207101ca3072a02db99d46780ba7d8377d0d1e 100644 (file)
@@ -9,7 +9,7 @@ set(AS                  as)
 set(AR                  as)
 set(OBJCOPY             objcopy)
 set(OBJDUMP             objdump)
-set(SIZE                size)
+#set(SIZE                size)
 
 set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
 
diff --git a/toolchain/osx32.cmake b/toolchain/osx32.cmake
new file mode 100644 (file)
index 0000000..c920710
--- /dev/null
@@ -0,0 +1,31 @@
+# Name of the target
+set(CMAKE_SYSTEM_NAME Darwin)
+set(CMAKE_SYSTEM_PROCESSOR i386)
+
+# Toolchain settings
+set(CMAKE_C_COMPILER    gcc)
+set(CMAKE_CXX_COMPILER  g++)
+set(AS                  as)
+set(AR                  as)
+set(OBJCOPY             objcopy)
+set(OBJDUMP             objdump)
+#set(SIZE                size)
+
+set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+
+set(CMAKE_C_FLAGS   "-std=gnu99 -fdata-sections -ffunction-sections" CACHE INTERNAL "c compiler flags")
+set(CMAKE_CXX_FLAGS "-fdata-sections -ffunction-sections" CACHE INTERNAL "cxx compiler flags")
+set(CMAKE_ASM_FLAGS "" CACHE INTERNAL "asm compiler flags")
+if (APPLE)
+    set(CMAKE_EXE_LINKER_FLAGS "-dead_strip" CACHE INTERNAL "exe link flags")
+else (APPLE)
+    set(CMAKE_EXE_LINKER_FLAGS "-Wl,--gc-sections" CACHE INTERNAL "exe link flags")
+endif (APPLE)
+
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "c debug compiler flags")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb3" CACHE INTERNAL "cxx debug compiler flags")
+SET(CMAKE_ASM_FLAGS_DEBUG "-g -ggdb3" CACHE INTERNAL "asm debug compiler flags")
+
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -g -ggdb3" CACHE INTERNAL "c release compiler flags")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -g -ggdb3" CACHE INTERNAL "cxx release compiler flags")
+SET(CMAKE_ASM_FLAGS_RELEASE "" CACHE INTERNAL "asm release compiler flags")