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