altra64/Makefile

84 lines
2.6 KiB
Makefile
Raw Normal View History

2017-10-06 09:48:52 -04:00
#
# Copyright (c) 2017 The Altra64 project contributors
# See LICENSE file in the project root for full license information.
#
2014-06-29 01:10:11 -04:00
ROOTDIR = $(N64_INST)
GCCN64PREFIX = $(ROOTDIR)/bin/mips64-elf-
CHKSUM64PATH = $(ROOTDIR)/bin/chksum64
MKDFSPATH = $(ROOTDIR)/bin/mkdfs
N64TOOL = $(ROOTDIR)/bin/n64tool
HEADERNAME = header.ed64
HEADERTITLE = "EverDrive OS"
2014-06-29 01:10:11 -04:00
2016-09-07 20:18:35 -04:00
SRCDIR = ./src
2017-10-06 10:26:20 -04:00
INCDIR = ./inc
2016-09-07 20:18:35 -04:00
RESDIR = ./res
2021-10-25 02:43:55 -04:00
BINDIR = ./target
OBJDIR = $(BINDIR)/obj
TOOLSDIR = ./tools
2014-06-29 01:10:11 -04:00
2021-10-25 02:29:40 -04:00
RUST_DIR = ./rust
RUST_TARGET_DIR = target/mips-nintendo64-none/release
RUST_FULL_TARGET_DIR = $(RUST_DIR)/$(RUST_TARGET_DIR)
RUST_DEPS := $(wildcard $(RUST_DIR)/src/*) $(wildcard $(RUST_DIR)/Cargo.*)
RUST_BIN_DEPS := $(RUST_DEPS) $(RUST_DIR)/mips-nintendo64-none.json
RUST_H_DEPS := $(RUST_DEPS) $(RUST_DIR)/cbindgen.toml
CFLAGS = -std=gnu99 -march=vr4300 -mtune=vr4300 -O1 -I$(INCDIR) -I$(ROOTDIR)/include -I$(ROOTDIR)/mips64-elf/include -I$(RUST_FULL_TARGET_DIR) -lpthread -lrt -D_REENTRANT -DUSE_TRUETYPE $(SET_DEBUG)
2021-10-28 23:24:57 -04:00
ifdef USE_YAML
CFLAGS += -DUSE_YAML
LIBS += -lyaml
else
LIBS += -laltra64
endif
LINK_FLAGS = -O1 -L$(ROOTDIR)/lib -L$(ROOTDIR)/mips64-elf/lib -L$(RUST_FULL_TARGET_DIR) -ldragon -lmad $(LIBS) -lc -lm -ldragonsys -lnosys -Tn64ld.x
PROG_NAME = $(BINDIR)/OS64P
2014-06-29 01:10:11 -04:00
ASFLAGS = -mtune=vr4300 -march=vr4300
CC = $(GCCN64PREFIX)gcc
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)ld
OBJCOPY = $(GCCN64PREFIX)objcopy
SOURCES := $(wildcard $(SRCDIR)/*.c)
OBJECTS = $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
2014-06-29 01:10:11 -04:00
2021-10-25 02:29:40 -04:00
$(PROG_NAME).v64: $(PROG_NAME).elf $(PROG_NAME).dfs
2021-10-25 02:43:55 -04:00
$(OBJCOPY) $(PROG_NAME).elf $(PROG_NAME).bin -O binary
rm -f $(PROG_NAME).v64
$(N64TOOL) -l 4M -t $(HEADERTITLE) -h $(RESDIR)/$(HEADERNAME) -o $(PROG_NAME).v64 $(PROG_NAME).bin -s 1M $(PROG_NAME).dfs
$(CHKSUM64PATH) $(PROG_NAME).v64
2014-06-29 01:10:11 -04:00
2021-10-25 02:29:40 -04:00
$(RUST_FULL_TARGET_DIR)/libaltra64.a: $(RUST_BIN_DEPS)
cd $(RUST_DIR) && cargo build --release --verbose --target mips-nintendo64-none.json -Z build-std=core && touch $(RUST_TARGET_DIR)/libaltra64.a
2021-10-25 01:59:55 -04:00
2021-10-25 02:29:40 -04:00
$(RUST_FULL_TARGET_DIR)/altra64.h: $(RUST_H_DEPS)
cd $(RUST_DIR) && cbindgen -o $(RUST_TARGET_DIR)/altra64.h && touch $(RUST_TARGET_DIR)/altra64.h
2021-10-25 01:59:55 -04:00
2021-10-25 02:29:40 -04:00
$(PROG_NAME).elf : $(OBJECTS) $(RUST_FULL_TARGET_DIR)/libaltra64.a
@mkdir -p $(BINDIR)
2021-10-25 02:43:55 -04:00
$(LD) -o $(PROG_NAME).elf $(OBJECTS) $(LINK_FLAGS)
2016-09-07 20:18:35 -04:00
2021-10-25 02:29:40 -04:00
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c $(RUST_FULL_TARGET_DIR)/altra64.h
@mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
2014-06-29 01:10:11 -04:00
copy: $(PROG_NAME).v64
sh $(TOOLSDIR)/upload.sh
2014-06-29 01:10:11 -04:00
$(PROG_NAME).dfs:
2021-10-25 02:43:55 -04:00
@mkdir -p $(BINDIR)
$(MKDFSPATH) $(PROG_NAME).dfs $(RESDIR)/filesystem/
2014-06-29 01:10:11 -04:00
all: $(PROG_NAME).v64
debug: $(PROG_NAME).v64
debug: SET_DEBUG=-DDEBUG
2014-06-29 01:10:11 -04:00
clean:
2021-10-25 02:43:55 -04:00
rm -rf ./target ./rust/target