Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #---------------------------------------------------------------------------------
- # Clear the implicit built in rules
- #---------------------------------------------------------------------------------
- .SUFFIXES:
- #---------------------------------------------------------------------------------
- ifeq ($(strip $(DEVKITPPC)),)
- $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
- endif
- ifeq ($(strip $(DEVKITPRO)),)
- $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
- endif
- PREFIX := powerpc-eabi-
- export AS := $(PREFIX)as
- export CC := $(PREFIX)gcc
- export CXX := $(PREFIX)g++
- export AR := $(PREFIX)ar
- export OBJCOPY := $(PREFIX)objcopy
- #---------------------------------------------------------------------------------
- # 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 := build/lib
- BUILD := build
- BUILD_DBG := $(TARGET)_dbg
- SOURCES := source \
- source/common \
- source/imports \
- source/network \
- source/memory \
- source/watcher \
- source/watcher/Common \
- source/watcher/EmuProcess \
- source/utils
- DATA :=
- INCLUDES := source
- #---------------------------------------------------------------------------------
- # options for code generation
- # DB: if the C++ .eh_frame sections are problematic, remove them from CXXFLAGS via -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
- # DB: -fno-common: Disable common section allowing uninitialized variables to reserve space and work with the RomHack compiler
- #---------------------------------------------------------------------------------
- CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math -G 0 \
- -ffunction-sections -fdata-sections \
- -fno-common \
- -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-unused-label -Wno-strict-aliasing \
- -O3 $(INCLUDE)
- CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math -G 0 \
- -ffunction-sections -fdata-sections \
- -fno-common \
- -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-unused-label -Wno-strict-aliasing \
- -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables \
- -O3 $(INCLUDE)
- ASFLAGS := -mregnames
- LDFLAGS := -nostartfiles -Wl,-Map,$(notdir $@).map,--gc-sections
- #---------------------------------------------------------------------------------
- Q := @
- MAKEFLAGS += --no-print-directory
- #---------------------------------------------------------------------------------
- # 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 PROJECTDIR := $(CURDIR)
- export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(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)))
- #---------------------------------------------------------------------------------
- # use CXX for linking C++ projects, CC for standard C
- #---------------------------------------------------------------------------------
- ifeq ($(strip $(CPPFILES)),)
- export LD := $(CC)
- else
- export LD := $(CXX)
- endif
- export OFILES := $(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))
- export OUTPUT := $(CURDIR)/$(TARGET)
- .PHONY: $(BUILD) clean install
- #---------------------------------------------------------------------------------
- $(BUILD):
- @[ -d $@ ] || mkdir -p $@
- @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
- #---------------------------------------------------------------------------------
- clean:
- @echo clean ...
- @rm -fr $(BUILD)
- #---------------------------------------------------------------------------------
- else
- DEPENDS := $(OFILES:.o=.d)
- #---------------------------------------------------------------------------------
- # main targets
- #---------------------------------------------------------------------------------
- $(OUTPUT).a: $(OFILES)
- #---------------------------------------------------------------------------------
- %.a:
- #---------------------------------------------------------------------------------
- @echo $(notdir $@)
- @rm -f $@
- @$(AR) -rc $@ $^
- #---------------------------------------------------------------------------------
- %.o: %.cpp
- @echo $(notdir $<)
- @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER)
- #---------------------------------------------------------------------------------
- %.o: %.c
- @echo $(notdir $<)
- @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)
- #---------------------------------------------------------------------------------
- %.o: %.S
- @echo $(notdir $<)
- @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
- -include $(DEPENDS)
- #---------------------------------------------------------------------------------
- endif
- #---------------------------------------------------------------------------------
Add Comment
Please, Sign In to add comment