diff --git a/Makefile b/Makefile index 3bd88eb..8726ba7 100644 --- a/Makefile +++ b/Makefile @@ -33,13 +33,19 @@ SOURCES := source libs/lua-5.3.3/src libs/tremor DATA := data INCLUDES := include libs/lua-5.3.3/src libs/lzlib libs/tremor #ROMFS := romfs +ROOT := sdmc:/3ds/ctruLua/ APP_TITLE := ctruLua APP_DESCRIPTION := Lua for the 3DS. Yes, it works. -APP_AUTHOR := Reuh, Firew0lf and NegiAD +APP_AUTHOR := Reuh,Ihamfp,Nodyn +APP_PRODUCT_CODE := CTR-P-ULUA +APP_UNIQUE_ID := 0xB00B5 + ICON := icon.png +BANNER := banner.png +JINGLE := jingle.wav APP_VERSION := $(shell git describe --abbrev=0 --tags) -LASTCOMMIT := $(shell git rev-parse HEAD) +LASTCOMMIT := $(shell git rev-parse HEAD) #--------------------------------------------------------------------------------- # options for code generation @@ -54,6 +60,9 @@ CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DCTR_VERSION=\"$(APP_VERSION)\" -DCTR_BUILD ifneq ($(ROMFS),) CFLAGS += -DROMFS endif +ifneq ($(ROOT),) + CFLAGS += -DROOT=\"$(ROOT)\" +endif CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 @@ -134,8 +143,14 @@ ifeq ($(strip $(NO_SMDH)),) export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh endif +export CIA_ARGS := -DAPP_TITLE=$(APP_TITLE) -DAPP_PRODUCT_CODE=$(APP_PRODUCT_CODE) \ + -DAPP_UNIQUE_ID=$(APP_UNIQUE_ID) \ + -elf $(OUTPUT).elf -rsf "$(TOPDIR)/ctrulua.rsf" \ + -icon $(TOPDIR)/icon.bin -banner $(TOPDIR)/banner.bin -exefslogo -target t + ifneq ($(ROMFS),) export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS) + export CIA_ARGS += -DAPP_ROMFS_DIR=$(ROMFS) endif .PHONY: $(BUILD) clean all @@ -147,8 +162,12 @@ $(BUILD): @[ -d $(BUILD) ] || mkdir -p $(BUILD) @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile +$(BUILD)-cia: + @[ -d $(BUILD) ] || mkdir -p $(BUILD) + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile $(OUTPUT).cia + build-portlibs: - @make -C libs/3ds_portlibs zlib freetype libjpeg-turbo libpng libogg + @make -C libs/3ds_portlibs zlib install-zlib freetype libjpeg-turbo libpng libogg install build-citro3d: @make -C libs/citro3d build @@ -190,7 +209,7 @@ build-doc-st: #--------------------------------------------------------------------------------- clean: - @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf + @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf banner.bin icon.bin clean-portlibs: @make -C libs/3ds_portlibs clean @@ -242,14 +261,27 @@ DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- + +all : $(OUTPUT).3dsx $(OUTPUT).cia + ifeq ($(strip $(NO_SMDH)),) $(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh else $(OUTPUT).3dsx : $(OUTPUT).elf endif +icon.bin : + bannertool makesmdh -s $(APP_TITLE) -l $(APP_TITLE) -p $(APP_AUTHOR) -i $(TOPDIR)/$(ICON) -o $(TOPDIR)/icon.bin -f visible allow3d + +banner.bin : + bannertool makebanner -i $(TOPDIR)/$(BANNER) -a $(TOPDIR)/$(JINGLE) -o $(TOPDIR)/banner.bin + $(OUTPUT).elf : $(OFILES) +$(OUTPUT).cia : $(OUTPUT).elf icon.bin banner.bin + makerom -f cia -o $(OUTPUT).cia $(CIA_ARGS) + + #--------------------------------------------------------------------------------- # you need a rule like this for each extension you use as binary data #--------------------------------------------------------------------------------- diff --git a/ctrulua.rsf b/ctrulua.rsf new file mode 100644 index 0000000..50a45a4 --- /dev/null +++ b/ctrulua.rsf @@ -0,0 +1,223 @@ +BasicInfo: + Title : $(APP_TITLE) + ProductCode : $(APP_PRODUCT_CODE) + Logo : Nintendo # Nintendo / Licensed / Distributed / iQue / iQueForSystem + +RomFs: + # Specifies the root path of the read only file system to include in the ROM. + #RootPath : $(ROMFS) + +TitleInfo: + Category : Application + UniqueId : $(APP_UNIQUE_ID) + +Option: + UseOnSD : true # true if App is to be installed to SD + FreeProductCode : true # Removes limitations on ProductCode + MediaFootPadding : false # If true CCI files are created with padding + EnableCrypt : false # Enables encryption for NCCH and CIA + EnableCompress : true # Compresses where applicable (currently only exefs:/.code) + +AccessControlInfo: + CoreVersion : 2 + + # Exheader Format Version + DescVersion : 2 + + # Minimum Required Kernel Version (below is for 4.5.0) + ReleaseKernelMajor : "02" + ReleaseKernelMinor : "33" + + # ExtData + UseExtSaveData : false # enables ExtData + #ExtSaveDataId : 0x300 # only set this when the ID is different to the UniqueId + + # FS:USER Archive Access Permissions + # Uncomment as required + FileSystemAccess: + #- CategorySystemApplication + #- CategoryHardwareCheck + - CategoryFileSystemTool + #- Debug + #- TwlCardBackup + #- TwlNandData + #- Boss + - DirectSdmc + #- Core + #- CtrNandRo + #- CtrNandRw + #- CtrNandRoWrite + #- CategorySystemSettings + #- CardBoard + #- ExportImportIvs + #- DirectSdmcWrite + #- SwitchCleanup + #- SaveDataMove + #- Shop + #- Shell + #- CategoryHomeMenu + + # Process Settings + MemoryType : Application # Application/System/Base + SystemMode : 64MB # 64MB(Default)/96MB/80MB/72MB/32MB + IdealProcessor : 0 + AffinityMask : 1 + Priority : 16 + MaxCpu : 0 # Let system decide + HandleTableSize : 0x200 + DisableDebug : false + EnableForceDebug : false + CanWriteSharedPage : true + CanUsePrivilegedPriority : false + CanUseNonAlphabetAndNumber : true + PermitMainFunctionArgument : true + CanShareDeviceMemory : true + RunnableOnSleep : false + SpecialMemoryArrange : true + + # New3DS Exclusive Process Settings + SystemModeExt : Legacy # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode + CpuSpeed : 804MHz # 268MHz(Default)/804MHz + EnableL2Cache : true # false(default)/true + CanAccessCore2 : true + + # Virtual Address Mappings + IORegisterMapping: + - 1ff00000-1ff7ffff # DSP memory + MemoryMapping: + - 1f000000-1f5fffff:r # VRAM + + # Accessible SVCs, : + SystemCallAccess: + ArbitrateAddress: 34 + Break: 60 + CancelTimer: 28 + ClearEvent: 25 + ClearTimer: 29 + CloseHandle: 35 + ConnectToPort: 45 + ControlMemory: 1 + CreateAddressArbiter: 33 + CreateEvent: 23 + CreateMemoryBlock: 30 + CreateMutex: 19 + CreateSemaphore: 21 + CreateThread: 8 + CreateTimer: 26 + DuplicateHandle: 39 + ExitProcess: 3 + ExitThread: 9 + GetCurrentProcessorNumber: 17 + GetHandleInfo: 41 + GetProcessId: 53 + GetProcessIdOfThread: 54 + GetProcessIdealProcessor: 6 + GetProcessInfo: 43 + GetResourceLimit: 56 + GetResourceLimitCurrentValues: 58 + GetResourceLimitLimitValues: 57 + GetSystemInfo: 42 + GetSystemTick: 40 + GetThreadContext: 59 + GetThreadId: 55 + GetThreadIdealProcessor: 15 + GetThreadInfo: 44 + GetThreadPriority: 11 + MapMemoryBlock: 31 + OutputDebugString: 61 + QueryMemory: 2 + ReleaseMutex: 20 + ReleaseSemaphore: 22 + SendSyncRequest1: 46 + SendSyncRequest2: 47 + SendSyncRequest3: 48 + SendSyncRequest4: 49 + SendSyncRequest: 50 + SetThreadPriority: 12 + SetTimer: 27 + SignalEvent: 24 + SleepThread: 10 + UnmapMemoryBlock: 32 + WaitSynchronization1: 36 + WaitSynchronizationN: 37 + Backdoor: 123 + + # Service List + # Maximum 34 services (32 if firmware is prior to 9.3.0) + ServiceAccessControl: + - cfg:u + - fs:USER + - gsp::Gpu + - hid:USER + - ndm:u + - pxi:dev + - APT:U + - ac:u + - act:u + - am:net + - boss:U + - cam:u + - cecd:u + - csnd:SND + - frd:u + - http:C + - ir:USER + - ir:u + - ir:rst + - ldr:ro + - mic:u + - news:u + - nfc:u + - nim:aoc + - nwm::UDS + - ptm:u + - qtm:u + - soc:U + - ssl:C + - y2r:u + + +SystemControlInfo: + SaveDataSize: 0K + RemasterVersion: 0 + StackSize: 0x40000 + + # Modules that run services listed above should be included below + # Maximum 48 dependencies + # If a module is listed that isn't present on the 3DS, the title will get stuck at the logo (3ds waves) + # So act, nfc and qtm are commented for 4.x support. Uncomment if you need these. + # : + Dependency: + ac: 0x0004013000002402 + #act: 0x0004013000003802 + am: 0x0004013000001502 + boss: 0x0004013000003402 + camera: 0x0004013000001602 + cecd: 0x0004013000002602 + cfg: 0x0004013000001702 + codec: 0x0004013000001802 + csnd: 0x0004013000002702 + dlp: 0x0004013000002802 + dsp: 0x0004013000001a02 + friends: 0x0004013000003202 + gpio: 0x0004013000001b02 + gsp: 0x0004013000001c02 + hid: 0x0004013000001d02 + http: 0x0004013000002902 + i2c: 0x0004013000001e02 + ir: 0x0004013000003302 + mcu: 0x0004013000001f02 + mic: 0x0004013000002002 + ndm: 0x0004013000002b02 + news: 0x0004013000003502 + #nfc: 0x0004013000004002 + nim: 0x0004013000002c02 + nwm: 0x0004013000002d02 + pdn: 0x0004013000002102 + ps: 0x0004013000003102 + ptm: 0x0004013000002202 + #qtm: 0x0004013020004202 + ro: 0x0004013000003702 + socket: 0x0004013000002e02 + spi: 0x0004013000002302 + ssl: 0x0004013000002f02 diff --git a/jingle.wav b/jingle.wav new file mode 100644 index 0000000..4b7eacb Binary files /dev/null and b/jingle.wav differ diff --git a/libs/3ds_portlibs/.gitignore b/libs/3ds_portlibs/.gitignore index 8e0d03f..85a02f3 100644 --- a/libs/3ds_portlibs/.gitignore +++ b/libs/3ds_portlibs/.gitignore @@ -1,9 +1,9 @@ freetype-* +jansson-* libexif-* libjpeg-* libpng-* +libxmp-* sqlite-* +tinyxml2-* zlib-* -libogg-* -libvorbis-* -build/ \ No newline at end of file diff --git a/libs/3ds_portlibs/Makefile b/libs/3ds_portlibs/Makefile index c47b8c1..fd527e6 100644 --- a/libs/3ds_portlibs/Makefile +++ b/libs/3ds_portlibs/Makefile @@ -1,188 +1,359 @@ -FREETYPE := freetype -FREETYPE_VERSION := $(FREETYPE)-2.6 -FREETYPE_SRC := $(FREETYPE_VERSION).tar.bz2 -FREETYPE_DOWNLOAD := "http://download.savannah.gnu.org/releases/freetype/freetype-2.6.tar.bz2" +BZIP2 := bzip2 +BZIP2_VERSION := $(BZIP2)-1.0.6 +BZIP2_SRC := $(BZIP2_VERSION).tar.gz +BZIP2_DOWNLOAD := "http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz" -LIBEXIF := libexif -LIBEXIF_VERSION := $(LIBEXIF)-0.6.21 -LIBEXIF_SRC := $(LIBEXIF_VERSION).tar.bz2 -LIBEXIF_DOWNLOAD := "http://sourceforge.net/projects/libexif/files/libexif/0.6.21/libexif-0.6.21.tar.bz2" +FREETYPE := freetype +FREETYPE_VERSION := $(FREETYPE)-2.6.2 +FREETYPE_SRC := $(FREETYPE_VERSION).tar.bz2 +FREETYPE_DOWNLOAD := http://download.savannah.gnu.org/releases/freetype/freetype-2.6.2.tar.bz2 -LIBJPEGTURBO := libjpeg-turbo -LIBJPEGTURBO_VERSION := $(LIBJPEGTURBO)-1.4.1 -LIBJPEGTURBO_SRC := $(LIBJPEGTURBO_VERSION).tar.gz -LIBJPEGTURBO_DOWNLOAD := "http://sourceforge.net/projects/libjpeg-turbo/files/1.4.1/libjpeg-turbo-1.4.1.tar.gz" +GIFLIB := giflib +GIFLIB_VERSION := $(GIFLIB)-5.1.1 +GIFLIB_SRC := $(GIFLIB_VERSION).tar.bz2 +GIFLIB_DOWNLOAD := "http://sourceforge.net/projects/giflib/files/giflib-5.1.1.tar.bz2" -LIBPNG := libpng -LIBPNG_VERSION := $(LIBPNG)-1.6.17 -LIBPNG_SRC := $(LIBPNG_VERSION).tar.xz -LIBPNG_DOWNLOAD := "http://prdownloads.sourceforge.net/libpng/libpng-1.6.17.tar.xz" +JANSSON := jansson +JANSSON_VERSION := $(JANSSON)-2.7 +JANSSON_SRC := $(JANSSON_VERSION).tar.gz +JANSSON_DOWNLOAD := https://github.com/akheron/jansson/archive/v2.7.tar.gz -SQLITE := sqlite -SQLITE_VERSION := $(SQLITE)-autoconf-3081002 -SQLITE_SRC := $(SQLITE_VERSION).tar.gz -SQLITE_DOWNLOAD := "http://www.sqlite.org/2015/sqlite-autoconf-3081002.tar.gz" +LIBCONFIG := libconfig +LIBCONFIG_VERSION := $(LIBCONFIG)-1.5 +LIBCONFIG_SRC := $(LIBCONFIG_VERSION).tar.gz +LIBCONFIG_DOWNLOAD := "http://www.hyperrealm.com/libconfig/libconfig-1.5.tar.gz" -ZLIB := zlib -ZLIB_VERSION := $(ZLIB)-1.2.8 -ZLIB_SRC := $(ZLIB_VERSION).tar.gz -ZLIB_DOWNLOAD := "http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz" +LIBEXIF := libexif +LIBEXIF_VERSION := $(LIBEXIF)-0.6.21 +LIBEXIF_SRC := $(LIBEXIF_VERSION).tar.bz2 +LIBEXIF_DOWNLOAD := http://sourceforge.net/projects/libexif/files/libexif/0.6.21/libexif-0.6.21.tar.bz2/download -LIBOGG := libogg -LIBOGG_VERSION := $(LIBOGG)-1.3.2 -LIBOGG_SRC := $(LIBOGG_VERSION).tar.gz -LIBOGG_DOWNLOAD := "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz" +LIBJPEGTURBO := libjpeg-turbo +LIBJPEGTURBO_VERSION := $(LIBJPEGTURBO)-1.4.2 +LIBJPEGTURBO_SRC := $(LIBJPEGTURBO_VERSION).tar.gz +LIBJPEGTURBO_DOWNLOAD := http://sourceforge.net/projects/libjpeg-turbo/files/1.4.2/libjpeg-turbo-1.4.2.tar.gz/download -LIBVORBIS := libvorbis -LIBVORBIS_VERSION := $(LIBVORBIS)-1.3.5 -LIBVORBIS_SRC := $(LIBVORBIS_VERSION).tar.gz -LIBVORBIS_DOWNLOAD := "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz" +LIBMAD := libmad +LIBMAD_VERSION := $(LIBMAD)-0.15.1b +LIBMAD_SRC := $(LIBMAD_VERSION).tar.gz +LIBMAD_DOWNLOAD := "http://sourceforge.net/projects/mad/files/libmad/0.15.1b/libmad-0.15.1b.tar.gz" -export PORTLIBS := $(CURDIR)/build -export PATH := $(DEVKITARM)/bin:$(PATH) -export PKG_CONFIG_PATH := $(PORTLIBS)/lib/pkgconfig -export CFLAGS := -march=armv6k -mtune=mpcore -mfloat-abi=hard -O3 \ - -mword-relocations -fomit-frame-pointer -ffast-math -export CPPFLAGS := -I$(PORTLIBS)/include -export LDFLAGS := -L$(PORTLIBS)/lib +LIBOGG := libogg +LIBOGG_VERSION := $(LIBOGG)-1.3.2 +LIBOGG_SRC := $(LIBOGG_VERSION).tar.xz +LIBOGG_DOWNLOAD := "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz" -.PHONY: all old_all install install-zlib clean \ +LIBPNG := libpng +LIBPNG_VERSION := $(LIBPNG)-1.6.21 +LIBPNG_SRC := $(LIBPNG_VERSION).tar.xz +LIBPNG_DOWNLOAD := http://prdownloads.sourceforge.net/libpng/libpng-1.6.21.tar.xz?download + +LIBXML2 := libxml2 +LIBXML2_VERSION := $(LIBXML2)-2.9.3 +LIBXML2_SRC := $(LIBXML2_VERSION).tar.gz +LIBXML2_DOWNLOAD := "http://xmlsoft.org/sources/libxml2-2.9.3.tar.gz" + +LIBXMP_LITE := libxmp-lite +LIBXMP_LITE_VERSION := $(LIBXMP_LITE)-4.3.10 +LIBXMP_LITE_SRC := $(LIBXMP_LITE_VERSION).tar.gz +LIBXMP_LITE_DOWNLOAD := http://sourceforge.net/projects/xmp/files/libxmp/4.3.10/libxmp-lite-4.3.10.tar.gz/download + +MBED := mbedtls +MBED_VERSION := $(MBED)-2.2.1 +MBED_SRC := $(MBED_VERSION).tgz +MBED_DOWNLOAD := "https://tls.mbed.org/download/mbedtls-2.2.1-gpl.tgz" + +SQLITE := sqlite +SQLITE_VERSION := $(SQLITE)-autoconf-3100200 +SQLITE_SRC := $(SQLITE_VERSION).tar.gz +SQLITE_DOWNLOAD := https://www.sqlite.org/2016/sqlite-autoconf-3100200.tar.gz + +TINYXML := tinyxml2 +TINYXML_VERSION := $(TINYXML)-3.0.0 +TINYXML_SRC := $(TINYXML_VERSION).tar.gz +TINYXML_DOWNLOAD := https://github.com/leethomason/tinyxml2/archive/3.0.0.tar.gz + +TREMOR := tremor +TREMOR_VERSION := $(TREMOR)-2a1a8f6 +TREMOR_SRC := $(TREMOR_VERSION).tar.gz +TREMOR_DOWNLOAD := https://git.xiph.org/?p=tremor.git;a=snapshot;h=2a1a8f621e500fdf0749f115e2206f82919560a3;sf=tgz + +XZ := xz +XZ_VERSION := $(XZ)-5.2.2 +XZ_SRC := $(XZ_VERSION).tar.xz +XZ_DOWNLOAD := "http://tukaani.org/xz/xz-5.2.2.tar.xz" + +ZLIB := zlib +ZLIB_VERSION := $(ZLIB)-1.2.8 +ZLIB_SRC := $(ZLIB_VERSION).tar.gz +ZLIB_DOWNLOAD := http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz?download + +export PORTLIBS_PATH := $(DEVKITPRO)/portlibs +export PATH := $(DEVKITARM)/bin:$(PORTLIBS_PATH)/3ds/bin:$(PORTLIBS_PATH)/armv6k/bin:$(PATH) +export PKG_CONFIG := $(PWD)/arm-none-eabi-pkg-config + +export CFLAGS := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -O3 -mword-relocations -ffunction-sections +export CPPFLAGS := -I$(PORTLIBS_PATH)/armv6k/include +export LDFLAGS := -L$(PORTLIBS_PATH)/armv6k/lib + +.PHONY: all install install-zlib clean download \ + $(BZIP2) \ $(FREETYPE) \ + $(GIFLIB) \ + $(JANSSON) \ + $(LIBCONFIG) \ $(LIBEXIF) \ $(LIBJPEGTURBO) \ + $(LIBMAD) \ + $(LIBOGG) \ $(LIBPNG) \ + $(MBED) \ + $(LIBXML2) \ + $(LIBXMP_LITE) \ $(SQLITE) \ + $(TINYXML) \ + $(TREMOR) \ + $(XZ) \ $(ZLIB) -all: zlib install-zlib freetype libexif libjpeg-turbo libpng sqlite install - @echo "Finished!" -create_build_dir: - @[ -d $(CURDIR)/build ] || mkdir -p $(CURDIR)/build - @[ -d $(CURDIR)/build/include ] || mkdir -p $(CURDIR)/build/include - @[ -d $(CURDIR)/build/lib ] || mkdir -p $(CURDIR)/build/lib - -old_all: +all: @echo "Please choose one of the following targets:" + @echo " $(BZIP2)" @echo " $(FREETYPE) (requires zlib to be installed)" + @echo " $(GIFLIB)" + @echo " $(JANSSON)" + @echo " $(LIBCONFIG)" @echo " $(LIBEXIF)" @echo " $(LIBJPEGTURBO)" + @echo " $(LIBMAD)" + @echo " $(LIBOGG)" @echo " $(LIBPNG) (requires zlib to be installed)" + @echo " $(LIBXML2)" + @echo " $(LIBXMP_LITE)" + @echo " $(MBED) (requires zlib to be installed)" @echo " $(SQLITE)" + @echo " $(TINYXML)" + @echo " $(TREMOR) (requires $(LIBOGG) to be installed)" + @echo " $(XZ)" @echo " $(ZLIB)" +download: $(BZIP2_SRC) $(FREETYPE_SRC) $(GIFLIB_SRC) $(JANSSON_SRC) $(LIBCONFIG_SRC) $(LIBEXIF_SRC) $(LIBJPEGTURBO_SRC) $(LIBMAD_SRC) $(LIBOGG_SRC) $(LIBPNG_SRC) $(LIBXML2_SRC) $(LIBXMP_LITE_SRC) $(MBED_SRC) $(SQLITE_SRC) $(TINYXML_SRC) $(TREMOR_SRC) $(XZ_SRC) $(ZLIB_SRC) + +DOWNLOAD = wget --no-check-certificate -O "$(1)" "$(2)" || curl -Lo "$(1)" "$(2)" + +$(BZIP2_SRC): + @$(call DOWNLOAD,$@,$(BZIP2_DOWNLOAD)) + +$(FREETYPE_SRC): + $(call DOWNLOAD,$@,$(FREETYPE_DOWNLOAD)) + +$(GIFLIB_SRC): + $(call DOWNLOAD,$@,$(GIFLIB_DOWNLOAD)) + +$(JANSSON_SRC): + @$(call DOWNLOAD,$@,$(JANSSON_DOWNLOAD)) + +$(LIBCONFIG_SRC): + @$(call DOWNLOAD,$@,$(LIBCONFIG_DOWNLOAD)) + +$(LIBEXIF_SRC): + @$(call DOWNLOAD,$@,$(LIBEXIF_DOWNLOAD)) + +$(LIBJPEGTURBO_SRC): + @$(call DOWNLOAD,$@,$(LIBJPEGTURBO_DOWNLOAD)) + +$(LIBMAD_SRC): + @$(call DOWNLOAD,$@,$(LIBMAD_DOWNLOAD)) + +$(LIBOGG_SRC): + @$(call DOWNLOAD,$@,$(LIBOGG_DOWNLOAD)) + +$(LIBPNG_SRC): + @$(call DOWNLOAD,$@,$(LIBPNG_DOWNLOAD)) + +$(LIBXML2_SRC): + @$(call DOWNLOAD,$@,$(LIBXML2_DOWNLOAD)) + +$(LIBXMP_LITE_SRC): + @$(call DOWNLOAD,$@,$(LIBXMP_LITE_DOWNLOAD)) + +$(MBED_SRC): + @$(call DOWNLOAD,$@,$(MBED_DOWNLOAD)) + +$(SQLITE_SRC): + @$(call DOWNLOAD,$@,$(SQLITE_DOWNLOAD)) + +$(TINYXML_SRC): + @$(call DOWNLOAD,$@,$(TINYXML_DOWNLOAD)) + +$(TREMOR_SRC): + @$(call DOWNLOAD,$@,$(TREMOR_DOWNLOAD)) + +$(XZ_SRC): + @$(call DOWNLOAD,$@,$(XZ_DOWNLOAD)) + +$(ZLIB_SRC): + @$(call DOWNLOAD,$@,$(ZLIB_DOWNLOAD)) + +$(BZIP2): $(BZIP2_SRC) + @[ -d $(BZIP2_VERSION) ] || tar -xzf $< + @cd $(BZIP2_VERSION) + @$(MAKE) -C $(BZIP2_VERSION) CC=arm-none-eabi-gcc AR=arm-none-eabi-ar RANLIB=arm-none-eabi-ranlib CPPFLAGS="$(CPPFLAGS)" CFLAGS="-D_FILE_OFFSET_BITS=64 -Winline $(CFLAGS)" libbz2.a + $(FREETYPE): $(FREETYPE_SRC) - @[ -d $(FREETYPE_VERSION) ] || tar -xf $< + @[ -d $(FREETYPE_VERSION) ] || tar -xjf $< @cd $(FREETYPE_VERSION) && \ - ./configure --prefix=$(PORTLIBS) --host=arm-none-eabi --disable-shared --enable-static --without-harfbuzz + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static --without-harfbuzz @$(MAKE) -C $(FREETYPE_VERSION) - @make create_build_dir - @cp -srf $(CURDIR)/$(FREETYPE_VERSION)/include/. $(CURDIR)/build/include - @cp -sf $(CURDIR)/$(FREETYPE_VERSION)/objs/.libs/libfreetype.a $(CURDIR)/build/lib/libfreetype.a + +$(GIFLIB): $(GIFLIB_SRC) + @[ -d $(GIFLIB_VERSION) ] || tar -xjf $< + @cd $(GIFLIB_VERSION) && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static + @$(MAKE) -C $(GIFLIB_VERSION) + +$(JANSSON): $(JANSSON_SRC) + @[ -d $(JANSSON_VERSION) ] || tar -xzf $< + @cd $(JANSSON_VERSION) && \ + autoreconf -i && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static + @$(MAKE) -C $(JANSSON_VERSION) + +$(LIBCONFIG): $(LIBCONFIG_SRC) + @[ -d $(LIBCONFIG_VERSION) ] || tar -xzf $< + @cd $(LIBCONFIG_VERSION) && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-cxx --disable-examples + @$(MAKE) -C $(LIBCONFIG_VERSION)/lib $(LIBEXIF): $(LIBEXIF_SRC) - @[ -d $(LIBEXIF_VERSION) ] || tar -xf $< + @[ -d $(LIBEXIF_VERSION) ] || tar -xjf $< @cd $(LIBEXIF_VERSION) && \ - ./configure --prefix=$(PORTLIBS) --host=arm-none-eabi --disable-shared --enable-static + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static @$(MAKE) -C $(LIBEXIF_VERSION) $(LIBJPEGTURBO): $(LIBJPEGTURBO_SRC) - @[ -d $(LIBJPEGTURBO_VERSION) ] || tar -xf $< + @[ -d $(LIBJPEGTURBO_VERSION) ] || tar -xzf $< @cd $(LIBJPEGTURBO_VERSION) && \ - ./configure --prefix=$(PORTLIBS) --host=arm-none-eabi --disable-shared --enable-static - @$(MAKE) CFLAGS+="\"-Drandom()=rand()\"" -C $(LIBJPEGTURBO_VERSION) - @make create_build_dir - @cp -sf $(CURDIR)/$(LIBJPEGTURBO_VERSION)/*.h $(CURDIR)/build/include - @cp -sf $(CURDIR)/$(LIBJPEGTURBO_VERSION)/.libs/libjpeg.a $(CURDIR)/build/lib/libjpeg.a + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static + @$(MAKE) -C $(LIBJPEGTURBO_VERSION) + +$(LIBMAD): $(LIBMAD_SRC) + @[ -d $(LIBMAD_VERSION) ] || tar -xzf $< + @cd $(LIBMAD_VERSION) && \ + patch -Np1 -i ../libmad-0.15.1b.patch && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static + @$(MAKE) -C $(LIBMAD_VERSION) + +$(LIBOGG): $(LIBOGG_SRC) + @[ -d $(LIBOGG_VERSION) ] || tar -xJf $< + @cd $(LIBOGG_VERSION) && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static + @$(MAKE) -C $(LIBOGG_VERSION) $(LIBPNG): $(LIBPNG_SRC) - @[ -d $(LIBPNG_VERSION) ] || tar -xf $< + @[ -d $(LIBPNG_VERSION) ] || tar -xJf $< @cd $(LIBPNG_VERSION) && \ - ./configure --prefix=$(PORTLIBS) --host=arm-none-eabi --disable-shared --enable-static + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static @$(MAKE) -C $(LIBPNG_VERSION) - @make create_build_dir - @cp -sf $(CURDIR)/$(LIBPNG_VERSION)/*.h $(CURDIR)/build/include - @cp -sf $(CURDIR)/$(LIBPNG_VERSION)/.libs/*.a $(CURDIR)/build/lib/libpng.a + +$(LIBXML2): $(LIBXML2_SRC) + @[ -d $(LIBXML2_VERSION) ] || tar -xzf $< + @cd $(LIBXML2_VERSION) && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static --without-http --without-ftp --without-threads + @$(MAKE) -C $(LIBXML2_VERSION) libxml2.la + +$(LIBXMP_LITE): $(LIBXMP_LITE_SRC) + @[ -d $(LIBXMP_LITE_VERSION) ] || tar -xzf $< + @cd $(LIBXMP_LITE_VERSION) && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static + @$(MAKE) -C $(LIBXMP_LITE_VERSION) + +$(MBED): $(MBED_SRC) + @[ -d $(MBED_VERSION) ] || tar xzf $< + @cd $(MBED_VERSION) && \ + patch -Np1 -i ../libmbedtls-2.2.1.patch && \ + cmake -DCMAKE_SYSTEM_NAME=Generic -DCMAKE_C_COMPILER=$(DEVKITARM)/bin/arm-none-eabi-gcc \ + -DCMAKE_CXX_COMPILER=$(DEVKITARM)/bin/arm-none-eabi-g++ \ + -DCMAKE_INSTALL_PREFIX=$(PORTLIBS_PATH)/armv6k -DCMAKE_C_FLAGS="$(CFLAGS)" \ + -DCMAKE_CXX_FLAGS="$(CFLAGS) -fno-exceptions -fno-rtti" \ + -DZLIB_ROOT="$(PORTLIBS_PATH)/armv6k" \ + -DENABLE_ZLIB_SUPPORT=TRUE -DENABLE_TESTING=FALSE -DENABLE_PROGRAMS=FALSE . + @$(MAKE) -C $(MBED_VERSION) # sqlite won't work with -ffast-math $(SQLITE): $(SQLITE_SRC) - @[ -d $(SQLITE_VERSION) ] || tar -xf $< + @[ -d $(SQLITE_VERSION) ] || tar -xzf $< @cd $(SQLITE_VERSION) && \ - CFLAGS="$(filter-out -ffast-math,$(CFLAGS)) -DSQLITE_OS_OTHER=1" ./configure --disable-shared --disable-threadsafe --disable-dynamic-extensions --host=arm-none-eabi --prefix=$(PORTLIBS) + CFLAGS="$(filter-out -ffast-math,$(CFLAGS)) -DSQLITE_OS_OTHER=1" ./configure --disable-shared --disable-threadsafe --disable-dynamic-extensions --host=arm-none-eabi --prefix=$(PORTLIBS_PATH)/armv6k # avoid building sqlite3 shell @$(MAKE) -C $(SQLITE_VERSION) libsqlite3.la +# tinyxml2 uses cmake +$(TINYXML): $(TINYXML_SRC) + @[ -d $(TINYXML_VERSION) ] || tar -xzf $< + @cd $(TINYXML_VERSION) && cmake -DCMAKE_SYSTEM_NAME=Generic -DCMAKE_C_COMPILER=$(DEVKITARM)/bin/arm-none-eabi-gcc -DCMAKE_CXX_COMPILER=$(DEVKITARM)/bin/arm-none-eabi-g++ -DCMAKE_INSTALL_PREFIX=$(PORTLIBS_PATH)/armv6k -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_CXX_FLAGS="$(CFLAGS) -fno-exceptions -fno-rtti" . && make + +$(TREMOR): $(TREMOR_SRC) + @[ -d $(TREMOR_VERSION) ] || tar -xzf $< + @cd $(TREMOR_VERSION) && \ + ./autogen.sh --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --disable-oggtest + @$(MAKE) -C $(TREMOR_VERSION) + +$(XZ): $(XZ_SRC) + @[ -d $(XZ_VERSION) ] || tar -xJf $< + @cd $(XZ_VERSION) && \ + ./configure --prefix=$(PORTLIBS_PATH)/armv6k --host=arm-none-eabi --disable-shared --enable-static --disable-xz --enable-threads=no + @$(MAKE) -C $(XZ_VERSION) + $(ZLIB): $(ZLIB_SRC) - @[ -d $(ZLIB_VERSION) ] || tar -xf $< + @[ -d $(ZLIB_VERSION) ] || tar -xzf $< @cd $(ZLIB_VERSION) && \ - CHOST=arm-none-eabi ./configure --static --prefix=$(PORTLIBS) + CHOST=arm-none-eabi ./configure --static --prefix=$(PORTLIBS_PATH)/armv6k @$(MAKE) -C $(ZLIB_VERSION) - @make create_build_dir - @cp -sf $(CURDIR)/$(ZLIB_VERSION)/*.h $(CURDIR)/build/include - @cp -sf $(CURDIR)/$(ZLIB_VERSION)/libz.a $(CURDIR)/build/lib/libz.a - -$(LIBOGG): $(LIBOGG_SRC) - @[ -d $(LIBOGG_VERSION) ] || tar -xf $< - @cd $(LIBOGG_VERSION) && \ - ./configure --prefix=$(PORTLIBS) --host=arm-none-eabi --disable-shared --enable-static - @$(MAKE) -C $(LIBOGG_VERSION) - @make create_build_dir - @cp -srf $(CURDIR)/$(LIBOGG_VERSION)/include/. $(CURDIR)/build/include - @cp -sf $(CURDIR)/$(LIBOGG_VERSION)/src/.libs/*.a $(CURDIR)/build/lib - -$(LIBVORBIS): $(LIBVORBIS_SRC) - @[ -d $(LIBVORBIS_VERSION) ] || tar -xf $< - @cd $(LIBVORBIS_VERSION) && \ - ./configure --prefix=$(PORTLIBS) --host=arm-none-eabi --disable-shared --enable-static - @$(MAKE) -C $(LIBVORBIS_VERSION) - @make create_build_dir - @cp -srf $(CURDIR)/$(LIBVORBIS_VERSION)/include/. $(CURDIR)/build/include - @cp -sf $(CURDIR)/$(LIBVORBIS_VERSION)/lib/.libs/*.a $(CURDIR)/build/lib - -# Downloads -$(ZLIB_SRC): - wget -O $@ $(ZLIB_DOWNLOAD) - -$(FREETYPE_SRC): - wget -O $@ $(FREETYPE_DOWNLOAD) - -$(LIBEXIF_SRC): - wget -O $@ $(LIBEXIF_DOWNLOAD) - -$(LIBJPEGTURBO_SRC): - wget -O $@ $(LIBJPEGTURBO_DOWNLOAD) - -$(LIBPNG_SRC): - wget -O $@ $(LIBPNG_DOWNLOAD) - -$(SQLITE_SRC): - wget -O $@ $(SQLITE_DOWNLOAD) - -$(LIBOGG_SRC): - wget -O $@ $(LIBOGG_DOWNLOAD) - -$(LIBVORBIS_SRC): - wget -O $@ $(LIBVORBIS_DOWNLOAD) install-zlib: @$(MAKE) -C $(ZLIB_VERSION) install install: + @if [ -d $(BZIP2_VERSION) ]; then \ + cp -fv $(BZIP2_VERSION)/bzlib.h $(PORTLIBS_PATH)/armv6k/include; \ + chmod a+r $(PORTLIBS_PATH)/armv6k/include/bzlib.h; \ + cp -fv $(BZIP2_VERSION)/libbz2.a $(PORTLIBS_PATH)/armv6k/lib; \ + chmod a+r $(PORTLIBS_PATH)/armv6k/lib/libbz2.a; \ + fi @[ ! -d $(FREETYPE_VERSION) ] || $(MAKE) -C $(FREETYPE_VERSION) install + @[ ! -d $(GIFLIB_VERSION) ] || $(MAKE) -C $(GIFLIB_VERSION) install + @[ ! -d $(JANSSON_VERSION) ] || $(MAKE) -C $(JANSSON_VERSION) install + @[ ! -d $(LIBCONFIG_VERSION) ] || $(MAKE) -C $(LIBCONFIG_VERSION)/lib install @[ ! -d $(LIBEXIF_VERSION) ] || $(MAKE) -C $(LIBEXIF_VERSION) install @[ ! -d $(LIBJPEGTURBO_VERSION) ] || $(MAKE) -C $(LIBJPEGTURBO_VERSION) install - @[ ! -d $(LIBPNG_VERSION) ] || $(MAKE) -C $(LIBPNG_VERSION) install - @[ ! -d $(SQLITE_VERSION) ] || $(MAKE) -C $(SQLITE_VERSION) install-libLTLIBRARIES install-data + @[ ! -d $(LIBMAD_VERSION) ] || $(MAKE) -C $(LIBMAD_VERSION) install @[ ! -d $(LIBOGG_VERSION) ] || $(MAKE) -C $(LIBOGG_VERSION) install - @[ ! -d $(LIBVORBIS_VERSION) ] || $(MAKE) -C $(LIBVORBIS_VERSION) install + @[ ! -d $(LIBPNG_VERSION) ] || $(MAKE) -C $(LIBPNG_VERSION) install + @[ ! -d $(LIBXML2_VERSION) ] || $(MAKE) -C $(LIBXML2_VERSION) install + @[ ! -d $(LIBXMP_LITE_VERSION) ] || $(MAKE) -C $(LIBXMP_LITE_VERSION) install + @[ ! -d $(MBED_VERSION) ] || $(MAKE) -C $(MBED_VERSION) install + @[ ! -d $(SQLITE_VERSION) ] || $(MAKE) -C $(SQLITE_VERSION) install-libLTLIBRARIES install-data + @[ ! -d $(TINYXML_VERSION) ] || $(MAKE) -C $(TINYXML_VERSION) install + @[ ! -d $(TREMOR_VERSION) ] || $(MAKE) -C $(TREMOR_VERSION) install + @[ ! -d $(XZ_VERSION) ] || $(MAKE) -C $(XZ_VERSION) install clean: + @$(RM) -r $(BZIP2_VERSION) @$(RM) -r $(FREETYPE_VERSION) + @$(RM) -r $(GIFLIB_VERSION) + @$(RM) -r $(JANSSON_VERSION) + @$(RM) -r $(LIBCONFIG_VERSION) @$(RM) -r $(LIBEXIF_VERSION) @$(RM) -r $(LIBJPEGTURBO_VERSION) - @$(RM) -r $(LIBPNG_VERSION) - @$(RM) -r $(SQLITE_VERSION) - @$(RM) -r $(ZLIB_VERSION) + @$(RM) -r $(LIBMAD_VERSION) @$(RM) -r $(LIBOGG_VERSION) - @$(RM) -r $(LIBVORBIS_VERSION) - @rm -rf $(CURDIR)/build - @rm -f $(CURDIR)/*.tar.* + @$(RM) -r $(LIBPNG_VERSION) + @$(RM) -r $(LIBXML2_VERSION) + @$(RM) -r $(LIBXMP_LITE_VERSION) + @$(RM) -r $(MBED_VERSION) + @$(RM) -r $(SQLITE_VERSION) + @$(RM) -r $(TINYXML_VERSION) + @$(RM) -r $(TREMOR_VERSION) + @$(RM) -r $(XZ_VERSION) + @$(RM) -r $(ZLIB_VERSION) diff --git a/libs/3ds_portlibs/README.md b/libs/3ds_portlibs/README.md index 0e7e574..47562dd 100644 --- a/libs/3ds_portlibs/README.md +++ b/libs/3ds_portlibs/README.md @@ -1,18 +1,8 @@ 3DS Portlibs ============ -Here is a Makefile for building various portlibs for 3DS. - -Type: - - $ make -or: - - $ make all - -to download and install all the libraries at once. - -You can build and install the libraries separately: +Here is a Makefile for building various portlibs for 3DS. You need to first +build zlib and install it. Then you can build the other portlibs. $ make zlib $ make install-zlib @@ -25,18 +15,42 @@ install` in order for the portlibs to be installed. Currently supports the following portlibs: +* bzip2 * freetype (requires zlib) +* giflib +* jansson +* libconfig * libexif * libjpeg-turbo +* libmad +* libogg * libpng (requires zlib) +* libxml2 +* libxmp-lite +* mbedtls (requires zlib) (without net component) * sqlite +* tinyxml2 +* tremor (requires libogg) +* xz * zlib Download links: -* [freetype-2.5.5.tar.bz2] (http://download.savannah.gnu.org/releases/freetype/freetype-2.5.5.tar.bz2) +* [bzip2-1.0.6] (http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz) +* [freetype-2.6.2.tar.bz2] (http://download.savannah.gnu.org/releases/freetype/freetype-2.6.2.tar.bz2) +* [giflib-5.1.1] (http://sourceforge.net/projects/giflib/files/giflib-5.1.1.tar.bz2) +* [jansson-v2.7.tar.gz] (https://github.com/akheron/jansson/archive/v2.7.tar.gz) +* [libconfig-1.5] (http://www.hyperrealm.com/libconfig/libconfig-1.5.tar.gz) * [libexif-0.6.21.tar.bz2] (http://sourceforge.net/projects/libexif/files/libexif/0.6.21/libexif-0.6.21.tar.bz2/download) -* [libjpeg-turbo-1.4.0.tar.gz] (http://sourceforge.net/projects/libjpeg-turbo/files/1.4.0/libjpeg-turbo-1.4.0.tar.gz/download) -* [libpng-1.6.17.tar.xz] (http://prdownloads.sourceforge.net/libpng/libpng-1.6.17.tar.xz?download) -* [sqlite-autoconf-3081002.tar.gz] (http://www.sqlite.org/2015/sqlite-autoconf-3081002.tar.gz) +* [libjpeg-turbo-1.4.2.tar.gz] (http://sourceforge.net/projects/libjpeg-turbo/files/1.4.2/libjpeg-turbo-1.4.2.tar.gz/download) +* [libmad-0.15.1b] (http://sourceforge.net/projects/mad/files/libmad/0.15.1b/libmad-0.15.1b.tar.gz) +* [libogg-1.3.2] (http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz) +* [libpng-1.6.21.tar.xz] (http://prdownloads.sourceforge.net/libpng/libpng-1.6.21.tar.xz?download) +* [libxml2-2.9.3] (http://xmlsoft.org/sources/libxml2-2.9.3.tar.gz) +* [libxmp-lite-4.3.10.tar.gz](http://sourceforge.net/projects/xmp/files/libxmp/4.3.10/libxmp-lite-4.3.10.tar.gz/download) +* [mbedtls-2.2.1] (https://tls.mbed.org/download/mbedtls-2.2.1-gpl.tgz) +* [sqlite-autoconf-3100200.tar.gz] (https://www.sqlite.org/2016/sqlite-autoconf-3100200.tar.gz) +* [tinyxml2-3.0.0.tar.gz] (https://github.com/leethomason/tinyxml2/archive/3.0.0.tar.gz) +* [tremor-2a1a8f6] (https://git.xiph.org/?p=tremor.git;a=snapshot;h=2a1a8f621e500fdf0749f115e2206f82919560a3;sf=tgz) +* [xz-5.2.2] (http://tukaani.org/xz/xz-5.2.2.tar.xz) * [zlib-1.2.8.tar.gz] (http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz?download) diff --git a/libs/3ds_portlibs/arm-none-eabi-pkg-config b/libs/3ds_portlibs/arm-none-eabi-pkg-config new file mode 100755 index 0000000..2c768e5 --- /dev/null +++ b/libs/3ds_portlibs/arm-none-eabi-pkg-config @@ -0,0 +1,11 @@ +#!/bin/sh + +# reset pkg-config variables to ensure we're not polluted by host libraries + +export PKG_CONFIG_DIR= +export PKG_CONFIG_PATH= +export PKG_CONFIG_SYSROOT_DIR= + +export PKG_CONFIG_LIBDIR=${DEVKITPRO}/portlibs/3ds/lib/pkgconfig:${DEVKITPRO}/portlibs/armv6k/lib/pkgconfig + +exec pkg-config "$@" \ No newline at end of file diff --git a/libs/3ds_portlibs/libmad-0.15.1b.patch b/libs/3ds_portlibs/libmad-0.15.1b.patch new file mode 100644 index 0000000..aa40881 --- /dev/null +++ b/libs/3ds_portlibs/libmad-0.15.1b.patch @@ -0,0 +1,91 @@ +Submitted By: Igor Živković +Date: 2013-07-04 +Initial Package Version: 0.15.1b +Upstream Status: Reported +Origin: Arch Linux packages repository +Description: Fixes compilation on x86-64 and optimization issues. + +diff -Naur libmad-0.15.1b.orig/configure.ac libmad-0.15.1b/configure.ac +--- libmad-0.15.1b.orig/configure.ac 2004-01-23 10:41:32.000000000 +0100 ++++ libmad-0.15.1b/configure.ac 2013-07-04 15:55:09.323764417 +0200 +@@ -124,71 +124,7 @@ + + if test "$GCC" = yes + then +- if test -z "$arch" +- then +- case "$host" in +- i386-*) ;; +- i?86-*) arch="-march=i486" ;; +- arm*-empeg-*) arch="-march=armv4 -mtune=strongarm1100" ;; +- armv4*-*) arch="-march=armv4 -mtune=strongarm" ;; +- powerpc-*) ;; +- mips*-agenda-*) arch="-mcpu=vr4100" ;; +- mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;; +- esac +- fi +- +- case "$optimize" in +- -O|"-O "*) +- optimize="-O" +- optimize="$optimize -fforce-mem" +- optimize="$optimize -fforce-addr" +- : #x optimize="$optimize -finline-functions" +- : #- optimize="$optimize -fstrength-reduce" +- optimize="$optimize -fthread-jumps" +- optimize="$optimize -fcse-follow-jumps" +- optimize="$optimize -fcse-skip-blocks" +- : #x optimize="$optimize -frerun-cse-after-loop" +- : #x optimize="$optimize -frerun-loop-opt" +- : #x optimize="$optimize -fgcse" +- optimize="$optimize -fexpensive-optimizations" +- optimize="$optimize -fregmove" +- : #* optimize="$optimize -fdelayed-branch" +- : #x optimize="$optimize -fschedule-insns" +- optimize="$optimize -fschedule-insns2" +- : #? optimize="$optimize -ffunction-sections" +- : #? optimize="$optimize -fcaller-saves" +- : #> optimize="$optimize -funroll-loops" +- : #> optimize="$optimize -funroll-all-loops" +- : #x optimize="$optimize -fmove-all-movables" +- : #x optimize="$optimize -freduce-all-givs" +- : #? optimize="$optimize -fstrict-aliasing" +- : #* optimize="$optimize -fstructure-noalias" +- +- case "$host" in +- arm*-*) +- optimize="$optimize -fstrength-reduce" +- ;; +- mips*-*) +- optimize="$optimize -fstrength-reduce" +- optimize="$optimize -finline-functions" +- ;; +- i?86-*) +- optimize="$optimize -fstrength-reduce" +- ;; +- powerpc-apple-*) +- # this triggers an internal compiler error with gcc2 +- : #optimize="$optimize -fstrength-reduce" +- +- # this is really only beneficial with gcc3 +- : #optimize="$optimize -finline-functions" +- ;; +- *) +- # this sometimes provokes bugs in gcc 2.95.2 +- : #optimize="$optimize -fstrength-reduce" +- ;; +- esac +- ;; +- esac ++ optimize="-O2" + fi + + case "$host" in +@@ -297,6 +233,7 @@ + then + case "$host" in + i?86-*) FPM="INTEL" ;; ++ x86_64*) FPM="64BIT" ;; + arm*-*) FPM="ARM" ;; + mips*-*) FPM="MIPS" ;; + sparc*-*) FPM="SPARC" ;; diff --git a/libs/3ds_portlibs/libmbedtls-2.2.1.patch b/libs/3ds_portlibs/libmbedtls-2.2.1.patch new file mode 100644 index 0000000..6c9152b --- /dev/null +++ b/libs/3ds_portlibs/libmbedtls-2.2.1.patch @@ -0,0 +1,12 @@ +diff -Naur mbedtls-2.2.1/include/mbedtls/config.h mbedtls-2.2.1-mod/include/mbedtls/config.h +--- mbedtls-2.2.1/include/mbedtls/config.h 2016-01-04 20:38:18.000000000 -0800 ++++ mbedtls-2.2.1-mod/include/mbedtls/config.h 2016-05-21 11:43:29.887604004 -0700 +@@ -1905,7 +1905,7 @@ + * + * This module provides TCP/IP networking routines. + */ +-#define MBEDTLS_NET_C ++//#define MBEDTLS_NET_C + + /** + * \def MBEDTLS_OID_C diff --git a/source/ctr.c b/source/ctr.c index dd34ff3..957861d 100644 --- a/source/ctr.c +++ b/source/ctr.c @@ -10,6 +10,7 @@ The `ctr` module. #include <3ds/services/apt.h> #include <3ds/os.h> #include <3ds/svc.h> +#include <3ds/services/hb.h> #include #include @@ -252,6 +253,18 @@ int luaopen_ctr_lib(lua_State *L) { #endif lua_pushstring(L, buff); lua_setfield(L, -2, "root"); + + /*** + Whether or not ctrµLua has been launched with ninjhax + @field hb + */ + if (!hbInit()) { + hbExit(); + lua_pushboolean(L, true); + } else { + lua_pushboolean(L, false); + } + lua_setfield(L, -2, "hb"); return 1; } diff --git a/source/main.c b/source/main.c index 33febb3..8bbfc38 100644 --- a/source/main.c +++ b/source/main.c @@ -1,4 +1,6 @@ #include +#include +#include #include <3ds.h> @@ -42,6 +44,13 @@ int main(int argc, char** argv) { char* mainFile = "main.lua"; #endif + // Change root dir + #ifdef ROOT + if(chdir(ROOT)) { + error(strerror(errno)); + } + #endif + // Init Lua lua_State *L = luaL_newstate(); if (L == NULL) { diff --git a/source/thread.c b/source/thread.c index eb46fa2..6563187 100644 --- a/source/thread.c +++ b/source/thread.c @@ -306,14 +306,9 @@ void load_thread_lib(lua_State *L) { //////////////////////////////////////////////////////////////////////////////// // Pool lib for accessing the pool from the thread // // Libception // +// Documentation is in thread.pool.doc.c, because LDoc // //////////////////////////////////////////////////////////////////////////////// -/*** -The `pool` module. Only accessible from a sub-thread. -@module ctr.thread.pool -@usage local pool = require("ctr.thread.pool") -*/ - static int pool_set(lua_State *L) { lua_getfield(L, LUA_REGISTRYINDEX, "LThreadSelf"); thread_userdata* thread = (thread_userdata*)lua_tointeger(L, -1); diff --git a/source/thread.pool.h b/source/thread.pool.h new file mode 100644 index 0000000..ef19baf --- /dev/null +++ b/source/thread.pool.h @@ -0,0 +1,21 @@ +// This is a documentation file, not a header. But LDoc. + +/*** +The `thread.pool` module. Only accessible from a sub-thread. +@module ctr.thread.pool +@usage local pool = require("ctr.thread.pool") +*/ + +/*** +Set a value in the thread's pool. +@function set +@tparam integer index +@param value anything but a table/userdata +*/ + +/*** +Get a value from the thread's pool. +@function get +@tparam integer index +@return the value stored +*/ diff --git a/source/uds.c b/source/uds.c index 3139fbf..9d4397d 100644 --- a/source/uds.c +++ b/source/uds.c @@ -16,6 +16,8 @@ The default wlancommID is 0x637472c2. #include #include +#define DEFAULT_WLANCOMMID 0x637472c2 + bool initStateUDS = false; udsBindContext bind = {0}; @@ -73,11 +75,16 @@ Scan for network beacons. static int uds_scan(lua_State *L) { static const size_t tmpbuffSize = 0x4000; u32* tmpbuff = malloc(tmpbuffSize); + if (tmpbuff == NULL) { + lua_pushnil(L); + lua_pushstring(L, "Failed to allocated beacon data buffer"); + return 2; + } udsNetworkScanInfo* networks = NULL; size_t totalNetworks = 0; - u32 wlanCommID = luaL_optinteger(L, 1, 0x637472c2); + u32 wlanCommID = luaL_optinteger(L, 1, DEFAULT_WLANCOMMID); u8 id8 = luaL_optinteger(L, 2, 0); // MAC address conversion @@ -117,7 +124,7 @@ static int uds_scan(lua_State *L) { udsNetworkScanInfo* beacon = lua_newuserdata(L, sizeof(udsNetworkScanInfo)); luaL_getmetatable(L, "LUDSBeaconScan"); lua_setmetatable(L, -2); - memcpy(beacon, &networks[0], sizeof(udsNetworkScanInfo)); + memcpy(beacon, &networks[i-1], sizeof(udsNetworkScanInfo)); lua_seti(L, -3, i); } free(networks); @@ -294,12 +301,12 @@ static int uds_createNetwork(lua_State *L) { size_t passSize = 0; const char *pass = luaL_optlstring(L, 1, "", &passSize); u8 maxNodes = luaL_optinteger(L, 2, UDS_MAXNODES); - u32 commID = luaL_optinteger(L, 3, 0x637472c2); + u32 commID = luaL_optinteger(L, 3, DEFAULT_WLANCOMMID); u32 recvBuffSize = luaL_optinteger(L, 4, UDS_DEFAULT_RECVBUFSIZE); u8 dataChannel = luaL_optinteger(L, 5, 1); udsGenerateDefaultNetworkStruct(&network, commID, dataChannel, maxNodes); - Result ret = udsCreateNetwork(&network, pass, passSize, &bind, dataChannel, recvBuffSize); + Result ret = udsCreateNetwork(&network, pass, passSize+1, &bind, dataChannel, recvBuffSize); if (R_FAILED(ret)) { lua_pushboolean(L, false); lua_pushinteger(L, ret);