mirror of
https://gitlab.com/Nanolx/homebrewfilter.git
synced 2024-12-27 01:51:48 +01:00
154 lines
5.9 KiB
Makefile
154 lines
5.9 KiB
Makefile
#---------------------------------------------------------------------------------
|
|
# Clear the implicit built in rules
|
|
#---------------------------------------------------------------------------------
|
|
.SUFFIXES:
|
|
#---------------------------------------------------------------------------------
|
|
ifeq ($(strip $(DEVKITPPC)),)
|
|
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
|
endif
|
|
|
|
include $(DEVKITPPC)/wii_rules
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# TARGET is the name of the output
|
|
# BUILD is the directory where object files & intermediate files will be placed
|
|
# SOURCES is a list of directories containing source code
|
|
# INCLUDES is a list of directories containing extra header files
|
|
#---------------------------------------------------------------------------------
|
|
TARGET := runtimeiospatch
|
|
BUILD := build
|
|
SOURCES := source
|
|
DATA := data
|
|
INCLUDES := $(DEVKITPRO)/libogc
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# options for code generation
|
|
#---------------------------------------------------------------------------------
|
|
|
|
CFLAGS = -save-temps -g -O2 -Wall $(MACHDEP) $(INCLUDE)
|
|
CXXFLAGS = $(CFLAGS)
|
|
ASFLAGS = $(INCLUDE) -D_LANGUAGE_ASSEMBLY
|
|
|
|
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
|
ARFLAGS = rcs
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# any extra libraries we wish to link with the project
|
|
#---------------------------------------------------------------------------------
|
|
LIBS :=
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# list of directories containing libraries, this must be the top level containing
|
|
# include and lib
|
|
#---------------------------------------------------------------------------------
|
|
LIBDIRS := $(DEVKITPRO)/libogc
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# no real need to edit anything past this point unless you need to add additional
|
|
# rules for different file extensions
|
|
#---------------------------------------------------------------------------------
|
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
#---------------------------------------------------------------------------------
|
|
|
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
|
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
|
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# automatically build a list of object files for our project
|
|
#---------------------------------------------------------------------------------
|
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# use CXX for linking C++ projects, CC for standard C
|
|
#---------------------------------------------------------------------------------
|
|
ifeq ($(strip $(CPPFILES)),)
|
|
export LD := $(CC)
|
|
else
|
|
export LD := $(CXX)
|
|
endif
|
|
|
|
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
|
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
|
$(sFILES:.s=.o) $(SFILES:.S=.o)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# build a list of include paths
|
|
#---------------------------------------------------------------------------------
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
-I$(CURDIR)/$(BUILD) \
|
|
-I$(LIBOGC_INC)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# build a list of library paths
|
|
#---------------------------------------------------------------------------------
|
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
|
-L$(LIBOGC_LIB)
|
|
|
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
|
.PHONY: $(BUILD) clean
|
|
|
|
#---------------------------------------------------------------------------------
|
|
$(BUILD):
|
|
@[ -d $@ ] || mkdir -p $@
|
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
|
|
|
#---------------------------------------------------------------------------------
|
|
clean:
|
|
@echo clean ...
|
|
@rm -fr $(BUILD)
|
|
@rm -f lib$(TARGET).a
|
|
#---------------------------------------------------------------------------------
|
|
run:
|
|
wiiload $(OUTPUT).dol
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
install:
|
|
@echo Installing ...
|
|
@mkdir -p $(LIBOGC_INC)/$(TARGET)
|
|
@install -v -m 644 lib$(TARGET).a $(LIBOGC_LIB)
|
|
@install -v -m 644 source/$(TARGET).h $(LIBOGC_INC)/$(TARGET)
|
|
#---------------------------------------------------------------------------------
|
|
else
|
|
|
|
DEPENDS := $(OFILES:.o=.d)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# main targets
|
|
#---------------------------------------------------------------------------------
|
|
$(OUTPUT).a: $(OFILES)
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# This rule links in binary data with the .bin extension
|
|
#---------------------------------------------------------------------------------
|
|
%.bin.o : %.bin
|
|
#---------------------------------------------------------------------------------
|
|
@echo $(notdir $<)
|
|
$(bin2o)
|
|
|
|
|
|
|
|
-include $(DEPENDS)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
# This rule will create a library with all the object files
|
|
#---------------------------------------------------------------------------------
|
|
%.a:
|
|
@echo Archiving ... lib$(notdir $@)
|
|
@$(AR) $(ARFLAGS) ../lib$(notdir $@) $^
|
|
@echo $(TARGET)
|
|
|
|
#---------------------------------------------------------------------------------
|
|
endif
|
|
#---------------------------------------------------------------------------------
|