summaryrefslogtreecommitdiffstats
path: root/src/mesa/es/Makefile
blob: 426799abf1b46451f2686beed8b906469b388472 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# src/mesa/es/Makefile
#
TOP := ../../..
MESA := ..

include $(TOP)/configs/current
include sources.mak

ES1_LIBS := libes1gallium.a
ES2_LIBS := libes2gallium.a

# Default rule: create ES1 and ES2 libs
.PHONY: default subdirs es1 es2
default: depend subdirs es1 es2

es1: $(ES1_LIBS)

es2: $(ES2_LIBS)

ES1_CPPFLAGS := -DFEATURE_ES1=1 -D__GL_EXPORTS
ES2_CPPFLAGS := -DFEATURE_ES2=1 -D__GL_EXPORTS

ES1_OBJ_DIR := objs-es1
ES2_OBJ_DIR := objs-es2

# adjust output dirs
ES1_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_OBJECTS))
ES1_GALLIUM_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_GALLIUM_OBJECTS))

ES2_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_OBJECTS))
ES2_GALLIUM_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_GALLIUM_OBJECTS))

# compile either ES1 or ES2 sources
define es-compile
	@mkdir -p $(dir $@)
	$(CC) -c $(CFLAGS) $(ES$(1)_CPPFLAGS) $(ES$(1)_INCLUDES) -o $@ $<
endef

$(ES1_OBJ_DIR)/%.o: %.c
	$(call es-compile,1)

$(ES1_OBJ_DIR)/%.o: %.S
	$(call es-compile,1)

$(ES1_OBJ_DIR)/%.o: $(MESA)/%.c
	$(call es-compile,1)

$(ES1_OBJ_DIR)/%.o: $(MESA)/%.S
	$(call es-compile,1)

$(ES2_OBJ_DIR)/%.o: %.c
	$(call es-compile,2)

$(ES2_OBJ_DIR)/%.o: %.S
	$(call es-compile,2)

$(ES2_OBJ_DIR)/%.o: $(MESA)/%.c
	$(call es-compile,2)

$(ES2_OBJ_DIR)/%.o: $(MESA)/%.S
	$(call es-compile,2)

libes1.a: $(ES1_OBJECTS) $(GLSL_LIBS)
	@$(MKLIB) -o es1 -static $(ES1_OBJECTS) $(GLSL_LIBS)

libes2.a: $(ES2_OBJECTS) $(GLSL_LIBS)
	@$(MKLIB) -o es2 -static $(ES1_OBJECTS) $(GLSL_LIBS)

libes1gallium.a: $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS)
	@$(MKLIB) -o es1gallium -static $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS)

libes2gallium.a: $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS)
	@$(MKLIB) -o es2gallium -static $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS)

.PHONY: clean
clean:
	-rm -f $(ES1_LIBS) $(ES2_LIBS)
	-rm -rf $(ES1_OBJ_DIR) $(ES2_OBJ_DIR)
	-rm -f depend depend.bak

# nothing to install
install:

subdirs:
	@$(MAKE) -C $(MESA) asm_subdirs
	@$(MAKE) -C $(MESA) glsl_builtin

# sort to avoid duplicates
ALL_SOURCES := $(sort $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES))

depend: $(ALL_SOURCES)
	@echo "running $(MKDEP)"
	@touch depend
	@# MESA is "..", but luckily, directories are longer than 2 characters
	@$(MKDEP) -f- -p$(ES1_OBJ_DIR)/ $(DEFINES) $(ES1_CFLAGS) \
		$(ES1_INCLUDES) $(ES1_ALL_SOURCES) 2>/dev/null | \
		sed -e 's,^$(ES1_OBJ_DIR)/$(MESA)/,$(ES1_OBJ_DIR)/,' > depend
	@$(MKDEP) -f- -p$(ES2_OBJ_DIR)/ $(DEFINES) $(ES2_CFLAGS) \
		$(ES2_INCLUDES) $(ES2_ALL_SOURCES) 2>/dev/null | \
		sed -e 's,^$(ES2_OBJ_DIR)/$(MESA)/,$(ES2_OBJ_DIR)/,' >> depend

ifneq ($(MAKECMDGOALS),clean)
-include depend
endif