targets/egl: Fix linking with libdrm.
[mesa.git] / src / gallium / targets / egl / Makefile
1 # src/gallium/targets/egl/Makefile
2 #
3 # This is the Makefile for EGL Gallium driver package. The package consists of
4 #
5 # egl_gallium.so - EGL driver
6 # pipe_<HW>.so - pipe drivers
7 # st_<API>.so - client API state trackers
8 #
9 # The following variables are examined
10 #
11 # EGL_PLATFORMS - platforms to support
12 # GALLIUM_WINSYS_DIRS - pipe drivers to support
13 # EGL_CLIENT_APIS - state trackers to support
14 #
15
16 TOP = ../../../..
17 include $(TOP)/configs/current
18
19 ST_PREFIX := st_
20 PIPE_PREFIX := pipe_
21
22 common_CPPFLAGS := \
23 -I$(TOP)/include \
24 -I$(TOP)/src/gallium/auxiliary \
25 -I$(TOP)/src/gallium/drivers \
26 -I$(TOP)/src/gallium/include \
27 -I$(TOP)/src/gallium/winsys \
28 $(LIBDRM_CFLAGS)
29
30 common_SYS :=
31 common_LIBS := \
32 $(TOP)/src/gallium/drivers/identity/libidentity.a \
33 $(TOP)/src/gallium/drivers/trace/libtrace.a \
34 $(TOP)/src/gallium/drivers/rbug/librbug.a \
35 $(GALLIUM_AUXILIARIES)
36
37 # EGL driver
38 egl_CPPFLAGS := \
39 -I$(TOP)/src/gallium/state_trackers/egl \
40 -I$(TOP)/src/egl/main \
41 -DPIPE_PREFIX=\"$(PIPE_PREFIX)\" -DST_PREFIX=\"$(ST_PREFIX)\"
42 egl_SYS := -lm $(DLOPEN_LIBS) -L$(TOP)/$(LIB_DIR) -lEGL
43 egl_LIBS := $(TOP)/src/gallium/state_trackers/egl/libegl.a
44
45 ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
46 egl_SYS += -lX11 -lXext -lXfixes $(LIBDRM_LIB)
47 egl_LIBS += $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a
48 endif
49 ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
50 egl_SYS += $(LIBDRM_LIB)
51 endif
52 ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
53 egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a
54 endif
55
56 # EGL_RENDERABLE_TYPE is a compile time attribute
57 egl_CPPFLAGS += $(API_DEFINES)
58 ifneq ($(filter $(GL_LIB), $(EGL_CLIENT_APIS)),)
59 egl_CPPFLAGS += -DFEATURE_GL=1
60 endif
61 ifneq ($(filter $(GLESv1_CM_LIB), $(EGL_CLIENT_APIS)),)
62 egl_CPPFLAGS += -DFEATURE_ES1=1
63 endif
64 ifneq ($(filter $(GLESv2_LIB), $(EGL_CLIENT_APIS)),)
65 egl_CPPFLAGS += -DFEATURE_ES2=1
66 endif
67 ifneq ($(filter $(VG_LIB), $(EGL_CLIENT_APIS)),)
68 egl_CPPFLAGS += -DFEATURE_VG=1
69 endif
70 egl_CPPFLAGS := $(sort $(egl_CPPFLAGS))
71
72 # i915 pipe driver
73 i915_CPPFLAGS :=
74 i915_SYS := -ldrm_intel
75 i915_LIBS := \
76 $(TOP)/src/gallium/winsys/i915/drm/libi915drm.a \
77 $(TOP)/src/gallium/drivers/i915/libi915.a
78
79 # i965 pipe driver
80 i965_CPPFLAGS :=
81 i965_SYS := -ldrm_intel
82 i965_LIBS := \
83 $(TOP)/src/gallium/winsys/i965/drm/libi965drm.a \
84 $(TOP)/src/gallium/drivers/i965/libi965.a
85
86 # nouveau pipe driver
87 nouveau_CPPFLAGS :=
88 nouveau_SYS := -ldrm_nouveau
89 nouveau_LIBS := \
90 $(TOP)/src/gallium/winsys/nouveau/drm/libnouveaudrm.a \
91 $(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
92 $(TOP)/src/gallium/drivers/nv50/libnv50.a \
93 $(TOP)/src/gallium/drivers/nouveau/libnouveau.a
94
95 # r300 pipe driver
96 r300_CPPFLAGS :=
97 r300_SYS := -ldrm -ldrm_radeon
98 r300_LIBS := \
99 $(TOP)/src/gallium/winsys/radeon/drm/libradeonwinsys.a \
100 $(TOP)/src/gallium/drivers/r300/libr300.a
101
102 # r600 pipe driver
103 r600_CPPFLAGS :=
104 r600_SYS := -ldrm -ldrm_radeon
105 r600_LIBS := \
106 $(TOP)/src/gallium/winsys/r600/drm/libr600winsys.a \
107 $(TOP)/src/gallium/drivers/r600/libr600.a
108
109 # vmwgfx pipe driver
110 vmwgfx_CPPFLAGS :=
111 vmwgfx_SYS :=
112 vmwgfx_LIBS := \
113 $(TOP)/src/gallium/winsys/svga/drm/libsvgadrm.a \
114 $(TOP)/src/gallium/drivers/svga/libsvga.a
115
116 # swrast (pseudo) pipe driver
117 swrast_CPPFLAGS := -DGALLIUM_SOFTPIPE -DGALLIUM_RBUG -DGALLIUM_TRACE
118 swrast_SYS := -lm
119 swrast_LIBS := $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
120
121 # LLVM
122 ifeq ($(MESA_LLVM),1)
123 common_SYS += $(LLVM_LIBS)
124 swrast_CPPFLAGS += -DGALLIUM_LLVMPIPE
125 swrast_LIBS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
126 LDFLAGS += $(LLVM_LDFLAGS)
127 endif
128
129 # OpenGL state tracker
130 GL_CPPFLAGS := -I$(TOP)/src/mesa $(API_DEFINES)
131 # do not link to $(GL_LIB) as the it supports GLES too
132 GL_SYS := $(DRI_LIB_DEPS)
133 GL_LIBS := $(TOP)/src/mesa/libmesagallium.a
134
135 # OpenGL ES 1.x state tracker
136 GLESv1_CM_CPPFLAGS := -I$(TOP)/src/mesa
137 GLESv1_CM_SYS := $(DRI_LIB_DEPS) -L$(TOP)/$(LIB_DIR) -l$(GLESv1_CM_LIB)
138 GLESv1_CM_LIBS := $(TOP)/src/mesa/libes1gallium.a
139
140 # OpenGL ES 2.x state tracker
141 GLESv2_CPPFLAGS := -I$(TOP)/src/mesa
142 GLESv2_SYS := $(DRI_LIB_DEPS) -L$(TOP)/$(LIB_DIR) -l$(GLESv2_LIB)
143 GLESv2_LIBS := $(TOP)/src/mesa/libes2gallium.a
144
145 # OpenVG state tracker
146 OpenVG_CPPFLAGS := -I$(TOP)/src/gallium/state_trackers/vega
147 OpenVG_SYS := -lm -L$(TOP)/$(LIB_DIR) -l$(VG_LIB)
148 OpenVG_LIBS := $(TOP)/src/gallium/state_trackers/vega/libvega.a
149
150
151 OUTPUT_PATH := $(TOP)/$(LIB_DIR)/egl
152
153 # determine the outputs
154 ifneq ($(findstring i915/drm,$(GALLIUM_WINSYS_DIRS)),)
155 OUTPUTS += i915
156 endif
157 ifneq ($(findstring i965/drm,$(GALLIUM_WINSYS_DIRS)),)
158 OUTPUTS += i965
159 endif
160 ifneq ($(findstring nouveau/drm,$(GALLIUM_WINSYS_DIRS)),)
161 OUTPUTS += nouveau
162 endif
163 ifneq ($(findstring radeon/drm,$(GALLIUM_WINSYS_DIRS)),)
164 OUTPUTS += r300
165 endif
166 ifneq ($(findstring r600/drm,$(GALLIUM_WINSYS_DIRS)),)
167 OUTPUTS += r600
168 endif
169 ifneq ($(findstring svga/drm,$(GALLIUM_WINSYS_DIRS)),)
170 OUTPUTS += vmwgfx
171 endif
172 OUTPUTS += swrast
173 OUTPUTS := $(addprefix $(PIPE_PREFIX), $(OUTPUTS))
174
175 # EGL driver and state trackers
176 OUTPUTS += egl_gallium $(addprefix $(ST_PREFIX), $(EGL_CLIENT_APIS))
177
178 OUTPUTS := $(addsuffix .so, $(OUTPUTS))
179 OUTPUTS := $(addprefix $(OUTPUT_PATH)/, $(OUTPUTS))
180
181 default: $(OUTPUTS)
182
183 define mklib
184 $(MKLIB) -o $(notdir $@) -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
185 -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) $< \
186 -Wl,--start-group $(common_LIBS) $($(1)_LIBS) -Wl,--end-group \
187 $(common_SYS) $($(1)_SYS)
188 endef
189
190 define mklib-cxx
191 $(MKLIB) -o $(notdir $@) -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
192 -cplusplus -install $(OUTPUT_PATH) $(MKLIB_OPTIONS) $< \
193 -Wl,--start-group $(common_LIBS) $($(1)_LIBS) -Wl,--end-group \
194 $(common_SYS) $($(1)_SYS)
195 endef
196
197 # EGL driver
198 $(OUTPUT_PATH)/egl_gallium.so: egl.o $(egl_LIBS)
199 $(call mklib,egl)
200
201 # pipe drivers
202 $(OUTPUT_PATH)/$(PIPE_PREFIX)i915.so: pipe_i915.o $(i915_LIBS)
203 $(call mklib,i915)
204
205 $(OUTPUT_PATH)/$(PIPE_PREFIX)i965.so: pipe_i965.o $(i965_LIBS)
206 $(call mklib,i965)
207
208 $(OUTPUT_PATH)/$(PIPE_PREFIX)nouveau.so: pipe_nouveau.o $(nouveau_LIBS)
209 $(call mklib,nouveau)
210
211 $(OUTPUT_PATH)/$(PIPE_PREFIX)r300.so: pipe_r300.o $(r300_LIBS)
212 $(call mklib,r300)
213
214 $(OUTPUT_PATH)/$(PIPE_PREFIX)r600.so: pipe_r600.o $(r600_LIBS)
215 $(call mklib,r600)
216
217 $(OUTPUT_PATH)/$(PIPE_PREFIX)vmwgfx.so: pipe_vmwgfx.o $(vmwgfx_LIBS)
218 $(call mklib,vmwgfx)
219
220 $(OUTPUT_PATH)/$(PIPE_PREFIX)swrast.so: pipe_swrast.o $(swrast_LIBS)
221 $(call mklib,swrast)
222
223 # state trackers
224 $(OUTPUT_PATH)/$(ST_PREFIX)$(GL_LIB).so: st_GL.o $(GL_LIBS)
225 $(call mklib-cxx,GL)
226
227 $(OUTPUT_PATH)/$(ST_PREFIX)$(GLESv1_CM_LIB).so: st_GLESv1_CM.o $(GLESv1_CM_LIBS)
228 $(call mklib-cxx,GLESv1_CM)
229
230 $(OUTPUT_PATH)/$(ST_PREFIX)$(GLESv2_LIB).so: st_GLESv2.o $(GLESv2_LIBS)
231 $(call mklib-cxx,GLESv2)
232
233 $(OUTPUT_PATH)/$(ST_PREFIX)$(VG_LIB).so: st_OpenVG.o $(OpenVG_LIBS)
234 $(call mklib,OpenVG)
235
236 egl.o: egl.c
237 $(CC) -c -o $@ $< $(common_CPPFLAGS) $(egl_CPPFLAGS) $(DEFINES) $(CFLAGS)
238
239 pipe_%.o: pipe_%.c
240 $(CC) -c -o $@ $< $(common_CPPFLAGS) $($*_CPPFLAGS) $(DEFINES) $(CFLAGS)
241
242 st_%.o: st_%.c
243 $(CC) -c -o $@ $< $(common_CPPFLAGS) $($*_CPPFLAGS) $(DEFINES) $(CFLAGS)
244
245 install: $(OUTPUTS)
246 $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR)
247 for out in $(OUTPUTS); do \
248 $(MINSTALL) -m 755 "$$out" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \
249 done
250
251 clean:
252 rm -f *.o