aboutsummaryrefslogtreecommitdiff
path: root/examples/system
diff options
context:
space:
mode:
authorspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-08-17 11:36:56 +0000
committerspicyjpeg <88942473+spicyjpeg@users.noreply.github.com>2021-08-17 11:36:56 +0000
commit89751f29467b359339a8c8b57c218cc3328bae43 (patch)
treef92eeff576fea528e6a5c5a984207aac9e0d2b8c /examples/system
parent5f5461879c73720359e87fa41cbfe8c452f5155e (diff)
downloadpsn00bsdk-89751f29467b359339a8c8b57c218cc3328bae43.tar.gz
Rewritten all Makefiles, set up proper GCC options, added iso.xml to template
Diffstat (limited to 'examples/system')
-rw-r--r--examples/system/childexec/child/child.c (renamed from examples/system/childexec/child.c)0
-rw-r--r--examples/system/childexec/child_exe.s2
-rw-r--r--examples/system/childexec/makefile105
-rw-r--r--examples/system/console/makefile81
-rw-r--r--examples/system/timer/makefile76
-rw-r--r--examples/system/tty/makefile81
6 files changed, 227 insertions, 118 deletions
diff --git a/examples/system/childexec/child.c b/examples/system/childexec/child/child.c
index 2ddfa73..2ddfa73 100644
--- a/examples/system/childexec/child.c
+++ b/examples/system/childexec/child/child.c
diff --git a/examples/system/childexec/child_exe.s b/examples/system/childexec/child_exe.s
index 842ac88..66bd0e2 100644
--- a/examples/system/childexec/child_exe.s
+++ b/examples/system/childexec/child_exe.s
@@ -3,4 +3,4 @@
.global child_exe # Insert spoopypasta
.type child_exe, @object
child_exe:
- .incbin "child.exe" \ No newline at end of file
+ .incbin "build/child/child.exe" \ No newline at end of file
diff --git a/examples/system/childexec/makefile b/examples/system/childexec/makefile
index 30229ae..e801739 100644
--- a/examples/system/childexec/makefile
+++ b/examples/system/childexec/makefile
@@ -1,36 +1,93 @@
-include ../../examples-setup.mk
+# PSn00bSDK makefile template
+# Part of the PSn00bSDK Project
+# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-INCLUDE +=
-LIBDIRS +=
+## Settings
-LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
+PSN00BSDK_LIBS ?= ../../../libpsn00b
-CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
-CPPFLAGS = $(CFLAGS) -fno-exceptions
-AFLAGS = -g -msoft-float
-LDFLAGS = -g -gc-sections \
- -T $(GCC_BASE)/$(PREFIX)/lib/ldscripts/elf32elmip.x
+# 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
-LDFLAGS_P = $(LDFLAGS) -Ttext=0x80010000
-LDFLAGS_C = $(LDFLAGS) -Ttext=0x80030000
+# Project target name
+#TARGET = childexec
-all: child parent
+## Files
-child: build/child.o
- $(LD) $(LDFLAGS_C) $(LIBDIRS) build/child.o $(LIBS) -o child.elf
- elf2x -q child.elf
+# Searches for C, C++ and S (assembler) files in local directory
+CFILES_PARENT = $(notdir $(wildcard *.c))
+CPPFILES_PARENT = $(notdir $(wildcard *.cpp))
+AFILES_PARENT = $(notdir $(wildcard *.s))
+
+CFILES_CHILD = $(notdir $(wildcard child/*.c))
+CPPFILES_CHILD = $(notdir $(wildcard child/*.cpp))
+AFILES_CHILD = $(notdir $(wildcard child/*.s))
+
+# Create names for object files
+OFILES_PARENT = $(addprefix build/,$(CFILES_PARENT:.c=.o)) \
+ $(addprefix build/,$(CPPFILES_PARENT:.cpp=.o)) \
+ $(addprefix build/,$(AFILES_PARENT:.s=.o))
+OFILES_CHILD = $(addprefix build/child/,$(CFILES_CHILD:.c=.o)) \
+ $(addprefix build/child/,$(CPPFILES_CHILD:.cpp=.o)) \
+ $(addprefix build/child/,$(AFILES_CHILD:.s=.o))
+
+# Project specific includes and libraries
+# (use -I for include dirs, -L for library dirs, -l for static libraries)
+INCLUDE +=
+LIBDIRS +=
+LIBS +=
+
+# Relocate the child executable to 0x30000
+LDFLAGS_CHILD = -Ttext=0x80030000
+
+## Build rules
+
+#all: iso
+all: build/child/child build/parent
+
+iso: build/child/child build/parent resources
+ $(MKPSXISO) -y -q iso.xml
+
+resources:
+ # Add commands to build/convert your assets here
+ #$(LZPACK) data.xml
+
+build/child/child: $(OFILES_CHILD)
+ @mkdir -p $(dir $@)
+ $(LD) $(LDFLAGS_EXE) $(LDFLAGS_CHILD) $(LIBDIRS) $^ $(LIBS) -o $@
+ $(NM) -f posix -l -n $@ >$@.map
+ $(ELF2X) -q $@ $@.exe
+
+build/parent: $(OFILES_PARENT)
+ @mkdir -p $(dir $@)
+ $(LD) $(LDFLAGS_EXE) $(LIBDIRS) $^ $(LIBS) -o $@
+ $(NM) -f posix -l -n $@ >$@.map
+ $(ELF2X) -q $@ $@.exe
+
+build/child/%.o: child/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS_EXE) $(INCLUDE) -c $< -o $@
+
+build/child/%.o: child/%.cpp
+ @mkdir -p $(dir $@)
+ $(CXX) $(CPPFLAGS_EXE) $(INCLUDE) -c $< -o $@
+
+build/child/%.o: child/%.s
+ @mkdir -p $(dir $@)
+ $(CC) $(AFLAGS_EXE) $(INCLUDE) -c $< -o $@
-parent: build/parent.o build/child_exe.o
- $(LD) $(LDFLAGS_P) $(LIBDIRS) build/parent.o build/child_exe.o $(LIBS) -o parent.elf
- elf2x -q parent.elf
-
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 parent.elf parent.exe child.elf child.exe
+ rm -rf build
diff --git a/examples/system/console/makefile b/examples/system/console/makefile
index 1ee638f..addf02a 100644
--- a/examples/system/console/makefile
+++ b/examples/system/console/makefile
@@ -1,54 +1,65 @@
-include ../../examples-setup.mk
+# PSn00bSDK makefile template
+# Part of the PSn00bSDK Project
+# 2019 - 2021 Lameguy64 / Meido-Tek Productions
+
+## Settings
+
+PSN00BSDK_LIBS ?= ../../../libpsn00b
+
+# 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
# Project target name
-TARGET = console.elf
+TARGET = console
+
+## Files
# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES = $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
+CFILES = $(notdir $(wildcard *.c))
+CPPFILES= $(notdir $(wildcard *.cpp))
+AFILES = $(notdir $(wildcard *.s))
-# Determine object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
+# Create names for object files
+OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
+ $(addprefix build/,$(CPPFILES:.cpp=.o)) \
+ $(addprefix build/,$(AFILES:.s=.o))
-# Project specific include and library directories
-# (use -I for include dirs, -L for library dirs)
-INCLUDE +=
-LIBDIRS +=
+# Project specific includes and libraries
+# (use -I for include dirs, -L for library dirs, -l for static libraries)
+INCLUDE +=
+LIBDIRS +=
+LIBS +=
-# Libraries to link
-LIBS = -lpsxsio -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
+## Build rules
-# C compiler flags
-CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
+#all: iso
+all: build/$(TARGET)
-# C++ compiler flags
-CPPFLAGS = $(CFLAGS) -fno-exceptions
+iso: build/$(TARGET) resources
+ $(MKPSXISO) -y -q iso.xml
-# Assembler flags
-AFLAGS = -g -msoft-float
+resources:
+ # Add commands to build/convert your assets here
+ #$(LZPACK) data.xml
-# Linker flags
-LDFLAGS = -g -Ttext=0x80010000 -gc-sections \
- -T $(GCC_BASE)/$(PREFIX)/lib/ldscripts/elf32elmip.x
+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) $(AFLAGS) $(INCLUDE) -c $< -o $@
-
+ $(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
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
diff --git a/examples/system/tty/makefile b/examples/system/tty/makefile
index 43893d5..381aa41 100644
--- a/examples/system/tty/makefile
+++ b/examples/system/tty/makefile
@@ -1,54 +1,65 @@
-include ../../examples-setup.mk
+# PSn00bSDK makefile template
+# Part of the PSn00bSDK Project
+# 2019 - 2021 Lameguy64 / Meido-Tek Productions
+
+## Settings
+
+PSN00BSDK_LIBS ?= ../../../libpsn00b
+
+# 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
# Project target name
-TARGET = tty.elf
+TARGET = tty
+
+## Files
# Searches for C, C++ and S (assembler) files in local directory
-CFILES = $(notdir $(wildcard *.c))
-CPPFILES = $(notdir $(wildcard *.cpp))
-AFILES = $(notdir $(wildcard *.s))
+CFILES = $(notdir $(wildcard *.c))
+CPPFILES= $(notdir $(wildcard *.cpp))
+AFILES = $(notdir $(wildcard *.s))
-# Determine object files
-OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
- $(addprefix build/,$(CPPFILES:.cpp=.o)) \
- $(addprefix build/,$(AFILES:.s=.o))
+# Create names for object files
+OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
+ $(addprefix build/,$(CPPFILES:.cpp=.o)) \
+ $(addprefix build/,$(AFILES:.s=.o))
-# Project specific include and library directories
-# (use -I for include dirs, -L for library dirs)
-INCLUDE +=
-LIBDIRS +=
+# Project specific includes and libraries
+# (use -I for include dirs, -L for library dirs, -l for static libraries)
+INCLUDE +=
+LIBDIRS +=
+LIBS +=
-# Libraries to link
-LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc
+## Build rules
-# C compiler flags
-CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections
+#all: iso
+all: build/$(TARGET)
-# C++ compiler flags
-CPPFLAGS = $(CFLAGS) -fno-exceptions
+iso: build/$(TARGET) resources
+ $(MKPSXISO) -y -q iso.xml
-# Assembler flags
-AFLAGS = -g -msoft-float
+resources:
+ # Add commands to build/convert your assets here
+ #$(LZPACK) data.xml
-# Linker flags
-LDFLAGS = -g -Ttext=0x80010000 -gc-sections \
- -T $(GCC_BASE)/$(PREFIX)/lib/ldscripts/elf32elmip.x
+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) $(AFLAGS) $(INCLUDE) -c $< -o $@
-
+ $(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