bgfx/scripts/shader.mk

131 lines
3.3 KiB
Makefile
Raw Normal View History

2013-03-17 13:31:00 -04:00
#
2015-01-02 17:43:11 -05:00
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
2013-03-17 13:31:00 -04:00
# License: http://www.opensource.org/licenses/BSD-2-Clause
#
THISDIR:=$(dir $(lastword $(MAKEFILE_LIST)))
include $(THISDIR)/tools.mk
2013-03-17 19:50:33 -04:00
2013-03-17 13:31:00 -04:00
ifndef TARGET
.PHONY: all
2013-04-12 12:05:24 -04:00
all:
@echo Usage: make TARGET=# [clean, all, rebuild]
2013-03-17 19:50:33 -04:00
@echo " TARGET=0 (hlsl - dx9)"
@echo " TARGET=1 (hlsl - dx11)"
@echo " TARGET=2 (glsl - nacl)"
@echo " TARGET=3 (glsl - android)"
@echo " TARGET=4 (glsl - linux)"
@echo " VERBOSE=1 show build commands."
2013-03-17 13:31:00 -04:00
else
2013-03-17 13: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 00:09:58 -05:00
CS_FLAGS=--platform windows -p cs_5_0 -O 1
2013-03-17 13:31:00 -04:00
SHADER_PATH=shaders/dx11
else
ifeq ($(TARGET), 2)
VS_FLAGS=--platform nacl
FS_FLAGS=--platform nacl
SHADER_PATH=shaders/gles
else
ifeq ($(TARGET), 3)
VS_FLAGS=--platform android
FS_FLAGS=--platform android
2014-07-20 23:27:13 -04:00
CS_FLAGS=--platform android
2013-03-17 13:31:00 -04:00
SHADER_PATH=shaders/gles
else
ifeq ($(TARGET), 4)
VS_FLAGS=--platform linux -p 120
FS_FLAGS=--platform linux -p 120
2014-07-20 23:27:13 -04:00
CS_FLAGS=--platform linux -p 430
2013-03-17 13:31:00 -04:00
SHADER_PATH=shaders/glsl
endif
endif
endif
endif
endif
THISDIR := $(dir $(lastword $(MAKEFILE_LIST)))
VS_FLAGS+=-i $(THISDIR)../src/
FS_FLAGS+=-i $(THISDIR)../src/
2014-07-20 23:27:13 -04:00
CS_FLAGS+=-i $(THISDIR)../src/
2013-03-17 13:31:00 -04:00
BUILD_OUTPUT_DIR=$(addprefix ./, $(RUNTIME_DIR)/$(SHADER_PATH))
BUILD_INTERMEDIATE_DIR=$(addprefix $(BUILD_DIR)/, $(SHADER_PATH))
VS_SOURCES=$(wildcard vs_*.sc)
VS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(VS_SOURCES))))
FS_SOURCES=$(wildcard fs_*.sc)
FS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(FS_SOURCES))))
2014-07-20 23:27:13 -04:00
CS_SOURCES=$(wildcard cs_*.sc)
CS_DEPS=$(addprefix $(BUILD_INTERMEDIATE_DIR)/,$(addsuffix .bin.d, $(basename $(CS_SOURCES))))
2013-03-17 13:31:00 -04:00
VS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(VS_SOURCES))))
FS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(FS_SOURCES))))
2014-07-20 23:27:13 -04:00
CS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(CS_SOURCES))))
2013-03-17 13:31:00 -04:00
BIN = $(VS_BIN) $(FS_BIN)
ASM = $(VS_ASM) $(FS_ASM)
2014-07-20 23: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
2013-03-17 13:31:00 -04:00
$(BUILD_INTERMEDIATE_DIR)/vs_%.bin : vs_%.sc
@echo [$(<)]
2013-03-17 19:50:33 -04:00
$(SILENT) $(SHADERC) $(VS_FLAGS) --type vertex --depends -o $(@) -f $(<) --disasm
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
2013-03-17 13:31:00 -04:00
$(BUILD_INTERMEDIATE_DIR)/fs_%.bin : fs_%.sc
@echo [$(<)]
2013-03-17 19:50:33 -04:00
$(SILENT) $(SHADERC) $(FS_FLAGS) --type fragment --depends -o $(@) -f $(<) --disasm
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
2013-03-17 13:31:00 -04:00
2014-07-20 23:27:13 -04:00
$(BUILD_INTERMEDIATE_DIR)/cs_%.bin : cs_%.sc
@echo [$(<)]
$(SILENT) $(SHADERC) $(CS_FLAGS) --type compute --depends -o $(@) -f $(<) --disasm
$(SILENT) cp $(@) $(BUILD_OUTPUT_DIR)/$(@F)
2013-03-17 13: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-20 23:27:13 -04:00
-include $(CS_DEPS)