aboutsummaryrefslogtreecommitdiff
path: root/examples/system/timer
diff options
context:
space:
mode:
authorJohn "Lameguy" Wilbert Villamor <lameguy64@gmail.com>2021-08-31 13:23:20 +0800
committerGitHub <noreply@github.com>2021-08-31 13:23:20 +0800
commitffa679d4d24b891cb59aba10946368f2ec00c391 (patch)
tree0cf6061915ebf48acdedf6d77b0c1b76eec5b8c3 /examples/system/timer
parent317dc2b91d3afcdbaddb035f38611d12af161970 (diff)
parentf2fc18f82dd7900465d6ab3ae2080726d5589d39 (diff)
downloadpsn00bsdk-ffa679d4d24b891cb59aba10946368f2ec00c391.tar.gz
Merge pull request #36 from spicyjpeg/dynlink
Dynamic linker, gp-relative addressing, ldscripts and more
Diffstat (limited to 'examples/system/timer')
-rw-r--r--examples/system/timer/makefile76
1 files changed, 53 insertions, 23 deletions
diff --git a/examples/system/timer/makefile b/examples/system/timer/makefile
index a8defe7..c418af4 100644
--- a/examples/system/timer/makefile
+++ b/examples/system/timer/makefile
@@ -1,35 +1,65 @@
-include ../../examples-setup.mk
+# PSn00bSDK makefile template
+# Part of the PSn00bSDK Project
+# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-TARGET = timer.elf
+## Settings
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES = $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
+PSN00BSDK_LIBS ?= ../../../libpsn00b
-OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CPPFILES:.cpp=.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 +=
-LIBDIRS +=
+# Project target name
+TARGET = timer
-LIBS = -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 +=
+
+## Build rules
+
+#all: iso
+all: build/$(TARGET)
+
+iso: build/$(TARGET) resources
+ $(MKPSXISO) -y -q iso.xml
+
+resources:
+ # Add commands to build/convert your assets here
+ #$(LZPACK) data.xml
+
+build/$(TARGET): $(OFILES)
+ @mkdir -p $(dir $@)
+ $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
+ $(NM) -f posix -l -n $@ >$@.map
+ $(ELF2X) -q $@ $@.exe
-all: $(OFILES)
- $(LD) $(LDFLAGS) $(LIBDIRS) $(OFILES) $(LIBS) -o $(TARGET)
- elf2x -q $(TARGET)
-
build/%.o: %.c
@mkdir -p $(dir $@)
- $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
-
+ $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
+
+build/%.o: %.cpp
+ @mkdir -p $(dir $@)
+ $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
+
build/%.o: %.s
@mkdir -p $(dir $@)
- $(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@
-
+ $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
+
clean:
- rm -rf build $(TARGET) $(TARGET:.elf=.exe)
+ rm -rf build