aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxapi
diff options
context:
space:
mode:
Diffstat (limited to 'libpsn00b/psxapi')
-rw-r--r--libpsn00b/psxapi/makefile62
-rw-r--r--libpsn00b/psxapi/sys/flushcache.s10
2 files changed, 51 insertions, 21 deletions
diff --git a/libpsn00b/psxapi/makefile b/libpsn00b/psxapi/makefile
index 0b0d603..f300e5f 100644
--- a/libpsn00b/psxapi/makefile
+++ b/libpsn00b/psxapi/makefile
@@ -1,41 +1,61 @@
-# Run using make (Linux) or gmake (BSD)
+# PSn00bSDK library makefile
# Part of the PSn00bSDK Project
-# 2019 - 2020 Lameguy64 / Meido-Tek Productions
+# 2019 - 2021 Lameguy64 / Meido-Tek Productions
-include ../../template/psn00bsdk-setup.mk
+## Settings
-TARGET = libpsxapi.a
+PSN00BSDK_LIBS ?= ..
-INCLUDE = -I../include
+include ../../psn00bsdk-setup.mk
-SOURCES = stdio fs sys
+# Project target name
+TARGET = libpsxapi.a
-AFILES = $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.s))
-OFILES = $(addprefix build/,$(AFILES:.s=.o))
+## Files
-AFLAGS = -g -msoft-float -Wa,--strip-local-absolute
+SOURCES = stdio fs sys
-ifndef PSN00BSDK_LIBS
+# Searches for C, C++ and S (assembler) files in local directory
+CFILES = $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
+CXXFILES= $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.cxx))
+AFILES = $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.s))
-PSN00BSDK_LIBS = ..
+# Create names for object files
+OFILES = $(addprefix build/,$(CFILES:.c=.o)) \
+ $(addprefix build/,$(CXXFILES:.cxx=.o)) \
+ $(addprefix build/,$(AFILES:.s=.o))
-endif
+# Project specific includes and libraries
+# (use -I for include dirs, -L for library dirs, -l for static libraries)
+INCLUDE +=
+LIBDIRS +=
+LIBS +=
-all: $(TARGET)
-
-$(TARGET): $(OFILES)
- $(AR) cr $(TARGET) $(OFILES)
- $(RANLIB) $(TARGET)
+## Build rules
+
+all: build/$(TARGET)
+
+build/$(TARGET): $(OFILES)
+ @mkdir -p $(dir $@)
+ $(AR) crs $@ $(OFILES)
+
+build/%.o: %.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@
+
+build/%.o: %.cxx
+ @mkdir -p $(dir $@)
+ $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@
build/%.o: %.s
@mkdir -p $(dir $@)
- $(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@
+ $(CC) $(AFLAGS_LIB) $(INCLUDE) -c $< -o $@
install:
ifneq ($(PSN00BSDK_LIBS), "..")
@mkdir -p $(PSN00BSDK_LIBS)
endif
- cp $(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
-
+ cp build/$(TARGET) $(PSN00BSDK_LIBS)/$(TARGET)
+
clean:
- rm -Rf build $(TARGET)
+ rm -rf build
diff --git a/libpsn00b/psxapi/sys/flushcache.s b/libpsn00b/psxapi/sys/flushcache.s
new file mode 100644
index 0000000..7eeb510
--- /dev/null
+++ b/libpsn00b/psxapi/sys/flushcache.s
@@ -0,0 +1,10 @@
+.set noreorder
+
+.section .text
+
+.global FlushCache
+.type FlushCache, @function
+FlushCache:
+ addiu $t2, $0, 0xa0
+ jr $t2
+ addiu $t1, $0, 0x44