Convert to CMake

This commit is contained in:
Michael Theall 2023-03-11 20:28:23 -06:00
parent fec8332df6
commit 6f5ccc3793
25 changed files with 399 additions and 1087 deletions

304
CMakeLists.txt Normal file
View File

@ -0,0 +1,304 @@
cmake_minimum_required(VERSION 3.12)
project(ftpd VERSION 3.2.0)
option(FTPD_CLASSIC "Build ${PROJECT_NAME} classic" OFF)
if(FTPD_CLASSIC AND (NINTENDO_SWITCH OR NINTENDO_3DS))
set(FTPD_TARGET "${PROJECT_NAME}-classic")
else()
set(FTPD_TARGET "${PROJECT_NAME}")
endif()
add_executable(${FTPD_TARGET})
target_compile_features(${FTPD_TARGET} PRIVATE cxx_std_20)
target_include_directories(${FTPD_TARGET} PRIVATE include)
target_compile_definitions(${FTPD_TARGET} PRIVATE
STATUS_STRING="${PROJECT_NAME} v${PROJECT_VERSION}"
)
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED)
set_target_properties(${FTPD_TARGET} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION FALSE
INTERPROCEDURAL_OPTIMIZATION_DEBUG FALSE
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE
INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE
)
endif()
if(FTPD_CLASSIC OR NINTENDO_DS)
target_compile_definitions(${FTPD_TARGET} PRIVATE CLASSIC)
endif()
if(NINTENDO_SWITCH OR NINTENDO_3DS OR NINTENDO_DS)
target_compile_definitions(${FTPD_TARGET} PRIVATE
NO_IPV6
FTPDCONFIG="/config/${PROJECT_NAME}/${PROJECT_NAME}.cfg"
)
endif()
target_sources(${FTPD_TARGET} PRIVATE
include/fs.h
include/ftpConfig.h
include/ftpServer.h
include/ftpSession.h
include/ioBuffer.h
include/log.h
include/platform.h
include/sockAddr.h
include/socket.h
source/fs.cpp
source/ftpConfig.cpp
source/ftpServer.cpp
source/ftpSession.cpp
source/ioBuffer.cpp
source/log.cpp
source/main.cpp
source/sockAddr.cpp
source/socket.cpp
)
if(NOT FTPD_CLASSIC AND NOT NINTENDO_DS)
target_sources(${FTPD_TARGET} PRIVATE
include/imconfig.h
include/imgui.h
include/licenses.h
source/imgui/imgui.cpp
source/imgui/imgui_draw.cpp
source/imgui/imgui_internal.h
source/imgui/imgui_tables.cpp
source/imgui/imgui_widgets.cpp
source/imgui/imstb_rectpack.h
source/imgui/imstb_textedit.h
source/imgui/imstb_truetype.h
source/licenses.cpp
)
endif()
if(NINTENDO_SWITCH)
target_sources(${FTPD_TARGET} PRIVATE
source/switch/init.c
source/switch/platform.cpp
)
if(FTPD_CLASSIC)
nx_generate_nacp(${FTPD_TARGET}.nacp
NAME "${PROJECT_NAME} classic"
AUTHOR "(c) 2023 Michael Theall, Dave Murphy, TuxSH"
VERSION ${PROJECT_VERSION}
)
nx_create_nro(${FTPD_TARGET}
NACP ${FTPD_TARGET}.nacp
ICON meta/${PROJECT_NAME}.jpg
)
return()
endif()
include(FindPkgConfig)
pkg_check_modules(CURL libcurl IMPORTED_TARGET)
pkg_check_modules(ZSTD libzstd IMPORTED_TARGET)
target_link_libraries(${FTPD_TARGET} PRIVATE
deko3d$<$<CONFIG:Debug>:d>
PkgConfig::CURL
PkgConfig::ZSTD
)
target_sources(${FTPD_TARGET} PRIVATE
source/switch/imgui_deko3d.cpp
source/switch/imgui_deko3d.h
source/switch/imgui_nx.cpp
source/switch/imgui_nx.h
)
dkp_add_asset_target(${PROJECT_NAME}_romfs ${CMAKE_CURRENT_BINARY_DIR}/romfs)
nx_add_shader_program(imgui_fsh source/switch/imgui_fsh.glsl frag)
nx_add_shader_program(imgui_vsh source/switch/imgui_vsh.glsl vert)
foreach(PNG
airplane_icon.png
battery_icon.png
charging_icon.png
eth_icon.png
eth_none_icon.png
wifi1_icon.png
wifi2_icon.png
wifi3_icon.png
wifi_none_icon.png)
string(REGEX REPLACE "[.]png$" ".rgba" RGBA ${PNG})
string(REGEX REPLACE "[.]png$" ".rgba.zst" ZST ${PNG})
add_custom_command(OUTPUT ${ZST}
COMMAND
convert ${CMAKE_CURRENT_SOURCE_DIR}/switch/gfx/${PNG} ${RGBA}
COMMAND
zstd -f ${RGBA} -o ${ZST} --ultra -22
MAIN_DEPENDENCY
switch/gfx/${PNG}
BYPRODUCTS
${RGBA}
)
add_custom_target(${ZST}_target DEPENDS ${ZST})
dkp_set_target_file(${ZST}_target ${ZST})
dkp_install_assets(${PROJECT_NAME}_romfs TARGETS ${ZST}_target)
endforeach()
foreach(ASTC deko3d.12x12.astc)
string(REGEX REPLACE "[.]astc$" ".astc.zst" ZST ${ASTC})
add_custom_command(OUTPUT ${ZST}
COMMAND
zstd -f ${CMAKE_CURRENT_SOURCE_DIR}/switch/gfx/${ASTC} -o ${ZST} --ultra -22
MAIN_DEPENDENCY
switch/gfx/${ASTC}
)
add_custom_target(${ZST}_target DEPENDS ${ZST})
dkp_set_target_file(${ZST}_target ${ZST})
dkp_install_assets(${PROJECT_NAME}_romfs TARGETS ${ZST}_target)
endforeach()
dkp_install_assets(${PROJECT_NAME}_romfs
DESTINATION
shaders
TARGETS
imgui_fsh
imgui_vsh
)
nx_generate_nacp(${FTPD_TARGET}.nacp
NAME "${PROJECT_NAME} pro"
AUTHOR "(c) 2023 Michael Theall, Dave Murphy, TuxSH"
VERSION ${PROJECT_VERSION}
)
nx_create_nro(${FTPD_TARGET}
NACP ${FTPD_TARGET}.nacp
ICON meta/${PROJECT_NAME}.jpg
ROMFS ${PROJECT_NAME}_romfs
)
elseif(NINTENDO_3DS)
target_sources(${FTPD_TARGET} PRIVATE
source/3ds/platform.cpp
)
if(FTPD_CLASSIC)
ctr_generate_smdh(${FTPD_TARGET}.smdh
NAME "${PROJECT_NAME} classic"
DESCRIPTION "v${PROJECT_VERSION}"
AUTHOR "(c) 2023 Michael Theall, Dave Murphy, TuxSH"
ICON meta/icon.png
)
ctr_create_3dsx(${FTPD_TARGET}
SMDH ${FTPD_TARGET}.smdh
)
return()
endif()
target_compile_definitions(${FTPD_TARGET} PRIVATE
ANTI_ALIAS=1
)
include(FindPkgConfig)
pkg_check_modules(CURL libcurl IMPORTED_TARGET)
target_link_libraries(${FTPD_TARGET} PRIVATE
citro3d$<$<CONFIG:Debug>:d>
PkgConfig::CURL
)
target_sources(${FTPD_TARGET} PRIVATE
source/3ds/imgui_citro3d.cpp
source/3ds/imgui_citro3d.h
source/3ds/imgui_ctru.cpp
source/3ds/imgui_ctru.h
)
ctr_add_shader_library(vshader source/3ds/vshader.v.pica)
dkp_add_embedded_binary_library(vshader_data vshader)
target_link_libraries(${FTPD_TARGET} PRIVATE vshader_data)
dkp_add_asset_target(${PROJECT_NAME}_romfs ${CMAKE_CURRENT_BINARY_DIR}/romfs)
add_custom_target(ca_cert DEPENDS 3ds/romfs/sni.cloudflaressl.com.ca)
dkp_set_target_file(ca_cert ${CMAKE_CURRENT_SOURCE_DIR}/3ds/romfs/sni.cloudflaressl.com.ca)
dkp_install_assets(${PROJECT_NAME}_romfs TARGETS ca_cert)
ctr_add_graphics_target(gfx ATLAS
OPTIONS
-f rgba -z auto -H gfx.h
INPUTS
3ds/gfx/battery0.png
3ds/gfx/battery1.png
3ds/gfx/battery2.png
3ds/gfx/battery3.png
3ds/gfx/battery4.png
3ds/gfx/batteryCharge.png
3ds/gfx/c3dlogo.png
3ds/gfx/wifi1.png
3ds/gfx/wifi2.png
3ds/gfx/wifi3.png
3ds/gfx/wifiNull.png
)
target_include_directories(${FTPD_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
dkp_install_assets(${PROJECT_NAME}_romfs
TARGETS
gfx
)
ctr_generate_smdh(${FTPD_TARGET}.smdh
NAME "${PROJECT_NAME} pro"
DESCRIPTION "v${PROJECT_VERSION}"
AUTHOR "(c) 2023 Michael Theall, Dave Murphy, TuxSH"
ICON meta/icon.png
)
ctr_create_3dsx(${FTPD_TARGET}
SMDH ${FTPD_TARGET}.smdh
ROMFS ${PROJECT_NAME}_romfs
)
elseif(NINTENDO_DS)
target_link_libraries(${FTPD_TARGET} PRIVATE
dswifi9
fat
)
target_sources(${FTPD_TARGET} PRIVATE
source/nds/platform.cpp
)
nds_create_rom(${FTPD_TARGET}
NAME "${PROJECT_NAME} classic"
SUBTITLE1 "v${PROJECT_VERSION}"
SUBTITLE2 "(c) 2023 mtheall"
ICON nds/icon.bmp
)
else()
find_package(glfw3 REQUIRED)
find_package(CURL REQUIRED)
find_package(OpenGL REQUIRED)
target_link_libraries(${FTPD_TARGET} PRIVATE CURL::libcurl glfw OpenGL::GL)
target_compile_definitions(${FTPD_TARGET} PRIVATE
FTPDCONFIG="${PROJECT_NAME}.cfg"
)
target_sources(${FTPD_TARGET} PRIVATE
source/linux/imgui_impl_glfw.cpp
source/linux/imgui_impl_glfw.h
source/linux/imgui_impl_opengl3.cpp
source/linux/imgui_impl_opengl3.h
source/linux/imgui_impl_opengl3_loader.h
source/linux/platform.cpp
)
endif()

129
Makefile
View File

@ -1,129 +0,0 @@
.PHONY: all all-classic format clean
.PHONY: dslink 3dslink 3dslink-classic nxlink-classic
.PHONY: nds 3dsx cia nro linux
.PHONY: 3dsx-classic cia-classic nro-classic
.PHONY: release release-nds release-3dsx release-cia release-nro
.PHONY: release-3dsx-classic release-cia-classic release-nro-classic
export GITREV := $(shell git rev-parse HEAD 2>/dev/null | cut -c1-6)
export VERSION_MAJOR := 3
export VERSION_MINOR := 1
export VERSION_MICRO := 0
export VERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)
###########################################################################
all: nds 3dsx nro linux
all-classic: nds 3dsx-classic nro-classic linux
format:
@clang-format -style=file -i $(filter-out \
include/imconfig.h \
include/imgui.h \
source/imgui/imgui.cpp \
source/imgui/imgui_draw.cpp \
source/imgui/imgui_internal.h \
source/imgui/imgui_tables.cpp \
source/imgui/imgui_widgets.cpp \
source/imgui/imstb_rectpack.h \
source/imgui/imstb_textedit.h \
source/imgui/imstb_truetype.h \
source/linux/imgui_impl_glfw.cpp \
source/linux/imgui_impl_glfw.h \
source/linux/imgui_impl_opengl3.cpp \
source/linux/imgui_impl_opengl3.h \
source/linux/imgui_impl_opengl3_loader.h \
, $(shell find source include -type f -name \*.c -o -name \*.cpp -o -name \*.h))
clean:
@$(MAKE) -f Makefile.nds clean
@$(MAKE) -f Makefile.3ds clean
@$(MAKE) -f Makefile.3ds clean CLASSIC="-DCLASSIC"
@$(MAKE) -f Makefile.switch clean
@$(MAKE) -f Makefile.switch clean CLASSIC="-DCLASSIC"
@$(MAKE) -f Makefile.linux clean
@$(RM) ftpd.nds.xz ftpd*.3dsx.xz ftpd*.cia.xz ftpd*.nro.xz
###########################################################################
dslink:
@$(MAKE) -f Makefile.nds dslink
3dslink:
@$(MAKE) -f Makefile.3ds 3dslink
3dslink-classic:
@$(MAKE) -f Makefile.3ds 3dslink CLASSIC="-DCLASSIC"
nxlink:
@$(MAKE) -f Makefile.switch nxlink
nxlink-classic:
@$(MAKE) -f Makefile.switch nxlink CLASSIC="-DCLASSIC"
###########################################################################
nds:
@$(MAKE) -f Makefile.nds CLASSIC="-DCLASSIC"
3dsx:
@$(MAKE) -f Makefile.3ds 3dsx
3dsx-classic:
@$(MAKE) -f Makefile.3ds 3dsx CLASSIC="-DCLASSIC"
cia: 3dsx
@$(MAKE) -f Makefile.3ds cia
cia-classic: 3dsx-classic
@$(MAKE) -f Makefile.3ds cia CLASSIC="-DCLASSIC"
nro:
@$(MAKE) -f Makefile.switch all
nro-classic:
@$(MAKE) -f Makefile.switch all CLASSIC="-DCLASSIC"
linux:
@$(MAKE) -f Makefile.linux
###########################################################################
release: release-nds \
release-3dsx release-3dsx-classic \
release-cia release-cia-classic \
release-nro release-nro-classic
@$(RM) -r release
@mkdir release
@xz -c <nds/ftpd.nds >release/ftpd.nds.xz
@ln -s ../nds/ftpd.nds release/ftpd.nds
@xz -c <3ds/ftpd.3dsx >release/ftpd.3dsx.xz
@ln -s ../3ds/ftpd.3dsx release/ftpd.3dsx
@xz -c <3ds-classic/ftpd-classic.3dsx >release/ftpd-classic.3dsx.xz
@ln -s ../3ds-classic/ftpd-classic.3dsx release/ftpd-classic.3dsx
@xz -c <3ds/ftpd.cia >release/ftpd.cia.xz
@ln -s ../3ds/ftpd.cia release/ftpd.cia
@xz -c <3ds-classic/ftpd-classic.cia >release/ftpd-classic.cia.xz
@ln -s ../3ds-classic/ftpd-classic.cia release/ftpd-classic.cia
@xz -c <switch/ftpd.nro >release/ftpd.nro.xz
@ln -s ../switch/ftpd.nro release/ftpd.nro
@xz -c <switch-classic/ftpd-classic.nro >release/ftpd-classic.nro.xz
@ln -s ../switch-classic/ftpd-classic.nro release/ftpd-classic.nro
release-nds:
@$(MAKE) -f Makefile.nds DEFINES=-DNDEBUG OPTIMIZE="-O3 -flto"
release-3dsx:
@$(MAKE) -f Makefile.3ds 3dsx DEFINES=-DNDEBUG OPTIMIZE="-O3 -flto"
release-3dsx-classic:
@$(MAKE) -f Makefile.3ds 3dsx DEFINES=-DNDEBUG OPTIMIZE="-O3 -flto" CLASSIC="-DCLASSIC"
release-cia: release-3dsx
@$(MAKE) -f Makefile.3ds cia DEFINES=-DNDEBUG OPTIMIZE="-O3 -flto"
release-cia-classic: release-3dsx-classic
@$(MAKE) -f Makefile.3ds cia DEFINES=-DNDEBUG OPTIMIZE="-O3 -flto" CLASSIC="-DCLASSIC"
release-nro:
@$(MAKE) -f Makefile.switch all DEFINES=-DNDEBUG OPTIMIZE="-O3 -flto"
release-nro-classic:
@$(MAKE) -f Makefile.switch all DEFINES=-DNDEBUG OPTIMIZE="-O3 -flto" CLASSIC="-DCLASSIC"

View File

@ -1,316 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# GRAPHICS is a list of directories containing graphics files
# GFXBUILD is the directory where converted graphics files will be placed
# If set to $(BUILD), it will statically link in the converted
# files as if they were data files.
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
SOURCES := source source/3ds
DATA := data
INCLUDES := include
ifeq ($(strip $(CLASSIC)),)
APP_TITLE := ftpd pro
TARGET := 3ds/ftpd
BUILD := 3ds/build
SOURCES += source/imgui
GRAPHICS := 3ds/gfx
ROMFS := 3ds/romfs
GFXBUILD := $(ROMFS)
RSF_FILE := meta/ftpd-cia.rsf
else
APP_TITLE := ftpd classic
TARGET := 3ds-classic/ftpd-classic
BUILD := 3ds-classic/build
RSF_FILE := meta/ftpd-classic-cia.rsf
endif
APP_DESCRIPTION := v$(VERSION)
APP_AUTHOR := (c) 2023 Michael Theall, Dave Murphy, TuxSH
ICON := meta/icon.png
BNR_IMAGE := meta/banner.png
BNR_AUDIO := meta/audio.wav
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
OPTIMIZE := -Og
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall $(OPTIMIZE) -mword-relocations \
-fomit-frame-pointer -ffunction-sections -fdata-sections \
$(ARCH) $(DEFINES) $(CLASSIC)
CFLAGS += $(INCLUDE) -DARM11 -D__3DS__ \
-DSTATUS_STRING="\"ftpd v$(VERSION)\"" \
-DNO_IPV6 -DFTPDCONFIG="\"/config/ftpd/ftpd.cfg\"" \
-DANTI_ALIAS=1 \
`curl-config --cflags`
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++2a
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) $(OPTIMIZE)
CC := `which ccache 2>/dev/null` $(CC)
CXX := `which ccache 2>/dev/null` $(CXX)
LIBS := `curl-config --libs` -lcitro3d -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(TOPDIR)/$(BUILD),$(CURDIR))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
ifeq ($(strip $(CLASSIC)),)
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
endif
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
export LD := $(CXX)
endif
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
ifeq ($(GFXBUILD),$(BUILD))
#---------------------------------------------------------------------------------
export T3XFILES := $(GFXFILES:.t3s=.t3x)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export ROMFS_T3XFILES := $(patsubst %.t3s,$(GFXBUILD)/%.t3x,$(GFXFILES))
export T3XHFILES := $(patsubst %.t3s,$(BUILD)/%.h,$(GFXFILES))
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o) \
$(addsuffix .o,$(T3XFILES))
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
$(addsuffix .h,$(subst .,_,$(BINFILES))) \
$(GFXFILES:.t3s=.h)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
endif
.PHONY: $(BUILD) clean all 3dsx cia 3dslink
#---------------------------------------------------------------------------------
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.3ds
$(BUILD):
@mkdir -p $@
ifneq ($(GFXBUILD),$(BUILD))
$(GFXBUILD):
@mkdir -p $@
endif
ifneq ($(DEPSDIR),$(BUILD))
$(DEPSDIR):
mkdir -p $@
endif
#---------------------------------------------------------------------------------
$(GFXBUILD)/%.t3x $(BUILD)/%.h: %.t3s
#---------------------------------------------------------------------------------
@echo $(notdir $<)
tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
3dsx: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.3ds 3dsx
cia: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.3ds cia
3dslink: 3dsx
@3dslink $(OUTPUT).3dsx
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@$(RM) -r $(BUILD) \
$(TARGET).3dsx \
$(OUTPUT).smdh \
$(TARGET).elf \
$(TARGET).cia \
$(ROMFS_T3XFILES) \
output/
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
all: $(OUTPUT).cia $(OUTPUT).3dsx
3dsx: $(OUTPUT).3dsx
cia: $(OUTPUT).cia
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all: $(OUTPUT).3dsx $(OUTPUT).smdh
$(OUTPUT).smdh: $(TOPDIR)/Makefile $(TOPDIR)/Makefile.3ds
$(OUTPUT).3dsx: $(OUTPUT).smdh
endif
$(OUTPUT).3dsx: $(OUTPUT).elf $(_3DSXDEPS)
$(OFILES_SOURCES): $(HFILES)
$(OUTPUT).elf: $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h: %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
$(OFILES): $(TOPDIR)/Makefile $(TOPDIR)/Makefile.3ds
#---------------------------------------------------------------------------------
.PRECIOUS: %.t3x
#---------------------------------------------------------------------------------
%.t3x.o %_t3x.h: %.t3x
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $*.shbin)
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
endef
%.shbin.o %_shbin.h : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o %_shbin.h : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o %_shbin.h : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
$(OUTPUT).cia: $(OUTPUT).elf $(OUTPUT).smdh $(TARGET).bnr $(TOPDIR)/$(RSF_FILE)
@makerom -f cia -target t -exefslogo -o $@ \
-elf $(OUTPUT).elf -rsf $(TOPDIR)/$(RSF_FILE) \
-ver "$$(($(VERSION_MAJOR)*1024+$(VERSION_MINOR)*16+$(VERSION_MICRO)))" \
-banner $(TARGET).bnr \
-icon $(OUTPUT).smdh
@echo "built ... $(notdir $@)"
$(TARGET).bnr: $(TOPDIR)/$(BNR_IMAGE) $(TOPDIR)/$(BNR_AUDIO)
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
@bannertool makebanner -o $@ -i $(TOPDIR)/$(BNR_IMAGE) -a $(TOPDIR)/$(BNR_AUDIO)
@echo "built ... $@"
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,37 +0,0 @@
TARGET := linux/ftpd
BUILD := linux/build
CFILES := $(wildcard source/linux/*.c)
CXXFILES := $(wildcard source/*.cpp source/imgui/*.cpp source/linux/*.cpp)
OFILES := $(patsubst source/%,$(BUILD)/%,$(CFILES:.c=.c.o))
OXXFILES := $(patsubst source/%,$(BUILD)/%,$(CXXFILES:.cpp=.cpp.o))
CPPFLAGS := -g -Wall -pthread -Iinclude -Isource/linux \
`pkg-config --cflags gl glfw3` \
-DSTATUS_STRING="\"ftpd v$(VERSION)\"" \
-DFTPDCONFIG="\"ftpd.cfg\"" \
`curl-config --cflags`
CFLAGS := $(CPPFLAGS)
CXXFLAGS := $(CPPFLAGS) -std=gnu++2a
LDFLAGS := -pthread `curl-config --libs` `pkg-config --libs gl glfw3` -ldl
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OFILES) $(OXXFILES)
$(CXX) -o $@ $^ $(LDFLAGS)
$(OFILES): $(BUILD)/%.c.o : source/%.c
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
$(CC) -MMD -MP -MF $(BUILD)/$*.c.d $(CFLAGS) -c $< -o $@
$(OXXFILES): $(BUILD)/%.cpp.o : source/%.cpp
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
$(CXX) -MMD -MP -MF $(BUILD)/$*.c.d $(CXXFLAGS) -c $< -o $@
clean:
@$(RM) -r $(BUILD) $(TARGET)
-include $(shell find $(BUILD) -name \*.d 2>/dev/null)

View File

@ -1,206 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DATA is a list of directories containing binary files embedded using bin2o
# GRAPHICS is a list of directories containing image files to be converted with grit
# AUDIO is a list of directories containing audio to be converted by maxmod
# ICON is the image used to create the game icon, leave blank to use default rule
# NITRO is a directory that will be accessible via NitroFS
#---------------------------------------------------------------------------------
TARGET := nds/ftpd
BUILD := nds/build
SOURCES := source source/nds
INCLUDES := include
DATA :=
GRAPHICS :=
AUDIO :=
ICON :=
# specify a directory which contains the nitro filesystem
# this is relative to the Makefile
NITRO :=
# These set the information text in the nds file
GAME_TITLE := ftpd classic
GAME_SUBTITLE1 := v$(VERSION)
GAME_SUBTITLE2 := (c) 2023 mtheall
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
OPTIMIZE := -Og
ARCH := -marm -mthumb-interwork -march=armv5te -mtune=arm946e-s
CFLAGS := -g -Wall $(OPTIMIZE) \
$(ARCH) $(INCLUDE) -DARM9 -DNDS \
-DSTATUS_STRING="\"ftpd v$(VERSION)\"" \
-DNO_IPV6 -DCLASSIC -DFTPDCONFIG="\"/config/ftpd/ftpd.cfg\""
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++2a
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) $(OPTIMIZE)
CC := `which ccache 2>/dev/null` $(CC)
CXX := `which ccache 2>/dev/null` $(CXX)
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project (order is important)
#---------------------------------------------------------------------------------
LIBS := -lfat -ldswifi9 -lnds9
# automatigically add libraries for NitroFS
ifneq ($(strip $(NITRO)),)
LIBS := -lfilesystem -lfat $(LIBS)
endif
# automagically add maxmod library
ifneq ($(strip $(AUDIO)),)
LIBS := -lmm9 $(LIBS)
endif
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(TOPDIR)/$(BUILD),$(CURDIR))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(CURDIR)/$(subst /,,$(dir $(ICON)))\
$(foreach dir,$(SOURCES),$(CURDIR)/$(dir))\
$(foreach dir,$(DATA),$(CURDIR)/$(dir))\
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
# prepare NitroFS directory
ifneq ($(strip $(NITRO)),)
export NITRO_FILES := $(CURDIR)/$(NITRO)
endif
# get audio list for maxmod
ifneq ($(strip $(AUDIO)),)
export MODFILES := $(foreach dir,$(notdir $(wildcard $(AUDIO)/*.*)),$(CURDIR)/$(AUDIO)/$(dir))
# place the soundbank file in NitroFS if using it
ifneq ($(strip $(NITRO)),)
export SOUNDBANK := $(NITRO_FILES)/soundbank.bin
# otherwise, needs to be loaded from memory
else
export SOUNDBANK := soundbank.bin
BINFILES += $(SOUNDBANK)
endif
endif
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES))\
$(PNGFILES:.png=.o)\
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir))\
$(foreach dir,$(LIBDIRS),-I$(dir)/include)\
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
icons := $(wildcard $(dir $(TARGET))*.bmp)
ifneq (,$(findstring $(TARGET).bmp,$(icons)))
export GAME_ICON := $(CURDIR)/$(TARGET).bmp
else
ifneq (,$(findstring $(dir $(TARGET))icon.bmp,$(icons)))
export GAME_ICON := $(CURDIR)/$(dir $(TARGET))icon.bmp
endif
endif
.PHONY: $(BUILD) clean dslink
#---------------------------------------------------------------------------------
$(BUILD):
@mkdir -p $@
@$(MAKE) -C $(BUILD) -f $(CURDIR)/Makefile.nds
dslink: $(BUILD)
@dslink $(OUTPUT).nds
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(SOUNDBANK)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).nds: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES)
# need to build soundbank first
$(OFILES): $(SOUNDBANK) $(TOPDIR)/Makefile $(TOPDIR)/Makefile.nds
#---------------------------------------------------------------------------------
# rule to build solution from music files
#---------------------------------------------------------------------------------
$(SOUNDBANK) : $(MODFILES)
#---------------------------------------------------------------------------------
mmutil $^ -d -o$@ -hsoundbank.h
#---------------------------------------------------------------------------------
%.bin.o: %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
$(bin2o)
#---------------------------------------------------------------------------------
# This rule creates assembly source files using grit
# grit takes an image file and a .grit describing how the file is to be processed
# add additional rules like this for each image extension
# you use in the graphics folders
#---------------------------------------------------------------------------------
%.s %.h: %.png %.grit
#---------------------------------------------------------------------------------
grit $< -fts -o$*
-include $(DEPSDIR)/*.d
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,317 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#
# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.json
# - config.json
# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
APP_AUTHOR := (c) 2023 Michael Theall, Dave Murphy, TuxSH
ICON := meta/ftpd.jpg
APP_VERSION := $(VERSION)
SOURCES := source source/switch
DATA := data
INCLUDES := include
ifeq ($(strip $(CLASSIC)),)
APP_TITLE := ftpd pro $(VERSION)
TARGET := switch/ftpd
BUILD := switch/build
SOURCES += source/imgui
GRAPHICS := switch/gfx
ROMFS := switch/romfs
else
APP_TITLE := ftpd classic $(VERSION)
TARGET := switch-classic/ftpd-classic
BUILD := switch-classic/build
endif
# Output folders for autogenerated files in romfs
OUT_SHADERS := shaders
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
OPTIMIZE:= -Og
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
CFLAGS := -g -Wall -Wno-narrowing $(OPTIMIZE) \
-ffunction-sections -fdata-sections \
$(ARCH) $(DEFINES) $(CLASSIC) -DNO_IPV6
CFLAGS += $(INCLUDE) -D__SWITCH__ \
-DSTATUS_STRING="\"ftpd v$(VERSION)\"" \
-DFTPDCONFIG="\"/config/ftpd/ftpd.cfg\"" \
`$(PREFIX)pkg-config --cflags libzstd` \
`curl-config --cflags`
CXXFLAGS := $(CFLAGS) -std=gnu++2a -fno-exceptions -fno-rtti
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) \
$(OPTIMIZE) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
CC := `which ccache 2>/dev/null` $(CC)
CXX := `which ccache 2>/dev/null` $(CXX)
LIBS := `curl-config --libs` `$(PREFIX)pkg-config --libs libzstd` -ldeko3d -lnx
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNX)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(TOPDIR)/$(BUILD),$(CURDIR))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
GLSLFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.glsl)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
ASTCFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.astc)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
ifneq ($(strip $(ROMFS)),)
ROMFS_TARGETS :=
ROMFS_FOLDERS :=
ifneq ($(strip $(OUT_SHADERS)),)
ROMFS_SHADERS := $(ROMFS)/$(OUT_SHADERS)
ROMFS_TARGETS += $(patsubst %.glsl, $(ROMFS_SHADERS)/%.dksh, $(GLSLFILES))
ROMFS_FOLDERS += $(ROMFS_SHADERS)
endif
ROMFS_PNG := $(addprefix $(ROMFS)/,$(PNGFILES:.png=.rgba.zst))
ROMFS_ASTC := $(addprefix $(ROMFS)/,$(ASTCFILES:.astc=.astc.zst))
ROMFS_GFX := $(ROMFS_PNG) $(ROMFS_ASTC)
ROMFS_TARGETS += $(ROMFS_GFX)
ROMFS_FOLDERS += $(ROMFS)
export ROMFS_DEPS := $(foreach file,$(ROMFS_TARGETS),$(CURDIR)/$(file))
endif
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(CONFIG_JSON)),)
jsons := $(wildcard *.json)
ifneq (,$(findstring $(TARGET).json,$(jsons)))
export APP_JSON := $(TOPDIR)/$(TARGET).json
else
ifneq (,$(findstring config.json,$(jsons)))
export APP_JSON := $(TOPDIR)/config.json
endif
endif
else
export APP_JSON := $(TOPDIR)/$(CONFIG_JSON)
endif
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.jpg)
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
else
ifneq (,$(findstring icon.jpg,$(icons)))
export APP_ICON := $(TOPDIR)/icon.jpg
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_ICON)),)
export NROFLAGS += --icon=$(APP_ICON)
endif
ifeq ($(strip $(NO_NACP)),)
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
endif
ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif
ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
.PHONY: all clean
#---------------------------------------------------------------------------------
all: $(ROMFS_TARGETS) | $(BUILD)
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.switch
nxlink: all
@nxlink -s $(OUTPUT).nro
$(BUILD):
@mkdir -p $@
ifneq ($(strip $(ROMFS_TARGETS)),)
$(ROMFS_TARGETS): | $(ROMFS_FOLDERS)
$(ROMFS_FOLDERS):
@mkdir -p $@
$(BUILD)/%.rgba: $(GRAPHICS)/%.png | $(BUILD)
@convert $< $@
$(ROMFS_PNG): $(ROMFS)/%.rgba.zst: $(BUILD)/%.rgba
@zstd -f $< -o $@ --ultra -22
$(ROMFS_ASTC): $(ROMFS)/%.astc.zst: $(GRAPHICS)/%.astc
@zstd -f $< -o $@ --ultra -22
$(ROMFS_SHADERS)/%_vsh.dksh: %_vsh.glsl
@echo {vert} $(notdir $<)
@uam -s vert -o $@ $<
$(ROMFS_SHADERS)/%_tcsh.dksh: %_tcsh.glsl
@echo {tess_ctrl} $(notdir $<)
@uam -s tess_ctrl -o $@ $<
$(ROMFS_SHADERS)/%_tesh.dksh: %_tesh.glsl
@echo {tess_eval} $(notdir $<)
@uam -s tess_eval -o $@ $<
$(ROMFS_SHADERS)/%_gsh.dksh: %_gsh.glsl
@echo {geom} $(notdir $<)
@uam -s geom -o $@ $<
$(ROMFS_SHADERS)/%_fsh.dksh: %_fsh.glsl
@echo {frag} $(notdir $<)
@uam -s frag -o $@ $<
$(ROMFS_SHADERS)/%.dksh: %.glsl
@echo {comp} $(notdir $<)
@uam -s comp -o $@ $<
endif
#---------------------------------------------------------------------------------
clean:
@echo clean ...
ifeq ($(strip $(APP_JSON)),)
@$(RM) -r $(BUILD) $(ROMFS)/*.zst $(ROMFS_FOLDERS) $(TARGET).nro $(TARGET).nacp $(TARGET).elf
else
@$(RM) -r $(BUILD) $(ROMFS_FOLDERS) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif
#---------------------------------------------------------------------------------
else
.PHONY: all
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(APP_JSON)),)
all : $(OUTPUT).nro
ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp $(ROMFS_DEPS)
else
$(OUTPUT).nro : $(OUTPUT).elf $(ROMFS_DEPS)
endif
else
all : $(OUTPUT).nsp
$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm
$(OUTPUT).nso : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
$(OFILES) : $(TOPDIR)/Makefile $(TOPDIR)/Makefile.switch
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2022 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -43,7 +43,7 @@ public:
/// \param path_ Path to config file
static UniqueFtpConfig load (char const *path_);
#ifndef NDS
#ifndef __NDS__
std::scoped_lock<platform::Mutex> lockGuard ();
#endif
@ -116,7 +116,7 @@ public:
private:
FtpConfig ();
#ifndef NDS
#ifndef __NDS__
/// \brief Mutex
mutable platform::Mutex m_lock;
#endif

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2022 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -88,7 +88,7 @@ private:
/// \brief Thread entry point
void threadFunc ();
#ifndef NDS
#ifndef __NDS__
/// \brief Thread
platform::Thread m_thread;

View File

@ -60,7 +60,7 @@ private:
/// \brief Command buffer size
constexpr static auto COMMAND_BUFFERSIZE = 4096;
#ifdef NDS
#ifdef __NDS__
/// \brief Response buffer size
constexpr static auto RESPONSE_BUFFERSIZE = 4096;
@ -77,7 +77,7 @@ private:
/// \brief File buffersize
constexpr static auto FILE_BUFFERSIZE = 4 * XFER_BUFFERSIZE;
#if defined(NDS)
#if defined(__NDS__)
/// \brief Socket buffer size
constexpr static auto SOCK_BUFFERSIZE = 4096;
@ -205,7 +205,7 @@ private:
/// \brief Transfer upload
bool storeTransfer ();
#ifndef NDS
#ifndef __NDS__
/// \brief Mutex
platform::Mutex m_lock;
#endif

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -43,11 +43,11 @@ extern char const *const g_libnxLicense;
extern char const *const g_bsdLicense;
#endif
#if !defined(NDS)
#if !defined(__NDS__)
extern char const *const g_zlibLicense;
#endif
#if !defined(NDS) && !defined(__3DS__) && !defined(__SWITCH__)
#if !defined(__NDS__) && !defined(__3DS__) && !defined(__SWITCH__)
extern char const *const g_glfwVersion;
extern char const *const g_glfwCopyright;
#endif

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2022 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -24,6 +24,10 @@
#include <string>
#include <string_view>
#ifdef DEBUG
#undef DEBUG
#endif
/// \brief Log level
enum LogLevel
{

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -22,7 +22,7 @@
#include "sockAddr.h"
#if defined(NDS)
#if defined(__NDS__)
#include <nds.h>
#elif defined(__3DS__)
#include <3ds.h>
@ -107,7 +107,7 @@ struct steady_clock
using steady_clock = std::chrono::steady_clock;
#endif
#ifndef NDS
#ifndef __NDS__
/// \brief Platform thread
class Thread
{

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
#include <cstdint>
#ifdef NDS
#ifdef __NDS__
struct sockaddr_storage
{
unsigned short ss_family;

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@
#include <chrono>
#include <memory>
#ifdef NDS
#ifdef __NDS__
struct pollfd
{
int fd;

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
#include <cstdio>
#include <string>
#if defined(NDS) || defined(__3DS__) || defined(__SWITCH__)
#if defined(__NDS__) || defined(__3DS__) || defined(__SWITCH__)
#define getline __getline
#endif

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2022 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -186,7 +186,7 @@ UniqueFtpConfig FtpConfig::load (char const *const path_)
return config;
}
#ifndef NDS
#ifndef __NDS__
std::scoped_lock<platform::Mutex> FtpConfig::lockGuard ()
{
return std::scoped_lock<platform::Mutex> (m_lock);
@ -290,7 +290,7 @@ bool FtpConfig::setPort (std::uint16_t const port_)
errno = EPERM;
return false;
}
#elif defined(NDS) || defined(__3DS__)
#elif defined(__NDS__) || defined(__3DS__)
// 3DS is allowed < 1024, but not 0
// NDS is allowed < 1024, but 0 crashes the app
if (port_ == 0)

View File

@ -28,7 +28,7 @@
#include "imgui.h"
#ifdef NDS
#ifdef __NDS__
#include <dswifi9.h>
#endif
@ -46,7 +46,7 @@
#include <thread>
using namespace std::chrono_literals;
#ifdef NDS
#ifdef __NDS__
#define LOCKED(x) x
#else
#define LOCKED(x) \
@ -62,7 +62,7 @@ namespace
/// \brief Application start time
auto const s_startTime = std::time (nullptr);
#ifndef NDS
#ifndef __NDS__
/// \brief Mutex for s_freeSpace
platform::Mutex s_lock;
#endif
@ -163,7 +163,7 @@ FtpServer::~FtpServer ()
{
m_quit = true;
#ifndef NDS
#ifndef __NDS__
m_thread.join ();
#endif
@ -182,21 +182,21 @@ FtpServer::~FtpServer ()
FtpServer::FtpServer (UniqueFtpConfig config_) : m_config (std::move (config_)), m_quit (false)
{
#ifndef NDS
#ifndef __NDS__
m_thread = platform::Thread (std::bind (&FtpServer::threadFunc, this));
#endif
}
void FtpServer::draw ()
{
#ifdef NDS
#ifdef __NDS__
loop ();
#endif
#ifdef CLASSIC
{
char port[7];
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (m_lock);
#endif
if (m_socket)
@ -208,7 +208,7 @@ void FtpServer::draw ()
m_socket ? m_socket->sockName ().name () : "Waiting on WiFi",
m_socket ? port : "");
#ifndef NDS
#ifndef __NDS__
char timeBuffer[16];
auto const now = std::time (nullptr);
std::strftime (timeBuffer, sizeof (timeBuffer), "%H:%M:%S", std::localtime (&now));
@ -221,7 +221,7 @@ void FtpServer::draw ()
}
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (s_lock);
#endif
if (!s_freeSpace.empty ())
@ -235,7 +235,7 @@ void FtpServer::draw ()
}
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (m_lock);
#endif
consoleSelect (&g_sessionConsole);
@ -332,7 +332,7 @@ UniqueFtpServer FtpServer::create ()
std::string FtpServer::getFreeSpace ()
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (s_lock);
#endif
return s_freeSpace;
@ -341,7 +341,7 @@ std::string FtpServer::getFreeSpace ()
void FtpServer::updateFreeSpace ()
{
struct statvfs st;
#if defined(NDS) || defined(__3DS__) || defined(__SWITCH__)
#if defined(__NDS__) || defined(__3DS__) || defined(__SWITCH__)
if (::statvfs ("sdmc:/", &st) != 0)
#else
if (::statvfs ("/", &st) != 0)
@ -350,7 +350,7 @@ void FtpServer::updateFreeSpace ()
auto freeSpace = fs::printSize (static_cast<std::uint64_t> (st.f_bsize) * st.f_bfree);
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (s_lock);
#endif
if (freeSpace != s_freeSpace)
@ -371,7 +371,7 @@ void FtpServer::handleNetworkFound ()
std::uint16_t port;
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config->lockGuard ();
#endif
port = m_config->port ();
@ -439,7 +439,7 @@ void FtpServer::showMenu ()
if (ImGui::MenuItem ("Upload Log"))
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (m_lock);
#endif
if (!m_uploadLogCurlM)
@ -501,7 +501,7 @@ void FtpServer::showMenu ()
{
if (!prevShowSettings)
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config->lockGuard ();
#endif
@ -634,7 +634,7 @@ void FtpServer::showSettings ()
m_showSettings = false;
ImGui::CloseCurrentPopup ();
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config->lockGuard ();
#endif
@ -659,7 +659,7 @@ void FtpServer::showSettings ()
if (save)
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config->lockGuard ();
#endif
if (!m_config->save (FTPDCONFIG))
@ -732,7 +732,7 @@ void FtpServer::showAbout ()
ImGui::TreePop ();
}
#if defined(NDS)
#if defined(__NDS__)
#elif defined(__3DS__)
if (ImGui::TreeNode (g_libctruVersion))
{
@ -891,7 +891,7 @@ void FtpServer::loop ()
std::vector<UniqueFtpSession> deadSessions;
{
// remove dead sessions
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (m_lock);
#endif
auto it = std::begin (m_sessions);
@ -915,7 +915,7 @@ void FtpServer::loop ()
if (!FtpSession::poll (m_sessions))
handleNetworkLost ();
}
#ifndef NDS
#ifndef __NDS__
// avoid busy polling in background thread
else
platform::Thread::sleep (16ms);

View File

@ -40,11 +40,11 @@
#include <mutex>
using namespace std::chrono_literals;
#if defined(NDS) || defined(__3DS__) || defined(__SWITCH__)
#if defined(__NDS__) || defined(__3DS__) || defined(__SWITCH__)
#define lstat stat
#endif
#ifdef NDS
#ifdef __NDS__
#define LOCKED(x) x
#else
#define LOCKED(x) \
@ -294,7 +294,7 @@ FtpSession::FtpSession (FtpConfig &config_, UniqueSocket commandSocket_)
m_devZero (false)
{
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
if (m_config.user ().empty ())
@ -317,7 +317,7 @@ FtpSession::FtpSession (FtpConfig &config_, UniqueSocket commandSocket_)
bool FtpSession::dead ()
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (m_lock);
#endif
if (m_commandSocket || m_pasvSocket || m_dataSocket)
@ -328,7 +328,7 @@ bool FtpSession::dead ()
void FtpSession::draw ()
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (m_lock);
#endif
@ -614,7 +614,7 @@ void FtpSession::setState (State const state_, bool const closePasv_, bool const
if (state_ == State::COMMAND)
{
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (m_lock);
#endif
@ -1368,7 +1368,7 @@ void FtpSession::xferDir (char const *const args_, XferDirMode const mode_, bool
void FtpSession::readCommand (int const events_)
{
#ifndef NDS
#ifndef __NDS__
// check out-of-band data
if (events_ & POLLPRI)
{
@ -2209,7 +2209,7 @@ void FtpSession::PASS (char const *args_)
std::string pass;
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
user = m_config.user ();
@ -2261,7 +2261,7 @@ void FtpSession::PASV (char const *args_)
// create an address to bind
struct sockaddr_in addr = m_commandSocket->sockName ();
#if defined(NDS) || defined(__3DS__)
#if defined(__NDS__) || defined(__3DS__)
static std::uint16_t ephemeralPort = 5001;
if (ephemeralPort > 10000)
ephemeralPort = 5001;
@ -2602,7 +2602,7 @@ void FtpSession::SITE (char const *args_)
if (::strcasecmp (command.c_str (), "USER") == 0)
{
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
m_config.setUser (arg);
@ -2614,7 +2614,7 @@ void FtpSession::SITE (char const *args_)
else if (::strcasecmp (command.c_str (), "PASS") == 0)
{
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
m_config.setPass (arg);
@ -2628,7 +2628,7 @@ void FtpSession::SITE (char const *args_)
bool error = false;
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
error = !m_config.setPort (arg);
@ -2648,14 +2648,14 @@ void FtpSession::SITE (char const *args_)
{
if (arg == "0")
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
m_config.setGetMTime (false);
}
else if (arg == "1")
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
m_config.setGetMTime (true);
@ -2672,7 +2672,7 @@ void FtpSession::SITE (char const *args_)
bool error;
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
error = !m_config.save (FTPDCONFIG);
@ -2831,7 +2831,7 @@ void FtpSession::USER (char const *args_)
std::string pass;
{
#ifndef NDS
#ifndef __NDS__
auto const lock = m_config.lockGuard ();
#endif
user = m_config.user ();

View File

@ -26,7 +26,7 @@
#include <zstd.h>
#endif
#if !defined(NDS) && !defined(__3DS__) && !defined(__SWITCH__)
#if !defined(__NDS__) && !defined(__3DS__) && !defined(__SWITCH__)
#include <GLFW/glfw3.h>
#endif
@ -108,7 +108,7 @@ char const *const g_bsdLicense =
"OF THE POSSIBILITY OF SUCH DAMAGE.";
#endif
#if !defined(NDS)
#if !defined(__NDS__)
char const *const g_zlibLicense =
"This software is provided 'as-is', without any express or implied warranty. In no event will "
"the authors be held liable for any damages arising from the use of this software.\n"
@ -125,7 +125,7 @@ char const *const g_zlibLicense =
"3. This notice may not be removed or altered from any source distribution.";
#endif
#if !defined(NDS) && !defined(__3DS__) && !defined(__SWITCH__)
#if !defined(__NDS__) && !defined(__3DS__) && !defined(__SWITCH__)
#define STR(x) #x
#define XSTR(x) STR (x)
#define GLFW_VERSION_STRING \

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2022 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -71,7 +71,7 @@ struct Message
/// \brief Log messages
std::vector<Message> s_messages;
#ifndef NDS
#ifndef __NDS__
/// \brief Log lock
platform::Mutex s_lock;
#endif
@ -79,7 +79,7 @@ platform::Mutex s_lock;
void drawLog ()
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (s_lock);
#endif
@ -153,7 +153,7 @@ void drawLog ()
#ifndef CLASSIC
std::string getLog ()
{
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (s_lock);
#endif
@ -237,14 +237,14 @@ void addLog (LogLevel const level_, char const *const fmt_, va_list ap_)
return;
#endif
#ifndef NDS
#ifndef __NDS__
thread_local
#endif
static char buffer[1024];
std::vsnprintf (buffer, sizeof (buffer), fmt_, ap_);
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (s_lock);
#endif
#ifndef NDEBUG
@ -272,7 +272,7 @@ void addLog (LogLevel const level_, std::string_view const message_)
c = '?';
}
#ifndef NDS
#ifndef __NDS__
auto const lock = std::scoped_lock (s_lock);
#endif
#ifndef NDEBUG

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -150,7 +150,7 @@ char const *SockAddr::name (char *buffer_, std::size_t size_) const
switch (m_addr.ss_family)
{
case AF_INET:
#ifdef NDS
#ifdef __NDS__
return inet_ntoa (reinterpret_cast<struct sockaddr_in const *> (&m_addr)->sin_addr);
#else
return inet_ntop (AF_INET,
@ -175,7 +175,7 @@ char const *SockAddr::name (char *buffer_, std::size_t size_) const
char const *SockAddr::name () const
{
#ifdef NDS
#ifdef __NDS__
return inet_ntoa (reinterpret_cast<struct sockaddr_in const *> (&m_addr)->sin_addr);
#else
#ifdef NO_IPV6

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -40,7 +40,7 @@ Socket::~Socket ()
if (m_connected)
info ("Closing connection to [%s]:%u\n", m_peerName.name (), m_peerName.port ());
#ifdef NDS
#ifdef __NDS__
if (::closesocket (m_fd) != 0)
error ("closesocket: %s\n", std::strerror (errno));
#else
@ -80,7 +80,7 @@ UniqueSocket Socket::accept ()
int Socket::atMark ()
{
#ifdef NDS
#ifdef __NDS__
errno = ENOSYS;
return -1;
#else
@ -180,7 +180,7 @@ bool Socket::shutdown (int const how_)
bool Socket::setLinger (bool const enable_, std::chrono::seconds const time_)
{
#ifdef NDS
#ifdef __NDS__
errno = ENOSYS;
return -1;
#else
@ -204,7 +204,7 @@ bool Socket::setLinger (bool const enable_, std::chrono::seconds const time_)
bool Socket::setNonBlocking (bool const nonBlocking_)
{
#ifdef NDS
#ifdef __NDS__
unsigned long enable = nonBlocking_;
auto const rc = ::ioctl (m_fd, FIONBIO, &enable);
@ -369,7 +369,7 @@ int Socket::poll (PollInfo *const info_,
return rc;
}
#ifdef NDS
#ifdef __NDS__
extern "C" int poll (struct pollfd *const fds_, nfds_t const nfds_, int const timeout_)
{
fd_set readFds;

View File

@ -1605,11 +1605,15 @@ bool imgui::nx::init ()
u64 languageCode;
auto rc = setInitialize ();
if (R_FAILED (rc))
{
std::fprintf (stderr, "setInitialize: 0x%lx\n", rc);
return false;
}
rc = setGetSystemLanguage (&languageCode);
if (R_FAILED (rc))
{
std::fprintf (stderr, "setGetSystemLanguage: 0x%lx\n", rc);
setExit ();
return false;
}
@ -1620,7 +1624,10 @@ bool imgui::nx::init ()
s32 numFonts = 0;
rc = plGetSharedFont (languageCode, fonts.data (), fonts.size (), &numFonts);
if (R_FAILED (rc))
{
std::fprintf (stderr, "plGetSharedFont: 0x%lx\n", rc);
return false;
}
fonts.resize (numFonts);
// add fonts

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by

View File

@ -3,7 +3,7 @@
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2021 Michael Theall
// Copyright (C) 2023 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -29,7 +29,9 @@
#include "imgui.h"
#ifndef CLASSIC
#include <zstd.h>
#endif
#include <arpa/inet.h>
#include <sys/stat.h>