Mercurial > remote-gamepad
comparison Makefile @ 0:4e831ec746e4
Hello world!
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
|---|---|
| date | Sun, 22 Feb 2015 17:41:32 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4e831ec746e4 |
|---|---|
| 1 #--------------------------------------------------------------------------------- | |
| 2 .SUFFIXES: | |
| 3 #--------------------------------------------------------------------------------- | |
| 4 | |
| 5 ifeq ($(strip $(DEVKITARM)),) | |
| 6 $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") | |
| 7 endif | |
| 8 | |
| 9 TOPDIR ?= $(CURDIR) | |
| 10 include $(DEVKITARM)/3ds_rules | |
| 11 | |
| 12 #--------------------------------------------------------------------------------- | |
| 13 # TARGET is the name of the output | |
| 14 # BUILD is the directory where object files & intermediate files will be placed | |
| 15 # SOURCES is a list of directories containing source code | |
| 16 # DATA is a list of directories containing data files | |
| 17 # INCLUDES is a list of directories containing header files | |
| 18 # | |
| 19 # NO_SMDH: if set to anything, no SMDH file is generated. | |
| 20 # APP_TITLE is the name of the app stored in the SMDH file (Optional) | |
| 21 # APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional) | |
| 22 # APP_AUTHOR is the author of the app stored in the SMDH file (Optional) | |
| 23 # ICON is the filename of the icon (.png), relative to the project folder. | |
| 24 # If not set, it attempts to use one of the following (in this order): | |
| 25 # - <Project name>.png | |
| 26 # - icon.png | |
| 27 # - <libctru folder>/default_icon.png | |
| 28 #--------------------------------------------------------------------------------- | |
| 29 TARGET := $(notdir $(CURDIR)) | |
| 30 BUILD := build | |
| 31 SOURCES := source | |
| 32 DATA := data | |
| 33 INCLUDES := include | |
| 34 | |
| 35 #--------------------------------------------------------------------------------- | |
| 36 # options for code generation | |
| 37 #--------------------------------------------------------------------------------- | |
| 38 ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard | |
| 39 | |
| 40 CFLAGS := -g -Wall -O2 -std=gnu11 -mword-relocations \ | |
| 41 -fomit-frame-pointer -ffast-math \ | |
| 42 $(ARCH) | |
| 43 | |
| 44 CFLAGS += $(INCLUDE) -DARM11 -D_3DS | |
| 45 | |
| 46 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 | |
| 47 | |
| 48 ASFLAGS := -g $(ARCH) | |
| 49 LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) | |
| 50 | |
| 51 LIBS := -lctru -lm | |
| 52 | |
| 53 #--------------------------------------------------------------------------------- | |
| 54 # list of directories containing libraries, this must be the top level containing | |
| 55 # include and lib | |
| 56 #--------------------------------------------------------------------------------- | |
| 57 LIBDIRS := $(CTRULIB) | |
| 58 | |
| 59 | |
| 60 #--------------------------------------------------------------------------------- | |
| 61 # no real need to edit anything past this point unless you need to add additional | |
| 62 # rules for different file extensions | |
| 63 #--------------------------------------------------------------------------------- | |
| 64 ifneq ($(BUILD),$(notdir $(CURDIR))) | |
| 65 #--------------------------------------------------------------------------------- | |
| 66 | |
| 67 export OUTPUT := $(CURDIR)/$(TARGET) | |
| 68 export TOPDIR := $(CURDIR) | |
| 69 | |
| 70 export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ | |
| 71 $(foreach dir,$(DATA),$(CURDIR)/$(dir)) | |
| 72 | |
| 73 export DEPSDIR := $(CURDIR)/$(BUILD) | |
| 74 | |
| 75 CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) | |
| 76 CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) | |
| 77 SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) | |
| 78 BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) | |
| 79 | |
| 80 #--------------------------------------------------------------------------------- | |
| 81 # use CXX for linking C++ projects, CC for standard C | |
| 82 #--------------------------------------------------------------------------------- | |
| 83 ifeq ($(strip $(CPPFILES)),) | |
| 84 #--------------------------------------------------------------------------------- | |
| 85 export LD := $(CC) | |
| 86 #--------------------------------------------------------------------------------- | |
| 87 else | |
| 88 #--------------------------------------------------------------------------------- | |
| 89 export LD := $(CXX) | |
| 90 #--------------------------------------------------------------------------------- | |
| 91 endif | |
| 92 #--------------------------------------------------------------------------------- | |
| 93 | |
| 94 export OFILES := $(addsuffix .o,$(BINFILES)) \ | |
| 95 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) | |
| 96 | |
| 97 export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ | |
| 98 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | |
| 99 -I$(CURDIR)/$(BUILD) | |
| 100 | |
| 101 export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | |
| 102 | |
| 103 ifeq ($(strip $(ICON)),) | |
| 104 icons := $(wildcard *.png) | |
| 105 ifneq (,$(findstring $(TARGET).png,$(icons))) | |
| 106 export APP_ICON := $(TOPDIR)/$(TARGET).png | |
| 107 else | |
| 108 ifneq (,$(findstring icon.png,$(icons))) | |
| 109 export APP_ICON := $(TOPDIR)/icon.png | |
| 110 endif | |
| 111 endif | |
| 112 else | |
| 113 export APP_ICON := $(TOPDIR)/$(ICON) | |
| 114 endif | |
| 115 | |
| 116 .PHONY: $(BUILD) clean all | |
| 117 | |
| 118 #--------------------------------------------------------------------------------- | |
| 119 all: $(BUILD) | |
| 120 | |
| 121 $(BUILD): | |
| 122 @[ -d $@ ] || mkdir -p $@ | |
| 123 @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | |
| 124 | |
| 125 #--------------------------------------------------------------------------------- | |
| 126 clean: | |
| 127 @echo clean ... | |
| 128 @rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf | |
| 129 | |
| 130 | |
| 131 #--------------------------------------------------------------------------------- | |
| 132 else | |
| 133 | |
| 134 DEPENDS := $(OFILES:.o=.d) | |
| 135 | |
| 136 #--------------------------------------------------------------------------------- | |
| 137 # main targets | |
| 138 #--------------------------------------------------------------------------------- | |
| 139 ifeq ($(strip $(NO_SMDH)),) | |
| 140 .PHONY: all | |
| 141 all : $(OUTPUT).3dsx $(OUTPUT).smdh | |
| 142 endif | |
| 143 $(OUTPUT).3dsx : $(OUTPUT).elf | |
| 144 $(OUTPUT).elf : $(OFILES) | |
| 145 | |
| 146 #--------------------------------------------------------------------------------- | |
| 147 # you need a rule like this for each extension you use as binary data | |
| 148 #--------------------------------------------------------------------------------- | |
| 149 %.bin.o : %.bin | |
| 150 #--------------------------------------------------------------------------------- | |
| 151 @echo $(notdir $<) | |
| 152 @$(bin2o) | |
| 153 | |
| 154 # WARNING: This is not the right way to do this! TODO: Do it right! | |
| 155 #--------------------------------------------------------------------------------- | |
| 156 %.vsh.o : %.vsh | |
| 157 #--------------------------------------------------------------------------------- | |
| 158 @echo $(notdir $<) | |
| 159 @python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin | |
| 160 @bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@ | |
| 161 @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h | |
| 162 @echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h | |
| 163 @echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h | |
| 164 @rm ../$(notdir $<).shbin | |
| 165 | |
| 166 -include $(DEPENDS) | |
| 167 | |
| 168 #--------------------------------------------------------------------------------------- | |
| 169 endif | |
| 170 #--------------------------------------------------------------------------------------- |
