diff options
| author | John Wilbert M. Villamor <lameguy64@gmail.com> | 2021-02-18 13:31:17 +0800 |
|---|---|---|
| committer | John Wilbert M. Villamor <lameguy64@gmail.com> | 2021-02-18 13:31:17 +0800 |
| commit | 63419d9cc07c56234d0f61a80f32105b192aec8e (patch) | |
| tree | 827cf4d134cf3b4618d0167cc912f3efd47c3aac /template/makefile | |
| parent | 1625072293c40ba3cb819f8f48aeb4b64e93b133 (diff) | |
| download | psn00bsdk-63419d9cc07c56234d0f61a80f32105b192aec8e.tar.gz | |
Lots of makefile corrections, improved build and toolchain instructions, added elf2cpe converter, fixed typo in plasma_tbl.h of n00bdemo example
Diffstat (limited to 'template/makefile')
| -rw-r--r-- | template/makefile | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/template/makefile b/template/makefile new file mode 100644 index 0000000..42ff370 --- /dev/null +++ b/template/makefile @@ -0,0 +1,54 @@ +include psn00bsdk-setup.mk + +# Project target name +TARGET = template.elf + +# 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 include and library directories +# (use -I for include dirs, -L for library dirs) +INCLUDE += +LIBDIRS += + +# Libraries to link +LIBS = -lpsxgpu -lpsxgte -lpsxspu -lpsxetc -lpsxapi -lc + +# C compiler flags +CFLAGS = -g -O2 -fno-builtin -fdata-sections -ffunction-sections + +# C++ compiler flags +CPPFLAGS = $(CFLAGS) -fno-exceptions + +# Assembler flags +AFLAGS = -g + +# Linker flags (-Ttext specifies the program text address) +LDFLAGS = -g -Ttext=0x80010000 -gc-sections \ + -T $(GCC_BASE)/$(PREFIX)/lib/ldscripts/elf32elmip.x + +all: $(OFILES) + $(LD) $(LDFLAGS) $(LIBDIRS) $(OFILES) $(LIBS) -o $(TARGET) + elf2x -q $(TARGET) + +build/%.o: %.c + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +build/%.o: %.cpp + @mkdir -p $(dir $@) + $(CXX) $(AFLAGS) $(INCLUDE) -c $< -o $@ + +build/%.o: %.s + @mkdir -p $(dir $@) + $(CC) $(AFLAGS) $(INCLUDE) -c $< -o $@ + +clean: + rm -rf build $(TARGET) $(TARGET:.elf=.exe) |
