From 4ae36b70fbb5ba2cc819df35aa6472aaaa9e1525 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Tue, 1 Sep 2015 00:04:20 +0200 Subject: [PATCH] startup code & cmake stuff for ppc --- CMakeLists.txt | 4 ++++ Samples/Dialog/CMakeLists.txt | 3 +++ TestApps/CMakeLists.txt | 3 ++- cmake/add_application.cmake | 45 +++++++++++++++++++++++++---------- libretro/CMakeLists.txt | 2 +- libretro/RetroPPCcfrg.r | 9 +++++++ libretro/ppcstart.c | 39 ++++++++++++++++++++++++++++++ 7 files changed, 91 insertions(+), 14 deletions(-) create mode 100755 libretro/RetroPPCcfrg.r create mode 100644 libretro/ppcstart.c diff --git a/CMakeLists.txt b/CMakeLists.txt index f426ca7e4b..3a9b5e8e65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR}/libretro) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libretro) set(REZ_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libretro:${CMAKE_INSTALL_PREFIX}/RIncludes" ) +if(CMAKE_SYSTEM_NAME MATCHES Retro68) add_subdirectory(Console) add_subdirectory(TestApps) add_subdirectory(Samples/HelloWorld) @@ -42,6 +43,9 @@ add_subdirectory(Samples/Raytracer) add_subdirectory(Samples/Launcher) add_subdirectory(Samples/Dialog) add_subdirectory(Samples/SystemExtension) +else() +add_subdirectory(Samples/Dialog) +endif() else() diff --git a/Samples/Dialog/CMakeLists.txt b/Samples/Dialog/CMakeLists.txt index beb1e50e62..efacce94a7 100644 --- a/Samples/Dialog/CMakeLists.txt +++ b/Samples/Dialog/CMakeLists.txt @@ -27,3 +27,6 @@ add_application(Dialog dialog.c dialog.r ) +if(CMAKE_SYSTEM_NAME MATCHES RetroPPC) +target_link_libraries(Dialog InterfaceLib) +endif() diff --git a/TestApps/CMakeLists.txt b/TestApps/CMakeLists.txt index 2df5585077..95bcab6631 100644 --- a/TestApps/CMakeLists.txt +++ b/TestApps/CMakeLists.txt @@ -22,7 +22,8 @@ add_application(ExceptionTest CONSOLE ExceptionTest.cc) add_application(InitTest CONSOLE InitTest.cc) add_application(EmptyTest EmptyTest.c) +if(CMAKE_SYSTEM_NAME MATCHES Retro68) enable_language(ASM) add_application(AsmTest AsmTest.s) set_target_properties(AsmTest PROPERTIES LINKER_LANGUAGE C) - +endif() diff --git a/cmake/add_application.cmake b/cmake/add_application.cmake index f69bc53d47..986bb2f9c3 100644 --- a/cmake/add_application.cmake +++ b/cmake/add_application.cmake @@ -61,19 +61,40 @@ function(add_application name) set_target_properties(${name} PROPERTIES LINK_DEPENDS libretro) endif(TARGET libretro) - set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name}.flt) + if(CMAKE_SYSTEM_NAME MATCHES Retro68) + + set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name}.flt) + + add_custom_command( + OUTPUT ${name}.bin ${name}.APPL ${name}.dsk + COMMAND ${REZ} ${REZ_TEMPLATES_PATH}/Retro68APPL.r + -I${REZ_INCLUDE_PATH} + -DFLT_FILE_NAME="\\"${name}.flt\\"" + -o "${name}.bin" --cc "${name}.dsk" --cc "${name}.APPL" + -t ${ARGS_TYPE} -c ${ARGS_CREATOR} + ${ARGS_MAKEAPPL_ARGS} + DEPENDS ${name} ${rsrc_files}) + add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin) + + elseif(CMAKE_SYSTEM_NAME MATCHES RetroPPC) + set_target_properties(${name} PROPERTIES OUTPUT_NAME ${name}.xcoff) + add_custom_command( + OUTPUT ${name}.pef + COMMAND ${MAKE_PEF} "${name}.xcoff" -o "${name}.pef" + DEPENDS ${name}) + + add_custom_command( + OUTPUT ${name}.bin ${name}.APPL ${name}.dsk + COMMAND ${REZ} ${REZ_TEMPLATES_PATH}/RetroPPCcfrg.r + -I${REZ_INCLUDE_PATH} + -o "${name}.bin" --cc "${name}.dsk" --cc "${name}.APPL" + -t ${ARGS_TYPE} -c ${ARGS_CREATOR} + --data ${name}.pef + ${ARGS_MAKEAPPL_ARGS} + DEPENDS ${name}.pef ${rsrc_files}) + add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin) + endif() - add_custom_command( - OUTPUT ${name}.bin ${name}.APPL ${name}.dsk - #COMMAND ${MAKE_APPL} ${ARGS_MAKEAPPL_ARGS} -c "${name}.flt" -o "${name}" - COMMAND ${REZ} ${REZ_TEMPLATES_PATH}/Retro68APPL.r - -I${REZ_INCLUDE_PATH} - -DFLT_FILE_NAME="\\"${name}.flt\\"" - -o "${name}.bin" --cc "${name}.dsk" --cc "${name}.APPL" - -t ${ARGS_TYPE} -c ${ARGS_CREATOR} - ${ARGS_MAKEAPPL_ARGS} - DEPENDS ${name} ${rsrc_files}) - add_custom_target(${name}_APPL ALL DEPENDS ${name}.bin) endfunction() cmake_policy(POP) diff --git a/libretro/CMakeLists.txt b/libretro/CMakeLists.txt index b2a619bae3..9d07cad46a 100644 --- a/libretro/CMakeLists.txt +++ b/libretro/CMakeLists.txt @@ -35,7 +35,7 @@ if(CMAKE_SYSTEM_NAME MATCHES Retro68) install(FILES Retro68Runtime.h DESTINATION include) install(FILES Retro68.r Retro68APPL.r DESTINATION RIncludes) else() - set(ARCH_FILES) + set(ARCH_FILES ppcstart.c) endif() add_library(retrocrt diff --git a/libretro/RetroPPCcfrg.r b/libretro/RetroPPCcfrg.r new file mode 100755 index 0000000000..70f13bf604 --- /dev/null +++ b/libretro/RetroPPCcfrg.r @@ -0,0 +1,9 @@ +data 'cfrg' (0) { + $"0000 0000 0000 0000 0000 0001 0000 0000" /* ................ */ + $"0000 0000 0000 0000 0000 0000 0000 0001" /* ................ */ + $"7077 7063 0000 0000 0000 0000 0000 0000" /* pwpc............ */ + $"0000 0000 0000 0101 0000 0000 0000 0000" /* ................ */ + $"0000 0000 0000 0000 0038 0366 6F6F 0000" /* .........8.foo.. */ +}; + + diff --git a/libretro/ppcstart.c b/libretro/ppcstart.c new file mode 100644 index 0000000000..4adead8fab --- /dev/null +++ b/libretro/ppcstart.c @@ -0,0 +1,39 @@ +/* + Copyright 2015 Wolfgang Thaller. + + This file is part of Retro68. + + Retro68 is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Retro68 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING and COPYING.RUNTIME respectively. If not, see + . +*/ + +#include +#include + +int main(int argc, char* argv[]); + +void __start() +{ + int result; + { + char *argv[2] = { "./a.out", NULL }; + result = main(1, argv); + } + exit(result); +}