|
| 1 | +#------------------------------------------------------------------------------- |
| 2 | +.SUFFIXES: |
| 3 | +#------------------------------------------------------------------------------- |
| 4 | + |
| 5 | +ifeq ($(strip $(DEVKITPRO)),) |
| 6 | +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") |
| 7 | +endif |
| 8 | + |
| 9 | +TOPDIR ?= $(CURDIR) |
| 10 | + |
| 11 | +include $(DEVKITPRO)/wums/share/wums_rules |
| 12 | + |
| 13 | +WUMS_ROOT := $(DEVKITPRO)/wums |
| 14 | +WUT_ROOT := $(DEVKITPRO)/wut |
| 15 | +#------------------------------------------------------------------------------- |
| 16 | +# TARGET is the name of the output |
| 17 | +# BUILD is the directory where object files & intermediate files will be placed |
| 18 | +# SOURCES is a list of directories containing source code |
| 19 | +# DATA is a list of directories containing data files |
| 20 | +# INCLUDES is a list of directories containing header files |
| 21 | +#------------------------------------------------------------------------------- |
| 22 | +TARGET := LoggingModule |
| 23 | +BUILD := build |
| 24 | +SOURCES := source |
| 25 | +DATA := data |
| 26 | +INCLUDES := source |
| 27 | + |
| 28 | +#------------------------------------------------------------------------------- |
| 29 | +# options for code generation |
| 30 | +#------------------------------------------------------------------------------- |
| 31 | +CFLAGS := -g -Wall -Wextra -O3 -ffunction-sections\ |
| 32 | + $(MACHDEP) |
| 33 | + |
| 34 | +CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ |
| 35 | + |
| 36 | +CXXFLAGS := $(CFLAGS) -std=c++17 |
| 37 | + |
| 38 | +ASFLAGS := -g $(ARCH) |
| 39 | +LDFLAGS = -g $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) $(WUMSSPECS) |
| 40 | + |
| 41 | +LIBS := -lwums -lwut |
| 42 | + |
| 43 | +#------------------------------------------------------------------------------- |
| 44 | +# list of directories containing libraries, this must be the top level |
| 45 | +# containing include and lib |
| 46 | +#------------------------------------------------------------------------------- |
| 47 | +LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUMS_ROOT) |
| 48 | + |
| 49 | +#------------------------------------------------------------------------------- |
| 50 | +# no real need to edit anything past this point unless you need to add additional |
| 51 | +# rules for different file extensions |
| 52 | +#------------------------------------------------------------------------------- |
| 53 | +ifneq ($(BUILD),$(notdir $(CURDIR))) |
| 54 | +#------------------------------------------------------------------------------- |
| 55 | + |
| 56 | +export OUTPUT := $(CURDIR)/$(TARGET) |
| 57 | +export TOPDIR := $(CURDIR) |
| 58 | + |
| 59 | +export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ |
| 60 | + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) |
| 61 | + |
| 62 | +export DEPSDIR := $(CURDIR)/$(BUILD) |
| 63 | + |
| 64 | +CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) |
| 65 | +CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) |
| 66 | +SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) |
| 67 | +BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) |
| 68 | + |
| 69 | +#------------------------------------------------------------------------------- |
| 70 | +# use CXX for linking C++ projects, CC for standard C |
| 71 | +#------------------------------------------------------------------------------- |
| 72 | +ifeq ($(strip $(CPPFILES)),) |
| 73 | +#------------------------------------------------------------------------------- |
| 74 | + export LD := $(CC) |
| 75 | +#------------------------------------------------------------------------------- |
| 76 | +else |
| 77 | +#------------------------------------------------------------------------------- |
| 78 | + export LD := $(CXX) |
| 79 | +#------------------------------------------------------------------------------- |
| 80 | +endif |
| 81 | +#------------------------------------------------------------------------------- |
| 82 | + |
| 83 | +export OFILES_BIN := $(addsuffix .o,$(BINFILES)) |
| 84 | +export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) |
| 85 | +export OFILES := $(OFILES_BIN) $(OFILES_SRC) |
| 86 | +export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) |
| 87 | + |
| 88 | +export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ |
| 89 | + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ |
| 90 | + -I$(CURDIR)/$(BUILD) |
| 91 | + |
| 92 | +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) |
| 93 | + |
| 94 | +.PHONY: $(BUILD) clean all |
| 95 | + |
| 96 | +#------------------------------------------------------------------------------- |
| 97 | +all: $(BUILD) |
| 98 | + |
| 99 | +$(BUILD): |
| 100 | + @[ -d $@ ] || mkdir -p $@ |
| 101 | + @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile |
| 102 | + |
| 103 | +#------------------------------------------------------------------------------- |
| 104 | +clean: |
| 105 | + @echo clean ... |
| 106 | + @rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf |
| 107 | + |
| 108 | +#------------------------------------------------------------------------------- |
| 109 | +else |
| 110 | +.PHONY: all |
| 111 | + |
| 112 | +DEPENDS := $(OFILES:.o=.d) |
| 113 | + |
| 114 | +#------------------------------------------------------------------------------- |
| 115 | +# main targets |
| 116 | +#------------------------------------------------------------------------------- |
| 117 | +all : $(OUTPUT).wms |
| 118 | + |
| 119 | +$(OUTPUT).wms : $(OUTPUT).elf |
| 120 | +$(OUTPUT).elf : $(OFILES) |
| 121 | + |
| 122 | +$(OFILES_SRC) : $(HFILES_BIN) |
| 123 | + |
| 124 | +#------------------------------------------------------------------------------- |
| 125 | +# you need a rule like this for each extension you use as binary data |
| 126 | +#------------------------------------------------------------------------------- |
| 127 | +%.bin.o %_bin.h : %.bin |
| 128 | +#------------------------------------------------------------------------------- |
| 129 | + @echo $(notdir $<) |
| 130 | + @$(bin2o) |
| 131 | + |
| 132 | +#--------------------------------------------------------------------------------- |
| 133 | +%.o: %.s |
| 134 | + @echo $(notdir $<) |
| 135 | + @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER) |
| 136 | + |
| 137 | +-include $(DEPENDS) |
| 138 | + |
| 139 | +#------------------------------------------------------------------------------- |
| 140 | +endif |
| 141 | +#------------------------------------------------------------------------------- |
0 commit comments