libctru/examples/graphics/gpu/geoshader/Makefile

178 lines
6.7 KiB
Makefile
Raw Normal View History

2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
2014-08-26 06:47:50 +02:00
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
2014-08-26 06:47:50 +02:00
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
# 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
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
2014-08-26 06:47:50 +02:00
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
2015-02-15 02:26:16 +01:00
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
2014-08-26 06:47:50 +02:00
CFLAGS := -g -Wall -O2 -mword-relocations \
2014-11-08 13:49:39 +01:00
-fomit-frame-pointer -ffast-math \
2014-08-26 06:47:50 +02:00
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
2014-08-26 06:47:50 +02:00
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
2014-08-26 06:47:50 +02:00
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
2015-07-22 19:41:59 +02:00
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pica)))
2014-08-26 06:47:50 +02:00
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
2014-03-11 17:09:39 +01:00
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
2015-07-22 19:41:59 +02:00
export OFILES := $(addsuffix .o,$(BINFILES)) $(PICAFILES:.pica=.shbin.o) \
2014-08-26 06:47:50 +02:00
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
2015-03-01 17:39:08 +01:00
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
2014-08-26 06:47:50 +02:00
.PHONY: $(BUILD) clean all
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
2015-02-18 12:59:53 +01:00
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
else
2014-08-26 06:47:50 +02:00
DEPENDS := $(OFILES:.o=.d)
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
2015-03-01 17:56:10 +01:00
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
else
$(OUTPUT).3dsx : $(OUTPUT).elf
2015-03-01 17:56:10 +01:00
endif
2014-08-26 06:47:50 +02:00
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
2015-07-22 19:41:59 +02:00
# rule for assembling GPU shaders
#---------------------------------------------------------------------------------
2015-07-22 19:41:59 +02:00
%.shbin.o: %.pica
@echo $(notdir $<)
2015-07-22 19:41:59 +02:00
$(eval CURBIN := $(patsubst %.pica,%.shbin,$(notdir $<)))
$(eval CURH := $(patsubst %.pica,%.psh.h,$(notdir $<)))
@picasso -h $(CURH) -o $(CURBIN) $<
2015-07-22 19:41:59 +02:00
@bin2s $(CURBIN) | $(AS) -o $@
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
2014-08-26 06:47:50 +02:00
-include $(DEPENDS)
2014-08-26 06:47:50 +02:00
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------