Makefile revision b2f18cd2b0f75d200d4fc713325269171ac87616
1# src/gallium/targets/egl-static/Makefile
2#
3# This is Makefile for egl_gallium.so.  It is static in that all state trackers
4# and pipe drivers are linked statically when possible.
5#
6# The following variables are examined
7#
8#   EGL_PLATFORMS       - platforms to support
9#   EGL_CLIENT_APIS     - state trackers to support
10#   GALLIUM_WINSYS_DIRS - pipe drivers to support
11#   SHARED_GLAPI        - st/mesa can be statically linked or not
12#
13
14TOP = ../../../..
15include $(TOP)/configs/current
16
17OUTPUTS := egl_gallium
18
19egl_CPPFLAGS := \
20	-I$(TOP)/include \
21	-I$(TOP)/src/gallium/auxiliary \
22	-I$(TOP)/src/gallium/drivers \
23	-I$(TOP)/src/gallium/include \
24	-I$(TOP)/src/gallium/winsys
25egl_LIBS := \
26	$(TOP)/src/gallium/drivers/identity/libidentity.a \
27	$(TOP)/src/gallium/drivers/trace/libtrace.a \
28	$(TOP)/src/gallium/drivers/rbug/librbug.a \
29	$(GALLIUM_AUXILIARIES)
30egl_SYS :=
31
32egl_SOURCES := \
33	egl.c \
34	egl_pipe.c \
35	egl_st.c
36
37egl_OBJECTS := $(egl_SOURCES:%.c=%.o)
38
39# st/egl
40egl_CPPFLAGS += \
41	-I$(TOP)/src/gallium/state_trackers/egl \
42	-I$(TOP)/src/egl/main \
43	-D_EGL_MAIN=_eglMain
44egl_LIBS += $(TOP)/src/gallium/state_trackers/egl/libegl.a
45egl_SYS += $(LIBUDEV_LIBS) $(DLOPEN_LIBS) -lEGL -lm -lpthread
46
47# EGL platforms
48ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
49egl_CPPFLAGS += $(LIBDRM_CFLAGS)
50egl_LIBS += $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a
51egl_SYS += -lX11 -lXext -lXfixes $(LIBDRM_LIBS)
52endif
53ifneq ($(findstring wayland, $(EGL_PLATFORMS)),)
54egl_CPPFLAGS += $(LIBDRM_CFLAGS)
55egl_LIBS += $(TOP)/src/gallium/winsys/sw/wayland/libws_wayland.a
56egl_LIBS += $(TOP)/src/egl/wayland/wayland-drm/.libs/libwayland-drm.a
57egl_SYS += $(LIBDRM_LIBS) $(WAYLAND_LIBS)
58endif
59ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
60egl_CPPFLAGS += $(LIBDRM_CFLAGS)
61egl_SYS += $(LIBDRM_LIBS) -lgbm
62endif
63ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
64egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a
65endif
66ifneq ($(findstring null, $(EGL_PLATFORMS)),)
67egl_LIBS += $(TOP)/src/gallium/winsys/sw/null/libws_null.a
68endif
69
70# st/mesa
71ifneq ($(filter $(GL_LIB), $(EGL_CLIENT_APIS)),)
72egl_CPPFLAGS += -I$(TOP)/src/mesa $(API_DEFINES)
73# make st/mesa built-in when there is a single glapi provider
74ifeq ($(SHARED_GLAPI),1)
75egl_LIBS += $(TOP)/src/mesa/libmesagallium.a
76egl_SYS += -lm -lpthread $(DLOPEN_LIBS) -l$(GLAPI_LIB)
77else
78egl_CPPFLAGS += -D_EGL_EXTERNAL_GL=1
79OUTPUTS += st_GL
80endif # SHARED_GLAPI
81endif
82
83# st/vega
84ifneq ($(filter $(VG_LIB), $(EGL_CLIENT_APIS)),)
85egl_CPPFLAGS += -I$(TOP)/src/gallium/state_trackers/vega -DFEATURE_VG=1
86egl_LIBS += $(TOP)/src/gallium/state_trackers/vega/libvega.a
87egl_SYS += -lm -l$(VG_LIB)
88endif
89
90# i915
91ifneq ($(findstring i915/drm,$(GALLIUM_WINSYS_DIRS)),)
92egl_CPPFLAGS += -D_EGL_PIPE_I915=1
93egl_LIBS += \
94	$(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
95	$(TOP)/src/gallium/drivers/i915/libi915.a
96egl_SYS += $(INTEL_LIBS)
97endif
98
99# nouveau
100ifneq ($(findstring nouveau/drm,$(GALLIUM_WINSYS_DIRS)),)
101egl_CPPFLAGS += -D_EGL_PIPE_NOUVEAU=1
102egl_LIBS += \
103	$(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
104	$(TOP)/src/gallium/drivers/nv30/libnv30.a \
105	$(TOP)/src/gallium/drivers/nv50/libnv50.a \
106	$(TOP)/src/gallium/drivers/nvc0/libnvc0.a \
107	$(TOP)/src/gallium/drivers/nouveau/libnouveau.a
108egl_SYS += $(NOUVEAU_LIBS)
109endif
110
111# r300
112ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
113ifneq ($(findstring r300,$(GALLIUM_DRIVERS_DIRS)),)
114egl_CPPFLAGS += -D_EGL_PIPE_R300=1
115egl_LIBS += \
116	$(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
117	$(TOP)/src/gallium/drivers/r300/libr300.a
118egl_SYS += $(RADEON_LIBS)
119endif
120endif
121
122# r600
123ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
124ifneq ($(findstring r600,$(GALLIUM_DRIVERS_DIRS)),)
125egl_CPPFLAGS += -D_EGL_PIPE_R600=1
126egl_LIBS += \
127	$(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
128	$(TOP)/src/gallium/drivers/r600/libr600.a
129egl_SYS += $(RADEON_LIBS)
130endif
131endif
132
133# radeonsi
134ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
135ifneq ($(findstring radeonsi,$(GALLIUM_DRIVERS_DIRS)),)
136egl_CPPFLAGS += -D_EGL_PIPE_RADEONSI=1
137egl_LIBS += \
138	$(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
139	$(TOP)/src/gallium/drivers/radeonsi/libradeonsi.a
140egl_SYS += $(RADEON_LIBS)
141endif
142endif
143
144# vmwgfx
145ifneq ($(findstring svga/drm,$(GALLIUM_WINSYS_DIRS)),)
146egl_CPPFLAGS += -D_EGL_PIPE_VMWGFX=1
147egl_LIBS += \
148	$(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
149	$(TOP)/src/gallium/drivers/svga/libsvga.a
150endif
151
152# softpipe
153ifneq ($(findstring softpipe,$(GALLIUM_DRIVERS_DIRS)),)
154egl_CPPFLAGS += -DGALLIUM_SOFTPIPE -DGALLIUM_RBUG -DGALLIUM_TRACE
155egl_LIBS += $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
156egl_SYS += -lm
157endif
158
159# llvmpipe
160ifneq ($(findstring llvmpipe,$(GALLIUM_DRIVERS_DIRS)),)
161egl_CPPFLAGS += -DGALLIUM_LLVMPIPE
162egl_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
163endif
164
165# sort to remove duplicates
166egl_CPPFLAGS := $(sort $(egl_CPPFLAGS))
167egl_LIBS := $(sort $(egl_LIBS))
168egl_SYS := $(sort $(egl_SYS))
169
170# st_GL, built only when shared glapi is not enabled
171st_GL_CPPFLAGS := -I $(TOP)/src/mesa -I$(TOP)/src/gallium/include
172st_GL_LIBS := $(TOP)/src/mesa/libmesagallium.a $(GALLIUM_AUXILIARIES)
173st_GL_SYS := -lm -lpthread $(DLOPEN_LIBS)
174
175# LLVM
176ifeq ($(MESA_LLVM),1)
177egl_SYS += $(LLVM_LIBS)
178LDFLAGS += $(LLVM_LDFLAGS)
179
180st_GL_SYS += $(LLVM_LIBS)
181endif
182
183OUTPUT_PATH := $(TOP)/$(LIB_DIR)/egl
184OUTPUTS := $(addprefix $(OUTPUT_PATH)/, $(addsuffix .so, $(OUTPUTS)))
185
186default: $(OUTPUTS)
187
188$(OUTPUT_PATH)/egl_gallium.so: $(egl_OBJECTS) $(egl_LIBS)
189	$(MKLIB) -o $(notdir $@) -noprefix -linker '$(CXX)' \
190		-ldflags '-L$(TOP)/$(LIB_DIR) -Wl,--no-undefined $(LDFLAGS)' \
191		-cplusplus -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) \
192		$(egl_OBJECTS) -Wl,--start-group $(egl_LIBS) -Wl,--end-group \
193		$(egl_SYS)
194
195$(OUTPUT_PATH)/st_GL.so: st_GL.o $(st_GL_LIBS)
196	$(MKLIB) -o $(notdir $@) -noprefix -linker '$(CXX)' \
197		-ldflags '-L$(TOP)/$(LIB_DIR) $(LDFLAGS)' \
198		-cplusplus -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) \
199		$< -Wl,--start-group $(st_GL_LIBS) -Wl,--end-group \
200		$(st_GL_SYS)
201
202$(egl_OBJECTS): %.o: %.c
203	$(CC) -c -o $@ $< $(egl_CPPFLAGS) $(DEFINES) $(CFLAGS)
204
205st_GL.o: st_GL.c
206	$(CC) -c -o $@ $< $(st_GL_CPPFLAGS) $(DEFINES) $(CFLAGS)
207
208install: $(OUTPUTS)
209	$(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
210	for out in $(OUTPUTS); do \
211		$(MINSTALL) -m 755 "$$out" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
212	done
213
214clean:
215	rm -f *.o
216