Update hooks and add a new way for patching functions

This commit is contained in:
Maschell
2019-11-17 17:43:09 +01:00
parent e9ea643f19
commit d2e557412f
6 changed files with 368 additions and 169 deletions

View File

@@ -51,6 +51,8 @@ include $(WUPSDIR)/plugin_makefile.mk
# options for code generation
#---------------------------------------------------------------------------------
MACHDEP = -DESPRESSO -mcpu=750 -meabi -mhard-float
# -Os: optimise size
# -Wall: generate lots of warnings
# -D__wiiu__: define the symbol __wiiu__ (used in some headers)
@@ -60,27 +62,24 @@ include $(WUPSDIR)/plugin_makefile.mk
# -nostartfiles: Do not use the standard system startup files when linking
# -ffunction-sections: split up functions so linker can garbage collect
# -fdata-sections: split up data so linker can garbage collect
COMMON_CFLAGS := -Os -Wall -mcpu=750 -meabi -mhard-float -D__WIIU__ -nostartfiles -ffunction-sections -fdata-sections -Wl,-q $(COMMON_CFLAGS)
COMMON_CFLAGS := -O0 -Wall $(MACHDEP) -meabi -ffunction-sections -fdata-sections -Wl,-q $(COMMON_CFLAGS)
CFLAGS += -D__WIIU__ -D__WUT__
# -x c: compile as c code
# -std=c11: use the c11 standard
CFLAGS := $(COMMON_CFLAGS) -x c -std=gnu11 $(CFLAGS)
# -x c: compile as c++ code
# -x c++: compile as c++ code
# -std=gnu++11: use the c++11 standard
CXXFLAGS := $(COMMON_CFLAGS) -x c++ -std=gnu++11 $(CXXFLAGS)
ifeq ($(DO_LOGGING), 1)
CFLAGS += -D__LOGGING__
CXXFLAGS += -D__LOGGING__
endif
#---------------------------------------------------------------------------------
# any extra ld flags
#--------------------------------------------------------------------------------
# --gc-sections: remove unneeded symbols
# -Map: generate a map file
LDFLAGS += -Wl,-Map,$(notdir $@).map,--gc-sections
LDFLAGS += $(ARCH) -Wl,-Map,$(notdir $@).map,--gc-sections,-wrap,__gxx_personality_v0
#---------------------------------------------------------------------------------
@@ -97,33 +96,6 @@ LIBS +=
#---------------------------------------------------------------------------------
LIBDIRS +=
NEEDS_WUT := 0
ifeq ($(WUT_ENABLE_CPP), 1)
WUT_ENABLE_NEWLIB := 1
LDFLAGS += -Wl,-whole-archive,-lwutstdc++,-no-whole-archive
NEEDS_WUT := 1
endif
ifeq ($(WUT_ENABLE_NEWLIB), 1)
LDFLAGS += -Wl,-whole-archive,-lwutnewlib,-no-whole-archive
NEEDS_WUT := 1
endif
ifeq ($(WUT_DEFAULT_MALLOC), 1)
LDFLAGS += -Wl,-whole-archive,-lwutmalloc,-no-whole-archive
NEEDS_WUT := 1
endif
ifeq ($(NEEDS_WUT), 1)
ifeq ($(strip $(WUT_ROOT)),)
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
endif
CFLAGS += -D__WUT__
CXXFLAGS += -D__WUT__
endif
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions

View File

@@ -1,20 +1,3 @@
# Compiling the projects with libutils logging code?
DO_LOGGING := 1
# Links against the wut implementation of newlib, this is useful for using any function
# from the C standard library
WUT_ENABLE_NEWLIB := 0
# Links against the wut implementation of stdcpp, this is useful for using any function
# from the C++ standard library. This will enable WUT_ENABLE_NEWLIB if you have not already done so.
WUT_ENABLE_CPP := 0
# By default newlib will allocate 90% of the default heap for use with sbrk & malloc,
# if this is unacceptable to you then you should use this as it replaces the newlib
# malloc functions which ones which redirect to the CafeOS default heap functions
# such as MEMAllocFromDefaultHeap.
WUT_DEFAULT_MALLOC := 1
# Target filename
TARGET := $(notdir $(CURDIR)).mod
@@ -43,12 +26,12 @@ LDFLAGS :=
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(WUPSDIR) $(WUT_ROOT)
LIBDIRS := $(WUPSDIR) $(WUT_ROOT) $(PORTLIBS)
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lwups -lutilswut -lcoreinit -lnsysnet
LIBS := -lwups -lwut
#---------------------------------------------------------------------------------
# Will be added to the final lib paths
@@ -61,4 +44,4 @@ EXTERNAL_LIBPATHS :=
# Will be added to the final include paths
# -IC:/library1/include
#---------------------------------------------------------------------------------
EXTERNAL_INCLUDE := -I$(WUT_ROOT)/include/libutilswut
EXTERNAL_INCLUDE :=