#--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- ifeq ($(strip $(DEVKITPPC)),) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") endif ifeq ($(strip $(DEVKITPRO)),) $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPRO") endif GITTAG ?= $(shell git describe --tags) 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 #--------------------------------------------------------------------------------- # 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 INCLUDES := include PKGCONFS := pkgconf DATA := LIB := lib #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- CFLAGS = -g -Os -Wall -D__wiiu__ $(MACHDEP) $(INCLUDE) CXXFLAGS = $(CFLAGS) ASFLAGS := -g export WIIUBIN := $(LIB)/libdynamiclibs.a export PKGCONF := dynamic_libs.pc #--------------------------------------------------------------------------------- # 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 := #--------------------------------------------------------------------------------- # 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 VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ $(foreach dir,$(PKGCONFS),$(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))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) export OFILES := $(addsuffix .o,$(BINFILES)) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.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$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include -I$(PORTLIBS)/include export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) $(PORTLIBS)/lib .PHONY: $(BUILD) clean all install #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile #--------------------------------------------------------------------------------- clean: @echo clean ... @rm -fr debug release $(LIB) include $(PKGCONF) all: $(BUILD) install: $(BUILD) @mkdir -p $(PORTLIBS)/lib @cp $(BUILD)/lib/libdynamiclibs.a $(PORTLIBS)/lib @mkdir -p $(PORTLIBS)/include/dynamic_libs @cp source/*.h $(PORTLIBS)/include/dynamic_libs @mkdir -p $(PORTLIBS)/lib/pkgconfig @cp $(BUILD)/$(PKGCONF) $(PORTLIBS)/lib/pkgconfig @echo Installed! #--------------------------------------------------------------------------------- else DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- all: $(WIIUBIN) $(PKGCONF) %.pc: %.pc.in @sed "s;@PREFIX@;$(PORTLIBS);g" $< > $@ @sed "s;@VERSION@;$(GITTAG);g" $< > $@ $(WIIUBIN): $(OFILES) $(LIB) @rm -f "$(WIIUBIN)" @$(AR) rcs "$(WIIUBIN)" $(OFILES) @echo built ... $(notdir $@) $(LIB): mkdir $(LIB) -include $(DEPENDS) #--------------------------------------------------------------------------------------- endif #---------------------------------------------------------------------------------------