-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# run `make all` to compile the .hhk and .bin file, use `make` to compile only the .bin file. | ||
# The .hhk file is the original format, the bin file is a newer format. | ||
APP_NAME:=3dRenderer | ||
|
||
ifndef SDK_DIR | ||
$(error You need to define the SDK_DIR environment variable, and point it to the sdk/ folder) | ||
endif | ||
|
||
AS:=sh4-elf-as | ||
AS_FLAGS:= | ||
|
||
CC:=sh4-elf-gcc | ||
CC_FLAGS:=-ffreestanding -fshort-wchar -Wall -Wextra -O2 -I $(SDK_DIR)/include/ -I $(SDK_DIR)/newlib/sh-elf/include/ -I /home/adrian/hollyhock-2/app_template/src/include/ | ||
|
||
CXX:=sh4-elf-g++ | ||
CXX_FLAGS:=-ffreestanding -fno-exceptions -fno-rtti -fshort-wchar -Wall -Wextra -O2 -fpermissive -I $(SDK_DIR)/include/ -m4a-nofpu -I $(SDK_DIR)/newlib/sh-elf/include/ | ||
|
||
LD:=sh4-elf-gcc | ||
LD_FLAGS:=-nostartfiles -m4-nofpu -Wno-undef -L$(SDK_DIR)/newlib/sh-elf/lib -lm | ||
|
||
READELF:=sh4-elf-readelf | ||
OBJCOPY:=sh4-elf-objcopy | ||
|
||
AS_SOURCES:=$(wildcard *.s) | ||
CC_SOURCES:=$(wildcard *.c) | ||
CXX_SOURCES := $(wildcard src/*.cpp) | ||
OBJECTS:=$(AS_SOURCES:.s=.o) $(CC_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) | ||
|
||
APP_ELF:=$(APP_NAME).hhk | ||
APP_BIN:=$(APP_NAME).bin | ||
|
||
bin: $(APP_BIN) Makefile | ||
|
||
hhk: $(APP_ELF) Makefile | ||
|
||
all: $(APP_ELF) $(APP_BIN) Makefile | ||
|
||
clean: | ||
rm -f $(OBJECTS) $(APP_ELF) $(APP_BIN) | ||
|
||
$(APP_ELF): $(OBJECTS) $(SDK_DIR)/sdk.o linker_hhk.ld | ||
$(LD) -T linker_hhk.ld -o $@ $(LD_FLAGS) $(OBJECTS) $(SDK_DIR)/sdk.o | ||
$(OBJCOPY) --set-section-flags .hollyhock_name=contents,strings,readonly $(APP_ELF) $(APP_ELF) | ||
$(OBJCOPY) --set-section-flags .hollyhock_description=contents,strings,readonly $(APP_ELF) $(APP_ELF) | ||
$(OBJCOPY) --set-section-flags .hollyhock_author=contents,strings,readonly $(APP_ELF) $(APP_ELF) | ||
$(OBJCOPY) --set-section-flags .hollyhock_version=contents,strings,readonly $(APP_ELF) $(APP_ELF) | ||
|
||
$(APP_BIN): $(OBJECTS) $(SDK_DIR)/sdk.o linker_bin.ld | ||
$(LD) -Wl,--oformat=binary -T linker_bin.ld -o $@ $(LD_FLAGS) $(OBJECTS) $(SDK_DIR)/sdk.o | ||
|
||
# We're not actually building sdk.o, just telling the user they need to do it | ||
# themselves. Just using the target to trigger an error when the file is | ||
# required but does not exist. | ||
$(SDK_DIR)/sdk.o: | ||
$(error You need to build the SDK before using it. Run make in the SDK directory, and check the README.md in the SDK directory for more information) | ||
|
||
%.o: %.s | ||
$(AS) $< -o $@ $(AS_FLAGS) | ||
|
||
%.o: %.c | ||
$(CC) -c $< -o $@ $(CC_FLAGS) | ||
|
||
# Break the build if global constructors are present: | ||
# Read the sections from the object file (with readelf -S) and look for any | ||
# called .ctors - if they exist, give the user an error message, delete the | ||
# object file (so that on subsequent runs of make the build will still fail) | ||
# and exit with an error code to halt the build. | ||
src/%.o: src/%.cpp | ||
$(CXX) -c $< -o $@ $(CXX_FLAGS) | ||
@$(READELF) $@ -S | grep ".ctors" > /dev/null && echo "ERROR: Global constructors aren't supported." && rm $@ && exit 1 || exit 0 | ||
|
||
|
||
.PHONY: bin hhk all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ENTRY(_main); | ||
|
||
SECTIONS { | ||
start_address = 0x8CFF0000; | ||
.init start_address : AT(start_address) { | ||
*(.init) | ||
} | ||
info_address = 0x8CFF0010; | ||
. = info_address; | ||
.hollyhock_name : { | ||
*(.hollyhock_name) | ||
} | ||
.hollyhock_description : { | ||
*(.hollyhock_description) | ||
} | ||
.hollyhock_author : { | ||
*(.hollyhock_author) | ||
} | ||
.hollyhock_version : { | ||
*(.hollyhock_version) | ||
} | ||
.text : { | ||
*(.text) | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ENTRY(_main); | ||
|
||
SECTIONS { | ||
. = 0x8CFF0000; | ||
} |