Created
February 16, 2022 14:15
-
-
Save ITotalJustice/7da53559ca02ef886032fb4694fc0cfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set(LIBDRAGON "/opt/libdragon") | |
| set(LIBDRAGON_LIBS "-ldragon -lc -lm -ldragonsys") # order matters | |
| SET(CMAKE_SYSTEM_NAME Generic) | |
| SET(CMAKE_SYSTEM_VERSION 1) | |
| SET(CMAKE_SYSTEM_PROCESSOR mips) | |
| SET(CMAKE_C_COMPILER ${LIBDRAGON}/bin/mips64-elf-gcc) | |
| SET(CMAKE_CXX_COMPILER ${LIBDRAGON}/bin/mips64-elf-g++) | |
| set(CMAKE_LINKER ${LIBDRAGON}/bin/mips64-elf-ld) | |
| set(CMAKE_AR ${LIBDRAGON}/bin/mips64-elf-ar) | |
| set(CMAKE_OBJCOPY ${LIBDRAGON}/bin/mips64-elf-objcopy) | |
| set(CMAKE_STRIP ${LIBDRAGON}/bin/mips64-elf-strip) | |
| set(CMAKE_ADDR2LINE ${LIBDRAGON}/bin/mips64-elf-addr2line) | |
| set(CMAKE_RANLIB ${LIBDRAGON}/bin/mips64-elf-ranlib) | |
| SET(CMAKE_C_FLAGS_INIT "-I${LIBDRAGON}/mips64-elf/include -O2 -march=vr4300 -mtune=vr4300") | |
| SET(CMAKE_CXX_FLAGS_INIT "-I${LIBDRAGON}/mips64-elf/include -O2 -march=vr4300 -mtune=vr4300") | |
| SET(CMAKE_EXE_LINKER_FLAGS_INIT "-L${LIBDRAGON}/lib -L${LIBDRAGON}/mips64-elf/lib") | |
| set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_LINKER} -o <TARGET> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> ${LIBDRAGON_LIBS} <LINK_LIBRARIES> -T${LIBDRAGON}/mips64-elf/lib/n64.ld") | |
| set(N64TOOL ${LIBDRAGON}/bin/n64tool) | |
| set(MKSPRITE ${LIBDRAGON}/bin/mksprite) | |
| set(MKDFS ${LIBDRAGON}/bin/chksum64) | |
| set(E64ROMCONFIG ${LIBDRAGON}/bin/ed64romconfig) | |
| set(DUMPDFS ${LIBDRAGON}/bin/dumpfs) | |
| set(CONVTOOL ${LIBDRAGON}/bin/convtool) | |
| set(CHKSUM64 ${LIBDRAGON}/bin/chksum64) | |
| set(AUDIOCONV64 ${LIBDRAGON}/bin/audioconv64) | |
| SET(CMAKE_EXECUTABLE_SUFFIX_C ".elf") | |
| SET(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf") | |
| SET(CMAKE_FIND_ROOT_PATH ${LIBDRAGON} ${LIBDRAGON}/mips64-elf) | |
| SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | |
| SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | |
| SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | |
| add_definitions("-DN64 -D__N64__") | |
| SET(PLATFORM_N64 TRUE) | |
| SET(N64 TRUE) | |
| function(n64_create_z64 target name) | |
| cmake_parse_arguments(Z64 "" "NAME;HEADER;SIZE" "" ${ARGN}) | |
| if (NOT DEFINED Z64_NAME) | |
| set(Z64_NAME -t ${Z64_NAME}) | |
| else() | |
| set(Z64_NAME -t ${target}) | |
| endif() | |
| if (DEFINED Z64_HEADER) | |
| set(Z64_HEADER -h ${Z64_HEADER}) | |
| else() | |
| set(Z64_HEADER -h ${LIBDRAGON}/mips64-elf/lib/header) | |
| endif() | |
| if (DEFINED Z64_SIZE) | |
| set(Z64_SIZE -l ${Z64_SIZE}) | |
| endif() | |
| add_custom_command(OUTPUT ${target}.z64 | |
| COMMAND ${CMAKE_OBJCOPY} ${target}.elf ${target}.bin -O binary | |
| COMMAND ${N64TOOL} -t ${Z64_NAME} -h ${LIBDRAGON}/mips64-elf/lib/header ${Z64_SIZE} -o ${target}.z64 ${target}.bin | |
| COMMAND rm ${target}.bin | |
| COMMAND ${CHKSUM64} ${target}.z64 | |
| DEPENDS ${target} | |
| ) | |
| add_custom_target(TARGET-${target}.z64 ALL DEPENDS ${target}.z64) | |
| endfunction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment