diff options
| author | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-08-17 11:36:56 +0000 |
|---|---|---|
| committer | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2021-08-17 11:36:56 +0000 |
| commit | 89751f29467b359339a8c8b57c218cc3328bae43 (patch) | |
| tree | f92eeff576fea528e6a5c5a984207aac9e0d2b8c /libpsn00b | |
| parent | 5f5461879c73720359e87fa41cbfe8c452f5155e (diff) | |
| download | psn00bsdk-89751f29467b359339a8c8b57c218cc3328bae43.tar.gz | |
Rewritten all Makefiles, set up proper GCC options, added iso.xml to template
Diffstat (limited to 'libpsn00b')
| -rw-r--r-- | libpsn00b/ldscripts/dll.ld | 122 | ||||
| -rw-r--r-- | libpsn00b/ldscripts/exe.ld | 114 | ||||
| -rw-r--r-- | libpsn00b/libc/makefile | 59 | ||||
| -rw-r--r-- | libpsn00b/lzp/makefile | 61 | ||||
| -rw-r--r-- | libpsn00b/psxapi/makefile | 62 | ||||
| -rw-r--r-- | libpsn00b/psxcd/makefile | 57 | ||||
| -rw-r--r-- | libpsn00b/psxetc/makefile | 59 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/makefile | 57 | ||||
| -rw-r--r-- | libpsn00b/psxgte/makefile | 57 | ||||
| -rw-r--r-- | libpsn00b/psxsio/makefile | 57 | ||||
| -rw-r--r-- | libpsn00b/psxspu/makefile | 61 |
11 files changed, 563 insertions, 203 deletions
diff --git a/libpsn00b/ldscripts/dll.ld b/libpsn00b/ldscripts/dll.ld new file mode 100644 index 0000000..59cbb53 --- /dev/null +++ b/libpsn00b/ldscripts/dll.ld @@ -0,0 +1,122 @@ +/* + * PSn00bSDK linker script for dynamically-loaded libraries + * (C) 2021 spicyjpeg - MPL licensed + * + * This script is similar to the one for executables. The main differences are + * the header at the beginning of the file, the .sdata/.sbss sections being + * replaced by the global offset table (GOT) and .bss being merged with .data. + */ + +OUTPUT_FORMAT(elf32-littlemips) +/*ENTRY(_start) +STARTUP(start.o)*/ + +MEMORY { + /* Code is position-independent, so we just set zero as address */ + RELOC_RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 1M +} + +SECTIONS { + /* + * DLL "header", containing the following sections: + * + * .dynamic: key-value pairs describing various section offsets, flags and + * other stuff + * .dynsym: dynamic symbol table, listing all functions to relocate as well + * as exported symbols + * .hash: pre-generated hash table to quickly look up symbol table + * entries by their names + * .dynstr: string blob referenced by symbol table entries + */ + + .dynamic : { *(.dynamic) } > RELOC_RAM + .dynsym : { *(.dynsym) } > RELOC_RAM + .hash : { *(.hash) } > RELOC_RAM + .dynstr : { *(.dynstr) } > RELOC_RAM + + /* Text section, i.e. code and constants */ + + .text : ALIGN(16) { + __text_start = .; + + *(.text .text.* .gnu.linkonce.t.*) + *(.plt .MIPS.stubs) + } > RELOC_RAM + .rodata : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + } > RELOC_RAM + + /* Global constructor and destructor arrays (length-prefixed) */ + + /* + * https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770 + */ + .ctors : ALIGN(16) { + __CTOR_LIST__ = .; + + LONG(((__CTOR_END__ - __CTOR_LIST__) / 4) - 2) + KEEP(*(SORT(.ctors.*))) + KEEP(*(.ctors)) + LONG(0) + + __CTOR_END__ = .; + } > RELOC_RAM + .dtors : ALIGN(16) { + __DTOR_LIST__ = .; + + LONG(((__DTOR_END__ - __DTOR_LIST__) / 4) - 2) + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + LONG(0) + + __DTOR_END__ = .; + } > RELOC_RAM + + /* Data and BSS sections, i.e. variables */ + + .data : { + *(.data .data.* .gnu.linkonce.d.*) + + /* + * Merge the .bss section into the .data section, so uninitialized + * variables are treated as if they were initialized and preallocated. + * This makes DLLs unnecessarily larger (BSS values shouldn't be stored + * as they are always zero) but greatly simplifies the dynamic linker, + * as we don't have to worry about managing .bss separately from the + * main DLL blob. + */ + __bss_start = .; + + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + + . = ALIGN((. != 0) ? 4 : 1); + } > RELOC_RAM + + /* + * Set _gp to point to the beginning of the GOT plus 0x7ff0, so anything + * within the GOT can be accessed using the $gp register as base plus a + * signed 16-bit immediate. Note that $gp is set to _gp in all exported + * functions (GCC adds the relevant code automatically). + */ + HIDDEN(_gp = ALIGN(16) + 0x7ff0); + + .got : { + *(.got) + } > RELOC_RAM + + _end = .; + + /* Dummy section */ + + .dummy (NOLOAD) : { + KEEP(*(.dummy)) + } > RELOC_RAM + + /* Remove anything flagged as link-time optimized */ + + /DISCARD/ : { + *(.gnu.lto_*) + } +} diff --git a/libpsn00b/ldscripts/exe.ld b/libpsn00b/ldscripts/exe.ld new file mode 100644 index 0000000..3033636 --- /dev/null +++ b/libpsn00b/ldscripts/exe.ld @@ -0,0 +1,114 @@ +/* + * PSn00bSDK linker script for executables + * (C) 2021 spicyjpeg - MPL licensed + * + * GP-relative addressing (i.e. placing small variables in a 64 KB block and + * using $gp to reference them) is fully supported; the block is made up of + * sections .sdata and .sbss. Note that GP-relative addressing is not + * compatible with dynamic linking, as DLLs require GP to be unused. + */ + +OUTPUT_FORMAT(elf32-littlemips) +ENTRY(_start) +/*STARTUP(start.o)*/ + +MEMORY { + /* Mapped into KSEG0 */ + KERNEL_RAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x010000 + APP_RAM (rwx) : ORIGIN = 0x80010000, LENGTH = 0x1f0000 +} + +SECTIONS { + /* Text section, i.e. code and constants */ + + .text : { + __text_start = .; + + *(.text .text.* .gnu.linkonce.t.*) + *(.plt .MIPS.stubs) + } > APP_RAM + .rodata : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + } > APP_RAM + + /* Global constructor and destructor arrays (length-prefixed) */ + + /* + * TODO: replace this crap with .init_array and .fini_array, which are the + * "modern" way of doing it without reversed arrays and weird length + * prefixes. That would require even more patching though. + * + * https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46770 + */ + .ctors : ALIGN(16) { + __CTOR_LIST__ = .; + + LONG(((__CTOR_END__ - __CTOR_LIST__) / 4) - 2) + KEEP(*(SORT(.ctors.*))) + KEEP(*(.ctors)) + LONG(0) + + __CTOR_END__ = .; + } > APP_RAM + .dtors : ALIGN(16) { + __DTOR_LIST__ = .; + + LONG(((__DTOR_END__ - __DTOR_LIST__) / 4) - 2) + KEEP(*(SORT(.dtors.*))) + KEEP(*(.dtors)) + LONG(0) + + __DTOR_END__ = .; + } > APP_RAM + + /* Data sections, i.e. variables with default values */ + + .data : { + *(.data .data.* .gnu.linkonce.d.*) + } > APP_RAM + + /* + * Set _gp to point to the beginning of .sdata plus 0x7ff0, so anything + * within .sdata (and .sbss) can be accessed using the $gp register as + * base plus a signed 16-bit immediate. Note that $gp is set to _gp on + * boot by _start() in the SDK. + */ + HIDDEN(_gp = ALIGN(16) + 0x7ff0); + + .sdata : { + *(.sdata .sdata.* .gnu.linkonce.s.*) + } > APP_RAM + + /* BSS sections, i.e. uninitialized variables */ + + __bss_start = .; + + .sbss (NOLOAD) : { + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + } > APP_RAM + .bss (NOLOAD) : { + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + + /* + * This crap was in the stock GCC linker script. + */ + . = ALIGN((. != 0) ? 4 : 1); + } > APP_RAM + + _end = .; + + /* Dummy section */ + + .dummy (NOLOAD) : { + KEEP(*(.dummy)) + } > APP_RAM + + /* Remove anything flagged as link-time optimized */ + + /DISCARD/ : { + *(.gnu.lto_*) + } +} diff --git a/libpsn00b/libc/makefile b/libpsn00b/libc/makefile index a515ad5..bb3a687 100644 --- a/libpsn00b/libc/makefile +++ b/libpsn00b/libc/makefile @@ -1,54 +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 = libc.a +PSN00BSDK_LIBS ?= .. -INCLUDE = -I../include +include ../../psn00bsdk-setup.mk -CFLAGS = -g -O2 -msoft-float -fno-builtin -fdata-sections \ - -ffunction-sections -Wa,--strip-local-absolute -AFLAGS = -g -msoft-float -Wa,-strip-local-absolute +# Project target name +TARGET = libc.a -CFILES = $(notdir $(wildcard ./*.c)) -CXXFILES = $(notdir $(wildcard ./*.cxx)) -AFILES = $(notdir $(wildcard ./*.s)) +## Files -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(CXXFILES:.cxx=.o) \ - $(AFILES:.s=.o)) +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.s)) -ifndef PSN00BSDK_LIBS +# Create names for object files +OFILES = $(addprefix build/,$(CFILES:.c=.o)) \ + $(addprefix build/,$(CXXFILES:.cxx=.o)) \ + $(addprefix build/,$(AFILES:.s=.o)) -PSN00BSDK_LIBS = .. +# Project specific includes and libraries +# (use -I for include dirs, -L for library dirs, -l for static libraries) +INCLUDE += +LIBDIRS += +LIBS += -endif +## Build rules -all: $(TARGET) +all: build/$(TARGET) -$(TARGET): $(OFILES) - cp $(GCC_BASE)/lib/gcc/$(PREFIX)/$(GCC_VERSION)/libgcc.a ./$(TARGET) - $(AR) r $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + # "Import" libgcc's contents + cp $(GCC_BASE)/lib/gcc/$(PREFIX)/$(GCC_VERSION)/libgcc.a ./$@ + $(AR) rs $@ $(OFILES) build/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@ build/%.o: %.cxx @mkdir -p $(dir $@) - $(CXX) $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(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/lzp/makefile b/libpsn00b/lzp/makefile index 729a500..02654ed 100644 --- a/libpsn00b/lzp/makefile +++ b/libpsn00b/lzp/makefile @@ -1,40 +1,59 @@ -# 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 = liblzp.a +PSN00BSDK_LIBS ?= .. -INCLUDE = -I../include +include ../../psn00bsdk-setup.mk -CFILES = $(notdir $(wildcard ./*.c)) -OFILES = $(addprefix build/,$(CFILES:.c=.o)) +# Project target name +TARGET = liblzp.a -CFLAGS = -g -O2 -msoft-float -fno-builtin -nostdlib -fdata-sections \ - -ffunction-sections -Wa,--strip-local-absolute +## Files -ifndef PSN00BSDK_LIBS +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.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) +## Build rules + +all: build/$(TARGET) + +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(AR) crs $@ $(OFILES) -$(TARGET): $(OFILES) - $(AR) cr $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) - build/%.o: %.c - @mkdir -p build - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + @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_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 $(OFILES) $(TARGET) + rm -rf build 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/psxcd/makefile b/libpsn00b/psxcd/makefile index cf1eda5..ee9b958 100644 --- a/libpsn00b/psxcd/makefile +++ b/libpsn00b/psxcd/makefile @@ -1,46 +1,59 @@ -# 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 = libpsxcd.a +PSN00BSDK_LIBS ?= .. -INCLUDE = -I../include +include ../../psn00bsdk-setup.mk -CFILES = $(notdir $(wildcard ./*.c)) -AFILES = $(notdir $(wildcard ./*.s)) -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o)) +# Project target name +TARGET = libpsxcd.a -CFLAGS = -g -msoft-float -fno-builtin -fdata-sections \ - -ffunction-sections -Wa,--strip-local-absolute -AFLAGS = -g -msoft-float -Wa,--strip-local-absolute +## Files -ifndef PSN00BSDK_LIBS +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.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 += + +## Build rules -all: $(TARGET) +all: build/$(TARGET) -$(TARGET): $(OFILES) - $(AR) cr $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(AR) crs $@ $(OFILES) build/%.o: %.c @mkdir -p $(dir $@) - $(CC) -O2 $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(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/psxetc/makefile b/libpsn00b/psxetc/makefile index cc12944..84bb64b 100644 --- a/libpsn00b/psxetc/makefile +++ b/libpsn00b/psxetc/makefile @@ -1,46 +1,59 @@ -# 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 = libpsxetc.a +PSN00BSDK_LIBS ?= .. -CFILES = $(notdir $(wildcard ./*.c)) -AFILES = $(notdir $(wildcard ./*.s)) -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o)) +include ../../psn00bsdk-setup.mk -CFLAGS = -g -O2 -msoft-float -fno-builtin -nostdlib -fdata-sections \ - -ffunction-sections -Wa,--strip-local-absolute -AFLAGS = -g -msoft-float -strip-local-absolute +# Project target name +TARGET = libpsxetc.a -INCLUDE = -I../include +## Files -ifndef PSN00BSDK_LIBS +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.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) +## Build rules -$(TARGET): $(OFILES) - $(AR) cr $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) +all: build/$(TARGET) + +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(AR) crs $@ $(OFILES) build/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@ + +build/%.o: %.cxx + @mkdir -p $(dir $@) + $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@ build/%.o: %.s @mkdir -p $(dir $@) - $(AS) $(AFLAGS) $(INCLUDE) $< -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/psxgpu/makefile b/libpsn00b/psxgpu/makefile index 5442958..adcb7fa 100644 --- a/libpsn00b/psxgpu/makefile +++ b/libpsn00b/psxgpu/makefile @@ -1,46 +1,59 @@ -# 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 = libpsxgpu.a +PSN00BSDK_LIBS ?= .. -INCLUDE = -I../include +include ../../psn00bsdk-setup.mk -CFILES = $(notdir $(wildcard ./*.c)) -AFILES = $(notdir $(wildcard ./*.s)) -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o)) +# Project target name +TARGET = libpsxgpu.a -CFLAGS = -g -O2 -msoft-float -fno-builtin -fdata-sections \ - -ffunction-sections -Wa,--strip-local-absolute -AFLAGS = -g -msoft-float -Wa,--strip-local-absolute +## Files -ifndef PSN00BSDK_LIBS +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.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) +## Build rules -$(TARGET): $(OFILES) - $(AR) cr $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) +all: build/$(TARGET) + +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(AR) crs $@ $(OFILES) build/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(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/psxgte/makefile b/libpsn00b/psxgte/makefile index 7c1683f..e60ff1e 100644 --- a/libpsn00b/psxgte/makefile +++ b/libpsn00b/psxgte/makefile @@ -1,46 +1,59 @@ -# 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 = libpsxgte.a +PSN00BSDK_LIBS ?= .. -INCLUDE = -I../include +include ../../psn00bsdk-setup.mk -CFILES = $(notdir $(wildcard ./*.c)) -AFILES = $(notdir $(wildcard ./*.s)) -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o)) +# Project target name +TARGET = libpsxgte.a -CFLAGS = -g -O2 -msoft-float -fno-builtin -fdata-sections \ - -ffunction-sections -Wa,--strip-local-absolute -AFLAGS = -g -msoft-float -strip-local-absolute +## Files -ifndef PSN00BSDK_LIBS +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.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 += + +## Build rules -all: $(TARGET) +all: build/$(TARGET) -$(TARGET): $(OFILES) - $(AR) cr $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(AR) crs $@ $(OFILES) build/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@ + +build/%.o: %.cxx + @mkdir -p $(dir $@) + $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@ build/%.o: %.s @mkdir -p $(dir $@) - $(AS) $(AFLAGS) $(INCLUDE) $< -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/psxsio/makefile b/libpsn00b/psxsio/makefile index 06971ba..c9dcade 100644 --- a/libpsn00b/psxsio/makefile +++ b/libpsn00b/psxsio/makefile @@ -1,46 +1,59 @@ -# 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 = libpsxsio.a +PSN00BSDK_LIBS ?= .. -INCLUDE = -I../include +include ../../psn00bsdk-setup.mk -CFILES = $(notdir $(wildcard ./*.c)) -AFILES = $(notdir $(wildcard ./*.s)) -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o)) +# Project target name +TARGET = libpsxsio.a -CFLAGS = -g -O2 -msoft-float -fno-builtin -fdata-sections \ - -ffunction-sections -Wa,--strip-local-absolute -AFLAGS = -g -msoft-float -Wa,--strip-local-absolute +## Files -ifndef PSN00BSDK_LIBS +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.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 += + +## Build rules -all: $(TARGET) +all: build/$(TARGET) -$(TARGET): $(OFILES) - $(AR) cr $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(AR) crs $@ $(OFILES) build/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(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/psxspu/makefile b/libpsn00b/psxspu/makefile index 7948f34..5710f39 100644 --- a/libpsn00b/psxspu/makefile +++ b/libpsn00b/psxspu/makefile @@ -1,46 +1,59 @@ -# 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 = libpsxspu.a +PSN00BSDK_LIBS ?= .. -INCLUDE = -I../include +include ../../psn00bsdk-setup.mk -CFILES = $(notdir $(wildcard ./*.c)) -AFILES = $(notdir $(wildcard ./*.s)) -OFILES = $(addprefix build/,$(CFILES:.c=.o) $(AFILES:.s=.o)) +# Project target name +TARGET = libpsxspu.a -CFLAGS = -g -O2 -msoft-float -fdata-sections -ffunction-sections \ - -Wa,--strip-local-absolute -AFLAGS = -g -msoft-float -strip-local-absolute +## Files -ifndef PSN00BSDK_LIBS +# Searches for C, C++ and S (assembler) files in local directory +CFILES = $(notdir $(wildcard *.c)) +CXXFILES= $(notdir $(wildcard *.cxx)) +AFILES = $(notdir $(wildcard *.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 += + +## Build rules -all: $(TARGET) +all: build/$(TARGET) -$(TARGET): $(OFILES) - $(AR) cr $(TARGET) $(OFILES) - $(RANLIB) $(TARGET) +build/$(TARGET): $(OFILES) + @mkdir -p $(dir $@) + $(AR) crs $@ $(OFILES) build/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + $(CC) $(CFLAGS_LIB) $(INCLUDE) -c $< -o $@ + +build/%.o: %.cxx + @mkdir -p $(dir $@) + $(CXX) $(CPPFLAGS_LIB) $(INCLUDE) -c $< -o $@ build/%.o: %.s @mkdir -p $(dir $@) - $(AS) $(AFLAGS) $(INCLUDE) $< -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 |
