Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 4.02 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.14.0)
  2. project(Emu68 VERSION 0.1.0)
  3.  
  4. include(cmake/verstring.cmake)
  5. include(cmake/firmware_download.cmake)
  6. get_verstring(VERSTRING)
  7.  
  8. set(CMAKE_CXX_STANDARD 11)
  9. set(CMAKE_C_STANDARD 11)
  10.  
  11. set(CMAKE_INSTALL_PREFIX "")
  12. set(SUPPORTED_TARGETS "raspi" "raspi64" "pbpro" "rockpro64")
  13. set(TARGET "raspi64" CACHE STRING "One of target machines: ${SUPPORTED_TARGETS}")
  14.  
  15. set(ARCH_FILES "")
  16. set(TARGET_FILES "")
  17. set(BASE_FILES
  18.     src/support.c
  19.     src/tlsf.c
  20.     src/devicetree.c
  21.     src/cpp_support.cpp
  22.     src/EmuLogo.c
  23.     src/HunkLoader.c
  24. )
  25. set(EMU_FILES
  26.     src/M68k_Translator.c
  27.     src/M68k_SR.c
  28.     src/M68k_MULDIV.c
  29.     src/M68k_MOVE.c
  30.     src/M68k_EA.c
  31.     src/M68k_LINE0.c
  32.     src/M68k_LINE4.c
  33.     src/M68k_LINE5.c
  34.     src/M68k_LINE6.c
  35.     src/M68k_LINE8.c
  36.     src/M68k_LINE9.c
  37.     src/M68k_LINEB.c
  38.     src/M68k_LINEC.c
  39.     src/M68k_LINED.c
  40.     src/M68k_LINEE.c
  41.     src/M68k_LINEF.c
  42. )
  43.  
  44. add_subdirectory(external/tiny-stl)
  45.  
  46. if (${TARGET} IN_LIST SUPPORTED_TARGETS)
  47.     message("-- Selected target machine: ${TARGET}")
  48.     if(${TARGET} STREQUAL "raspi64" OR ${TARGET} STREQUAL "raspi")
  49.         if (${TARGET} STREQUAL "raspi64")
  50.             list(APPEND TARGET_FILES
  51.                 src/raspi/start_rpi64.c
  52.             )
  53.         else()
  54.             list(APPEND TARGET_FILES
  55.                 src/raspi/start_rpi.c
  56.             )
  57.         endif()
  58.         list(APPEND TARGET_FILES
  59.             src/raspi/support_rpi.c
  60.         )
  61.         download_raspi_firmware()
  62.         install(DIRECTORY ${CMAKE_BINARY_DIR}/firmware/ DESTINATION .)
  63.         install(FILES ${CMAKE_BINARY_DIR}/Emu68.img DESTINATION .)
  64.         install(FILES ${CMAKE_SOURCE_DIR}/scripts/config.txt DESTINATION .)
  65.     elseif(${TARGET} STREQUAL "pbpro")
  66.         list(APPEND TARGET_FILES
  67.             src/pine64/start_pbpro.c
  68.             src/pine64/support_pbpro.c
  69.         )
  70.         install(FILES ${CMAKE_SOURCE_DIR}/blobs/rk3399-pinebookpro.dtb DESTINATION .)
  71.         install(FILES ${CMAKE_BINARY_DIR}/Emu68.img DESTINATION .)
  72.         install(FILES ${CMAKE_SOURCE_DIR}/scripts/extlinux.conf DESTINATION extlinux/)
  73.     endif()
  74.  
  75.     if (${TARGET} STREQUAL "raspi")
  76.         set(TARGET_ARCH "armhf")
  77.     else()
  78.         set(TARGET_ARCH "aarch64")
  79.     endif()
  80. else()
  81.     message(FATAL_ERROR "Wrong target machine specified: ${TARGET}")
  82. endif()
  83.  
  84. if(${TARGET_ARCH} STREQUAL "armhf")
  85.     list(APPEND ARCH_FILES
  86.         src/armhf/start.c
  87.         src/armhf/RegisterAllocator.c
  88.     )
  89.     set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/scripts/ldscript-be.lds)
  90.     set(CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id -Wl,--be8 -Wl,--format=elf32-bigarm -nostdlib -nostartfiles -static -T ${LINKER_SCRIPT}")
  91.     add_compile_options(-mbig-endian -mcpu=cortex-a7 -mfpu=neon-vfpv4 -O3 -pedantic -pedantic-errors -ffixed-r11 -fomit-frame-pointer -Wall -Wextra -Werror)
  92. else()
  93.     list(APPEND ARCH_FILES
  94.             src/aarch64/start.c
  95.             src/aarch64/mmu.c
  96.             src/aarch64/RegisterAllocator64.c
  97.     )
  98.     set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/scripts/ldscript-be64.lds)
  99.     set(CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id -Wl,-EB -Wl,--format=elf64-bigaarch64 -nostdlib -nostartfiles -static -T ${LINKER_SCRIPT}")
  100.     add_compile_options(-mbig-endian -O3 -pedantic -pedantic-errors -ffixed-x19 -ffixed-x20 -ffixed-x21 -ffixed-x22 -ffixed-x23 -ffixed-x24 -ffixed-x25 -ffixed-x26 -ffixed-x27 -ffixed-x28 -ffixed-x29 -ffixed-x13 -ffixed-x14 -ffixed-x15 -ffixed-x16 -ffixed-x17 -ffixed-x18 -fomit-frame-pointer -Wall -Wextra -Werror)
  101. endif()
  102.  
  103. add_executable(Emu68.elf
  104.     ${ARCH_FILES}
  105.     ${TARGET_FILES}
  106.     ${BASE_FILES}
  107.     ${EMU_FILES}
  108. )
  109.  
  110. add_custom_command(
  111.     TARGET Emu68.elf POST_BUILD
  112.     COMMAND ${CMAKE_OBJCOPY} -v -O binary "${CMAKE_BINARY_DIR}/Emu68.elf" "${CMAKE_BINARY_DIR}/Emu68.img"
  113.     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  114. )
  115.  
  116. target_link_libraries(Emu68.elf tinystl)
  117. target_include_directories(Emu68.elf PRIVATE ${CMAKE_SOURCE_DIR}/include)
  118. target_compile_definitions(Emu68.elf PRIVATE VERSION_STRING="${VERSTRING}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement