diff options
| author | John "Lameguy" Wilbert Villamor <lameguy64@gmail.com> | 2021-08-31 13:23:20 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-31 13:23:20 +0800 |
| commit | ffa679d4d24b891cb59aba10946368f2ec00c391 (patch) | |
| tree | 0cf6061915ebf48acdedf6d77b0c1b76eec5b8c3 /examples/demos | |
| parent | 317dc2b91d3afcdbaddb035f38611d12af161970 (diff) | |
| parent | f2fc18f82dd7900465d6ab3ae2080726d5589d39 (diff) | |
| download | psn00bsdk-ffa679d4d24b891cb59aba10946368f2ec00c391.tar.gz | |
Merge pull request #36 from spicyjpeg/dynlink
Dynamic linker, gp-relative addressing, ldscripts and more
Diffstat (limited to 'examples/demos')
| -rw-r--r-- | examples/demos/n00bdemo/data.s | 2 | ||||
| -rw-r--r-- | examples/demos/n00bdemo/data.xml | 6 | ||||
| -rw-r--r-- | examples/demos/n00bdemo/makefile | 82 |
3 files changed, 58 insertions, 32 deletions
diff --git a/examples/demos/n00bdemo/data.s b/examples/demos/n00bdemo/data.s index 3ca33cb..f3b2a83 100644 --- a/examples/demos/n00bdemo/data.s +++ b/examples/demos/n00bdemo/data.s @@ -3,7 +3,7 @@ .global lz_resources .type lz_resources, @object lz_resources: - .incbin "data.lzp" + .incbin "build/data.lzp" #.global smd_mtekdisk #.type smd_mtekdisk, @object diff --git a/examples/demos/n00bdemo/data.xml b/examples/demos/n00bdemo/data.xml index 292a325..6761f16 100644 --- a/examples/demos/n00bdemo/data.xml +++ b/examples/demos/n00bdemo/data.xml @@ -1,6 +1,6 @@ <lzp_project> - <create packname="textures.qlp" format="qlp"> + <create packname="build/textures.qlp" format="qlp"> <file alias="petscum">data/petscum16c.tim</file> <file alias="bungirl">data/bungirl.tim</file> @@ -19,7 +19,7 @@ </create> - <create packname="data.lzp" format="lzp"> + <create packname="build/data.lzp" format="lzp"> <!-- intro assets --> <file alias="mtekdisk">data/mtekdisk.smd</file> @@ -42,7 +42,7 @@ <file alias="hatkid">data/hatkid.smd</file> <!-- Global textures --> - <file alias="textures">textures.qlp</file> + <file alias="textures">build/textures.qlp</file> </create> diff --git a/examples/demos/n00bdemo/makefile b/examples/demos/n00bdemo/makefile index 7e3bd8e..9206e09 100644 --- a/examples/demos/n00bdemo/makefile +++ b/examples/demos/n00bdemo/makefile @@ -1,39 +1,65 @@ -include ../../examples-setup.mk +# PSn00bSDK makefile template +# Part of the PSn00bSDK Project +# 2019 - 2021 Lameguy64 / Meido-Tek Productions -TARGET = demo.elf +## Settings -CFILES = $(notdir $(wildcard *.c)) -AFILES = $(notdir $(wildcard *.s)) +PSN00BSDK_LIBS ?= ../../../libpsn00b -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o)) +# Edit this to point to psn00bsdk-setup.mk, or copy that over to your project's +# root folder (it only depends on environment variables). +include ../../../psn00bsdk-setup.mk -INCLUDE += -I../../../libpsn00b/lzp +# Project target name +TARGET = demo -LIBS = -llzp -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc +## Files -CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections -CPPFLAGS = $(CFLAGS) -fno-exceptions -AFLAGS = -g -msoft-float -LDFLAGS = -g -Ttext=0x80010000 -gc-sections -T $(GCC_BASE)/$(PREFIX)/lib/ldscripts/elf32elmip.x +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CPPFILES= $(notdir $(wildcard *.cpp)) +AFILES = $(notdir $(wildcard *.s)) + +# Create names for object files +OFILES = $(addprefix build/,$(CFILES:.c=.o)) \ + $(addprefix build/,$(CPPFILES:.cpp=.o)) \ + $(addprefix build/,$(AFILES:.s=.o)) + +# Project specific includes and libraries +# (use -I for include dirs, -L for library dirs, -l for static libraries) +INCLUDE += +LIBDIRS += +LIBS += -llzp + +## Build rules + +#all: iso +all: build/$(TARGET) + +iso: build/$(TARGET) + $(MKPSXISO) -y -q iso.xml + +resources: + $(LZPACK) data.xml + touch data.s + +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@ + $(NM) -f posix -l -n $@ >$@.map + $(ELF2X) -q $@ $@.exe -all: resources $(OFILES) - $(LD) $(LDFLAGS) $(LIBDIRS) $(OFILES) $(LIBS) -o $(TARGET) - elf2x -q $(TARGET) - build/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ - -build/%.o: %.s + $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@ + +build/%.o: %.cpp @mkdir -p $(dir $@) - $(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@ - -resources: - lzpack data.xml - touch data.s - -iso: - mkpsxiso -y -q -o demo.iso iso.xml - + $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@ + +build/%.o: %.s resources + @mkdir -p $(dir $@) + $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@ + clean: - rm -rf build *.lzp *.qlp $(TARGET) $(TARGET:.elf=.exe) $(TARGET:.elf=.iso) + rm -rf build |
