libutils/Makefile

156 lines
5.2 KiB
Makefile
Raw Normal View History

2017-12-27 13:05:50 +01:00
DO_LOGGING := 1
2017-10-29 09:24:06 +01:00
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC)
endif
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
PREFIX := powerpc-eabi-
export AS := $(PREFIX)as
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
include $(DEVKITPPC)/base_rules
2017-10-29 09:24:06 +01:00
#---------------------------------------------------------------------------------
# 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
# DATA is a list of directories containing binary files
# LIBDIR is where the built library will be placed
# all directories are relative to this makefile
#---------------------------------------------------------------------------------
BUILD ?= release
SOURCES := source \
source/fs \
source/utils \
source/language \
source/network \
2017-10-29 09:24:06 +01:00
source/system \
source/kernel
INCLUDES := include \
source
DATA :=
LIB := lib
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS = -g -Os -Wall -D__wiiu__ -D_GNU_SOURCE $(MACHDEP) $(INCLUDE)
2017-10-29 09:24:06 +01:00
CXXFLAGS = $(CFLAGS)
ifeq ($(DO_LOGGING), 1)
CFLAGS += -D__LOGGING__
CXXFLAGS += -D__LOGGING__
endif
2017-10-29 09:24:06 +01:00
ASFLAGS := -mregnames
export WIIUBIN := $(LIB)/libutils.a
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -ldynamiclibs
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
#---------------------------------------------------------------------------------
# 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 TOPDIR ?= $(CURDIR)/..
export DEPSDIR := $(CURDIR)/$(BUILD)
export INCLUDEDIR := $(PORTLIBS)/include/libutils
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
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)/*.*)))
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) $(sFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) -I$(LIBOGC_INC) \
-I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) $(PORTLIBS)/lib
.PHONY: $(BUILD) clean
#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr debug release $(LIB) include
all: $(WIIUBIN)
install:
@cp $(BUILD)/lib/libutils.a $(PORTLIBS)/lib
@mkdir -p $(INCLUDEDIR)/utils/
@mkdir -p $(INCLUDEDIR)/kernel/
@mkdir -p $(INCLUDEDIR)/system/
@mkdir -p $(INCLUDEDIR)/network/
2017-10-29 09:24:06 +01:00
@mkdir -p $(INCLUDEDIR)/language/
@mkdir -p $(INCLUDEDIR)/fs/
@cp source/utils/*.h $(INCLUDEDIR)/utils/
@cp source/utils/*.hpp $(INCLUDEDIR)/utils/
2017-10-29 09:24:06 +01:00
@cp source/system/*.h $(INCLUDEDIR)/system/
@cp source/language/*.h $(INCLUDEDIR)/language/
@cp source/network/*.h $(INCLUDEDIR)/network/
2017-10-29 09:24:06 +01:00
@cp source/fs/*.h $(INCLUDEDIR)/fs/
@cp source/fs/*.hpp $(INCLUDEDIR)/fs/
2017-10-31 15:57:54 +01:00
@cp source/kernel/*.h $(INCLUDEDIR)/kernel/
2017-10-29 09:24:06 +01:00
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(WIIUBIN) : $(OFILES) $(LIB)
@rm -f "$(WIIUBIN)"
@$(AR) rcs "$(WIIUBIN)" $(OFILES)
@echo built ... $(notdir $@)
$(LIB):
mkdir $(LIB)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------