2013-03-17 21:31:00 +04:00
|
|
|
#
|
2017-01-04 19:34:25 +03:00
|
|
|
# Copyright 2011-2017 Branimir Karadzic. All rights reserved.
|
|
|
|
# License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
2013-03-17 21:31:00 +04:00
|
|
|
#
|
|
|
|
|
2014-08-18 04:20:15 +04:00
|
|
|
THISDIR:=$(dir $(lastword $(MAKEFILE_LIST)))
|
|
|
|
include $(THISDIR)/tools.mk
|
2013-03-18 03:50:33 +04:00
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
# Define SHADERS_DIR if your shader files are in a different dir than the makefile including this.
|
|
|
|
# Notice: If defined, SHADERS_DIR should end with dir slash '/'.
|
|
|
|
# Example:
|
|
|
|
# SHADERS_DIR=shader_files/
|
|
|
|
|
2013-03-17 21:31:00 +04:00
|
|
|
ifndef TARGET
|
|
|
|
.PHONY: all
|
2013-04-12 20:05:24 +04:00
|
|
|
all:
|
|
|
|
@echo Usage: make TARGET=# [clean, all, rebuild]
|
2016-10-01 22:38:41 +03:00
|
|
|
@echo " TARGET=0 (hlsl - d3d9)"
|
|
|
|
@echo " TARGET=1 (hlsl - d3d11)"
|
2016-10-01 10:08:37 +03:00
|
|
|
@echo " TARGET=2 (essl - nacl)"
|
|
|
|
@echo " TARGET=3 (essl - android)"
|
2016-10-01 22:38:41 +03:00
|
|
|
@echo " TARGET=4 (glsl)"
|
|
|
|
@echo " TARGET=5 (metal)"
|
|
|
|
@echo " TARGET=6 (pssl)"
|
|
|
|
@echo " TARGET=7 (spriv)"
|
2017-01-20 20:29:09 +03:00
|
|
|
|
|
|
|
.PHONY: rebuild
|
|
|
|
rebuild:
|
|
|
|
@make -s --no-print-directory TARGET=0 clean all
|
|
|
|
@make -s --no-print-directory TARGET=1 clean all
|
|
|
|
@make -s --no-print-directory TARGET=2 clean all
|
|
|
|
@make -s --no-print-directory TARGET=3 clean all
|
|
|
|
@make -s --no-print-directory TARGET=4 clean all
|
|
|
|
@make -s --no-print-directory TARGET=5 clean all
|
|
|
|
@make -s --no-print-directory TARGET=7 clean all
|
|
|
|
|
2013-03-17 21:31:00 +04:00
|
|
|
else
|
2013-12-21 11:03:12 +04:00
|
|
|
|
2016-10-20 04:11:47 +03:00
|
|
|
ADDITIONAL_INCLUDES?=
|
|
|
|
|
2013-03-17 21:31:00 +04:00
|
|
|
ifeq ($(TARGET), 0)
|
|
|
|
VS_FLAGS=--platform windows -p vs_3_0 -O 3
|
|
|
|
FS_FLAGS=--platform windows -p ps_3_0 -O 3
|
|
|
|
SHADER_PATH=shaders/dx9
|
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 1)
|
|
|
|
VS_FLAGS=--platform windows -p vs_4_0 -O 3
|
|
|
|
FS_FLAGS=--platform windows -p ps_4_0 -O 3
|
2014-12-20 08:09:58 +03:00
|
|
|
CS_FLAGS=--platform windows -p cs_5_0 -O 1
|
2013-03-17 21:31:00 +04:00
|
|
|
SHADER_PATH=shaders/dx11
|
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 2)
|
|
|
|
VS_FLAGS=--platform nacl
|
|
|
|
FS_FLAGS=--platform nacl
|
2016-10-01 10:08:37 +03:00
|
|
|
SHADER_PATH=shaders/essl
|
2013-03-17 21:31:00 +04:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 3)
|
|
|
|
VS_FLAGS=--platform android
|
|
|
|
FS_FLAGS=--platform android
|
2014-07-21 07:27:13 +04:00
|
|
|
CS_FLAGS=--platform android
|
2016-10-01 10:08:37 +03:00
|
|
|
SHADER_PATH=shaders/essl
|
2013-03-17 21:31:00 +04:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 4)
|
|
|
|
VS_FLAGS=--platform linux -p 120
|
|
|
|
FS_FLAGS=--platform linux -p 120
|
2014-07-21 07:27:13 +04:00
|
|
|
CS_FLAGS=--platform linux -p 430
|
2013-03-17 21:31:00 +04:00
|
|
|
SHADER_PATH=shaders/glsl
|
2015-06-13 07:10:29 +03:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 5)
|
|
|
|
VS_FLAGS=--platform osx -p metal
|
|
|
|
FS_FLAGS=--platform osx -p metal
|
|
|
|
CS_FLAGS=--platform osx -p metal
|
|
|
|
SHADER_PATH=shaders/metal
|
2016-10-01 04:16:04 +03:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 6)
|
|
|
|
VS_FLAGS=--platform orbis -p pssl
|
|
|
|
FS_FLAGS=--platform orbis -p pssl
|
|
|
|
CS_FLAGS=--platform orbis -p pssl
|
|
|
|
SHADER_PATH=shaders/pssl
|
2016-10-01 10:08:37 +03:00
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 7)
|
|
|
|
VS_FLAGS=--platform linux -p spirv
|
|
|
|
FS_FLAGS=--platform linux -p spirv
|
|
|
|
CS_FLAGS=--platform linux -p spirv
|
|
|
|
SHADER_PATH=shaders/spirv
|
|
|
|
endif
|
2016-10-01 04:16:04 +03:00
|
|
|
endif
|
2015-06-13 07:10:29 +03:00
|
|
|
endif
|
2013-03-17 21:31:00 +04:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2013-04-02 09:52:06 +04:00
|
|
|
THISDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
2016-10-20 04:11:47 +03:00
|
|
|
VS_FLAGS+=-i $(THISDIR)../src/ $(ADDITIONAL_INCLUDES)
|
|
|
|
FS_FLAGS+=-i $(THISDIR)../src/ $(ADDITIONAL_INCLUDES)
|
|
|
|
CS_FLAGS+=-i $(THISDIR)../src/ $(ADDITIONAL_INCLUDES)
|
2013-04-02 09:52:06 +04:00
|
|
|
|
2013-03-17 21:31:00 +04:00
|
|
|
BUILD_OUTPUT_DIR=$(addprefix ./, $(RUNTIME_DIR)/$(SHADER_PATH))
|
|
|
|
BUILD_INTERMEDIATE_DIR=$(addprefix $(BUILD_DIR)/, $(SHADER_PATH))
|
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
VS_SOURCES=$(notdir $(wildcard $(addprefix $(SHADERS_DIR), vs_*.sc)))
|
|
|
|
VS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(notdir $(VS_SOURCES)))))
|
2013-03-17 21:31:00 +04:00
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
FS_SOURCES=$(notdir $(wildcard $(addprefix $(SHADERS_DIR), fs_*.sc)))
|
|
|
|
FS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(notdir $(FS_SOURCES)))))
|
2013-03-17 21:31:00 +04:00
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
CS_SOURCES=$(notdir $(wildcard $(addprefix $(SHADERS_DIR), cs_*.sc)))
|
|
|
|
CS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(notdir $(CS_SOURCES)))))
|
2014-07-21 07:27:13 +04:00
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
VS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(notdir $(VS_SOURCES)))))
|
|
|
|
FS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(notdir $(FS_SOURCES)))))
|
|
|
|
CS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(notdir $(CS_SOURCES)))))
|
2013-03-17 21:31:00 +04:00
|
|
|
|
|
|
|
BIN = $(VS_BIN) $(FS_BIN)
|
|
|
|
ASM = $(VS_ASM) $(FS_ASM)
|
|
|
|
|
2014-07-21 07:27:13 +04:00
|
|
|
ifeq ($(TARGET), 1)
|
|
|
|
BIN += $(CS_BIN)
|
|
|
|
ASM += $(CS_ASM)
|
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 3)
|
|
|
|
BIN += $(CS_BIN)
|
|
|
|
ASM += $(CS_ASM)
|
|
|
|
else
|
|
|
|
ifeq ($(TARGET), 4)
|
|
|
|
BIN += $(CS_BIN)
|
|
|
|
ASM += $(CS_ASM)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
$(BUILD_INTERMEDIATE_DIR)/vs_%.bin : $(SHADERS_DIR)vs_%.sc
|
2013-03-17 21:31:00 +04:00
|
|
|
@echo [$(<)]
|
2013-03-18 03:50:33 +04:00
|
|
|
$(SILENT) $(SHADERC) $(VS_FLAGS) --type vertex --depends -o $(@) -f $(<) --disasm
|
|
|
|
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
|
2013-03-17 21:31:00 +04:00
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
$(BUILD_INTERMEDIATE_DIR)/fs_%.bin : $(SHADERS_DIR)fs_%.sc
|
2013-03-17 21:31:00 +04:00
|
|
|
@echo [$(<)]
|
2013-03-18 03:50:33 +04:00
|
|
|
$(SILENT) $(SHADERC) $(FS_FLAGS) --type fragment --depends -o $(@) -f $(<) --disasm
|
|
|
|
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
|
2013-03-17 21:31:00 +04:00
|
|
|
|
2016-02-02 03:22:54 +03:00
|
|
|
$(BUILD_INTERMEDIATE_DIR)/cs_%.bin : $(SHADERS_DIR)cs_%.sc
|
2014-07-21 07:27:13 +04:00
|
|
|
@echo [$(<)]
|
|
|
|
$(SILENT) $(SHADERC) $(CS_FLAGS) --type compute --depends -o $(@) -f $(<) --disasm
|
|
|
|
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
|
|
|
|
|
2013-03-17 21:31:00 +04:00
|
|
|
.PHONY: all
|
|
|
|
all: dirs $(BIN)
|
|
|
|
@echo Target $(SHADER_PATH)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@echo Cleaning...
|
|
|
|
@-rm -vf $(BIN)
|
|
|
|
@-$(call CMD_RMDIR,$(BUILD_INTERMEDIATE_DIR))
|
|
|
|
|
|
|
|
.PHONY: dirs
|
|
|
|
dirs:
|
|
|
|
@-$(call CMD_MKDIR,$(BUILD_INTERMEDIATE_DIR))
|
|
|
|
@-$(call CMD_MKDIR,$(BUILD_OUTPUT_DIR))
|
|
|
|
|
|
|
|
.PHONY: rebuild
|
|
|
|
rebuild: clean all
|
|
|
|
|
|
|
|
endif # TARGET
|
|
|
|
|
|
|
|
-include $(VS_DEPS)
|
|
|
|
-include $(FS_DEPS)
|
2014-07-21 07:27:13 +04:00
|
|
|
-include $(CS_DEPS)
|