Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Oct 28, 2022
0 parents commit e111551
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "Project_CTR"]
path = Project_CTR
url = https://github.com/3DSGuy/Project_CTR
[submodule "3dstool"]
path = 3dstool
url = https://github.com/dnasdw/3dstool.git
[submodule "bannertool"]
path = bannertool
url = https://github.com/deltabeard/bannertool.git
1 change: 1 addition & 0 deletions 3dstool
Submodule 3dstool added at 9c4336
67 changes: 67 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
SHIMS := $(shell pwd)/shims

ifneq ($(CMAKE_TOOLCHAIN_FILE),)
CROSS_PREFIX := $(shell grep -F 'set(cross_prefix ' $(CMAKE_TOOLCHAIN_FILE) | cut -d' ' -f2 | cut -d')' -f1)
CMAKE_CXX_FLAGS := -DCMAKE_CXX_FLAGS="-I$(SHIMS) -I$(shell grep -F 'set(toolchain_dir ' $(CMAKE_TOOLCHAIN_FILE) | cut -d' ' -f2 | cut -d')' -f1)/include"
CMAKE_EXE_LINKER_FLAGS := -DCMAKE_EXE_LINKER_FLAGS="-L$(shell grep -F 'set(toolchain_dir ' $(CMAKE_TOOLCHAIN_FILE) | cut -d' ' -f2 | cut -d')' -f1)/lib"
CC = $(CROSS_PREFIX)gcc
CXX = $(CROSS_PREFIX)g++
ifneq ($(findstring mingw,$(CROSS_PREFIX)),)
SUFFIX := .exe
ARCHFLAGS := -static-libgcc -static-libstdc++
ARCHFLAGS2 := -municode $(ARCHFLAGS)
CMAKE_CXX_STANDARD_LIBRARIES := -DCMAKE_CXX_STANDARD_LIBRARIES="-lz -lwldap32 -lws2_32 -lcrypt32 -lkernel32 -luser32"
EXTRA_TARGETS := bin/libwinpthread-1.dll
SYSDIR := $(shell grep -F 'set(CMAKE_PREFIX_PATH ${toolchain_dir}' $(CMAKE_TOOLCHAIN_FILE) | cut -d';' -f2 | cut -d')' -f1)
endif
CMAKE_EXTRA = && cmake . $(CMAKE_CXX_FLAGS) $(CMAKE_EXE_LINKER_FLAGS) $(CMAKE_CXX_STANDARD_LIBRARIES)
endif

STRIP = $(CROSS_PREFIX)strip
AR = $(CROSS_PREFIX)ar

all: 3dstool bannertool ctrtool makerom $(EXTRA_TARGETS)

.PHONY: 3dstool bannertool ctrltool makerom clean distclean cross

3dstool: bin/3dstool$(SUFFIX)
bannertool: bin/bannertool$(SUFFIX)
ctrtool: bin/ctrtool$(SUFFIX)
makerom: bin/makerom$(SUFFIX)

bin/bannertool$(SUFFIX):
$(MAKE) -C bannertool CC=$(CC) CXX=$(CXX) LDFLAGS="-static-libgcc -static-libstdc++"
install -Dm755 bannertool/bannertool.elf bin/bannertool$(SUFFIX)
$(STRIP) bin/bannertool$(SUFFIX)

bin/ctrtool$(SUFFIX):
ARCHFLAGS="$(ARCHFLAGS2)" CC=$(CC) CXX=$(CXX) INC=-I$(SHIMS) $(MAKE) -C Project_CTR/ctrtool deps PROJECT_PLATFORM=foo ARFLAGS=cr
ARCHFLAGS="$(ARCHFLAGS2)" CC=$(CC) CXX=$(CXX) INC=-I$(SHIMS) $(MAKE) -C Project_CTR/ctrtool PROJECT_PLATFORM=foo ARFLAGS=cr
install -Dm755 -t bin Project_CTR/ctrtool/bin/ctrtool$(SUFFIX)
$(STRIP) bin/ctrtool$(SUFFIX)

bin/makerom$(SUFFIX):
ARCHFLAGS="$(ARCHFLAGS)" CC=$(CC) CXX=$(CXX) INC=-I$(SHIMS) $(MAKE) -C Project_CTR/makerom deps PROJECT_PLATFORM=foo ARFLAGS=cr
ARCHFLAGS="$(ARCHFLAGS)" CC=$(CC) CXX=$(CXX) INC=-I$(SHIMS) $(MAKE) -C Project_CTR/makerom PROJECT_PLATFORM=foo ARFLAGS=cr
install -Dm755 -t bin Project_CTR/makerom/bin/makerom$(SUFFIX)
$(STRIP) bin/makerom$(SUFFIX)

bin/3dstool$(SUFFIX):
cd 3dstool && cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$(CMAKE_TOOLCHAIN_FILE) $(CMAKE_EXTRA)
cmake --build 3dstool
install -Dm755 -t bin 3dstool/bin/Release/3dstool$(SUFFIX)
$(STRIP) bin/3dstool$(SUFFIX)

bin/libwinpthread-1.dll:
mkdir bin
cp $(SYSDIR)/lib/libwinpthread-1.dll bin

clean:
rm -f bannertool/bannertool.elf
$(MAKE) -C Project_CTR/ctrtool clean clean_deps
$(MAKE) -C Project_CTR/makerom clean clean_deps
-cmake --build 3dstool --target clean
rm -rf bin

distclean: clean
git submodule foreach git clean -dfx
1 change: 1 addition & 0 deletions Project_CTR
Submodule Project_CTR added at 334f6f
1 change: 1 addition & 0 deletions bannertool
Submodule bannertool added at cc9fcb
1 change: 1 addition & 0 deletions shims/Windows.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include_next <windows.h>

0 comments on commit e111551

Please sign in to comment.