[intel] Quirk away MSI support on 945G/GM.
[platform/upstream/libdrm.git] / linux-core / Makefile
1 # Makefile -- For the Direct Rendering Manager module (drm)
2 #
3 # Based on David Woodhouse's mtd build.
4 #
5 # Modified to handle the DRM requirements and builds on a wider range of
6 # platforms in a flexible way by David Dawes.  It's not clear, however,
7 # that this approach is simpler than the old one.
8 #
9 # The purpose of this Makefile is to handle setting up everything
10 # needed for an out-of-kernel source build.  Makefile.kernel contains
11 # everything required for in-kernel source builds.  It is included into
12 # this file, so none of that should be duplicated here.
13 #
14 # $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux,v 1.40 2003/08/17 17:12:25 dawes Exp $
15 #
16
17 #
18 # By default, the build is done against the running linux kernel source.
19 # To build against a different kernel source tree, set LINUXDIR:
20 #
21 #    make LINUXDIR=/path/to/kernel/source
22
23 #
24 # To build only some modules, either set DRM_MODULES to the list of modules,
25 # or specify the modules as targets:
26 #
27 #    make r128.o radeon.o
28 #
29 # or:
30 #
31 #    make DRM_MODULES="r128 radeon"
32 #
33
34 SHELL=/bin/sh
35
36 .SUFFIXES:
37
38 ifndef LINUXDIR
39 RUNNING_REL := $(shell uname -r)
40
41 LINUXDIR := $(shell if [ -e /lib/modules/$(RUNNING_REL)/source ]; then \
42                  echo /lib/modules/$(RUNNING_REL)/source; \
43                  else echo /lib/modules/$(RUNNING_REL)/build; fi)
44 endif
45
46 ifndef O
47 O := $(shell if [ -e /lib/modules/$(RUNNING_REL)/build ]; then \
48                  echo /lib/modules/$(RUNNING_REL)/build; \
49                  else echo ""; fi)
50 #O := $(LINUXDIR)
51 endif
52
53 ifdef ARCH
54 MACHINE := $(ARCH)
55 else
56 MACHINE := $(shell uname -m)
57 endif
58
59 # Modules for all architectures
60 MODULE_LIST := drm.o tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o \
61                mach64.o nv.o nouveau.o xgi.o
62
63 # Modules only for ix86 architectures
64 ifneq (,$(findstring 86,$(MACHINE)))
65 ARCHX86 := 1
66 MODULE_LIST += i810.o i915.o
67 endif
68
69 ifneq (,$(findstring sparc64,$(MACHINE)))
70 ARCHSPARC64 := 1
71 #MODULE_LIST += ffb.o
72 endif
73
74 DRM_MODULES ?= $(MODULE_LIST)
75
76 # These definitions are for handling dependencies in the out of kernel build.
77
78 DRMHEADERS =    drmP.h drm_compat.h drm_os_linux.h drm.h drm_sarea.h
79 COREHEADERS =   drm_core.h drm_sman.h drm_hashtab.h 
80
81 TDFXHEADERS =   tdfx_drv.h $(DRMHEADERS)
82 R128HEADERS =   r128_drv.h r128_drm.h $(DRMHEADERS)
83 RADEONHEADERS = radeon_drv.h radeon_drm.h r300_reg.h $(DRMHEADERS)
84 MGAHEADERS =    mga_drv.h mga_drm.h mga_ucode.h $(DRMHEADERS)
85 I810HEADERS =   i810_drv.h i810_drm.h $(DRMHEADERS)
86 I915HEADERS =   i915_drv.h i915_drm.h $(DRMHEADERS)
87 SISHEADERS=     sis_drv.h sis_drm.h drm_hashtab.h drm_sman.h $(DRMHEADERS)
88 SAVAGEHEADERS=  savage_drv.h savage_drm.h $(DRMHEADERS)
89 VIAHEADERS =    via_drm.h via_drv.h via_3d_reg.h via_verifier.h $(DRMHEADERS)
90 MACH64HEADERS = mach64_drv.h mach64_drm.h $(DRMHEADERS)
91 NVHEADERS =     nv_drv.h $(DRMHEADERS)
92 FFBHEADERS =    ffb_drv.h $(DRMHEADERS)
93 NOUVEAUHEADERS = nouveau_drv.h nouveau_drm.h nouveau_reg.h $(DRMHEADERS)
94 XGIHEADERS = xgi_cmdlist.h xgi_drv.h xgi_misc.h xgi_regs.h $(DRMHEADERS)
95
96 PROGS = dristat drmstat
97
98 CLEANFILES = *.o *.ko $(PROGS) .depend .*.flags .*.d .*.cmd *.mod.c drm_pciids.h .tmp_versions
99
100 # VERSION is not defined from the initial invocation.  It is defined when
101 # this Makefile is invoked from the kernel's root Makefile.
102
103 ifndef VERSION
104
105 ifdef RUNNING_REL
106
107 # SuSE has the version.h and autoconf.h headers for the current kernel
108 # in /boot as /boot/vmlinuz.version.h and /boot/vmlinuz.autoconf.h.
109 # Check these first to see if they match the running kernel.
110
111 BOOTVERSION_PREFIX = /boot/vmlinuz.
112
113 V := $(shell if [ -f $(BOOTVERSION_PREFIX)version.h ]; then \
114         grep UTS_RELEASE $(BOOTVERSION_PREFIX)version.h | \
115         cut -d' ' -f3; fi)
116
117 ifeq ($(V),"$(RUNNING_REL)")
118 HEADERFROMBOOT := 1
119 GETCONFIG := MAKEFILES=$(shell /bin/pwd)/.config
120 HAVECONFIG := y
121 endif
122
123 # On Red Hat we need to check if there is a .config file in the kernel
124 # source directory.  If there isn't, we need to check if there's a
125 # matching file in the configs subdirectory.
126
127 ifneq ($(HAVECONFIG),y)
128 HAVECONFIG := $(shell if [ -e $(LINUXDIR)/.config ]; then echo y; fi)
129 endif
130
131 ifneq ($(HAVECONFIG),y)
132 REL_BASE := $(shell echo $(RUNNING_REL) | sed 's/-.*//')
133 REL_TYPE := $(shell echo $(RUNNING_REL) | sed 's/[0-9.-]//g')
134 ifeq ($(REL_TYPE),)
135 RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE).config
136 else
137 RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE)-$(REL_TYPE).config
138 endif
139 HAVECONFIG := $(shell if [ -e $(LINUXDIR)/$(RHCONFIG) ]; then echo y; fi)
140 ifneq ($(HAVECONFIG),y)
141 RHCONFIG :=
142 endif
143 endif
144
145 ifneq ($(HAVECONFIG),y)
146 ifneq ($(0),$(LINUXDIR))
147 GETCONFIG += O=$(O)
148 endif
149 HAVECONFIG := $(shell if [ -e $(O)/.config ]; then echo y; fi)
150 endif
151
152 ifneq ($(HAVECONFIG),y)
153 $(error Cannot find a kernel config file)
154 endif
155
156 endif
157
158 CLEANCONFIG := $(shell if cmp -s $(LINUXDIR)/.config .config; then echo y; fi)
159 ifeq ($(CLEANCONFIG),y)
160 CLEANFILES += $(LINUXDIR)/.config .config $(LINUXDIR)/tmp_include_depends
161 endif
162
163 all: modules
164
165 modules: includes
166         +make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`/bin/pwd` DRMSRCDIR=`/bin/pwd` modules
167
168 ifeq ($(HEADERFROMBOOT),1)
169
170 BOOTHEADERS = version.h autoconf.h
171 BOOTCONFIG = .config
172
173 CLEANFILES += $(BOOTHEADERS) $(BOOTCONFIG)
174
175 includes:: $(BOOTHEADERS) $(BOOTCONFIG)
176
177 version.h: $(BOOTVERSION_PREFIX)version.h
178         rm -f $@
179         ln -s $< $@
180
181 autoconf.h: $(BOOTVERSION_PREFIX)autoconf.h
182         rm -f $@
183         ln -s $< $@
184
185 .config: $(BOOTVERSION_PREFIX)config
186         rm -f $@
187         ln -s $< $@
188 endif
189
190 # This prepares an unused Red Hat kernel tree for the build.
191 ifneq ($(RHCONFIG),)
192 includes:: $(LINUXDIR)/.config $(LINUXDIR)/tmp_include_depends .config
193
194 $(LINUXDIR)/.config: $(LINUXDIR)/$(RHCONFIG)
195         rm -f $@
196         ln -s $< $@
197
198 .config: $(LINUXDIR)/$(RHCONFIG)
199         rm -f $@
200         ln -s $< $@
201
202 $(LINUXDIR)/tmp_include_depends:
203         echo all: > $@
204 endif
205
206 # Make sure that the shared source files are linked into this directory.
207
208
209 SHAREDDIR := ../shared-core
210
211 ifeq ($(shell if [ -d $(SHAREDDIR) ]; then echo y; fi),y)
212 includes::  drm_pciids.h
213
214 drm_pciids.h: $(SHAREDDIR)/drm_pciids.txt
215         sh ../scripts/create_linux_pci_lists.sh < $(SHAREDDIR)/drm_pciids.txt
216 endif
217
218 clean cleandir:
219         rm -rf $(CLEANFILES)
220
221 $(MODULE_LIST)::
222         make DRM_MODULES=$@ modules
223
224 # Build test utilities
225
226 PRGCFLAGS = $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
227             -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
228             -I. -I../../..
229
230 DRMSTATLIBS = -L../../.. -L.. -ldrm -lxf86_os \
231               -L../../../../dummylib -ldummy -lm
232
233 programs: $(PROGS)
234
235 dristat: dristat.c
236         $(CC) $(PRGCFLAGS) $< -o $@
237
238 drmstat: drmstat.c
239         $(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS)
240
241 install:
242         make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`/bin/pwd` DRMSRCDIR=`/bin/pwd` modules_install
243
244 else
245
246 # Check for kernel versions that we don't support.
247
248 BELOW26 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 6 ]; then \
249                 echo y; fi)
250
251 ifeq ($(BELOW26),y)
252 $(error Only 2.6.x and later kernels are supported \
253         ($(VERSION).$(PATCHLEVEL).$(SUBLEVEL)))
254 endif
255
256 ifdef ARCHX86
257 ifndef CONFIG_X86_CMPXCHG
258 $(error CONFIG_X86_CMPXCHG needs to be enabled in the kernel)
259 endif
260 endif
261
262 # This needs to go before all other include paths.
263 CC += -I$(DRMSRCDIR)
264
265 # Check for PAGE_AGP definition
266 PAGE_AGP := $(shell cat $(LINUXDIR)/include/asm/agp.h 2>/dev/null | \
267                 grep -c PAGE_AGP)
268
269 ifneq ($(PAGE_AGP),0)
270 EXTRA_CFLAGS += -DHAVE_PAGE_AGP
271 endif
272
273 # Start with all modules turned off.
274 CONFIG_DRM_GAMMA := n
275 CONFIG_DRM_TDFX := n
276 CONFIG_DRM_MGA := n
277 CONFIG_DRM_I810 := n
278 CONFIG_DRM_R128 := n
279 CONFIG_DRM_RADEON := n
280 CONFIG_DRM_I915 := n
281 CONFIG_DRM_SIS := n
282 CONFIG_DRM_FFB := n
283 CONFIG_DRM_SAVAGE := n
284 CONFIG_DRM_VIA := n
285 CONFIG_DRM_MACH64 := n
286 CONFIG_DRM_NV := n
287 CONFIG_DRM_NOUVEAU := n
288 CONFIG_DRM_XGI := n
289
290 # Enable module builds for the modules requested/supported.
291
292 ifneq (,$(findstring tdfx,$(DRM_MODULES)))
293 CONFIG_DRM_TDFX := m
294 endif
295 ifneq (,$(findstring r128,$(DRM_MODULES)))
296 CONFIG_DRM_R128 := m
297 endif
298 ifneq (,$(findstring radeon,$(DRM_MODULES)))
299 CONFIG_DRM_RADEON := m
300 endif
301 ifneq (,$(findstring sis,$(DRM_MODULES)))
302 CONFIG_DRM_SIS := m
303 endif
304 ifneq (,$(findstring via,$(DRM_MODULES)))
305 CONFIG_DRM_VIA := m
306 endif
307 ifneq (,$(findstring mach64,$(DRM_MODULES)))
308 CONFIG_DRM_MACH64 := m
309 endif
310 ifneq (,$(findstring ffb,$(DRM_MODULES)))
311 CONFIG_DRM_FFB := m
312 endif
313 ifneq (,$(findstring savage,$(DRM_MODULES)))
314 CONFIG_DRM_SAVAGE := m
315 endif
316 ifneq (,$(findstring mga,$(DRM_MODULES)))
317 CONFIG_DRM_MGA := m
318 endif
319 ifneq (,$(findstring nv,$(DRM_MODULES)))
320 CONFIG_DRM_NV := m
321 endif
322 ifneq (,$(findstring nouveau,$(DRM_MODULES)))
323 CONFIG_DRM_NOUVEAU := m
324 endif
325 ifneq (,$(findstring xgi,$(DRM_MODULES)))
326 CONFIG_DRM_XGI := m
327 endif
328
329 # These require AGP support
330
331 ifneq (,$(findstring i810,$(DRM_MODULES)))
332 CONFIG_DRM_I810 := m
333 endif
334 ifneq (,$(findstring i915,$(DRM_MODULES)))
335 CONFIG_DRM_I915 := m
336 endif
337
338 GIT_REVISION := $(shell cd "$(DRMSRCDIR)" && git-describe --abbrev=17)
339 ifneq ($(GIT_REVISION),)
340 EXTRA_CFLAGS+=-D"GIT_REVISION=\"$(GIT_REVISION)\""
341 endif
342
343 include $(DRMSRCDIR)/Makefile.kernel
344
345 # Depencencies
346 $(drm-objs):    $(DRMHEADERS) $(COREHEADERS)
347 $(tdfx-objs):   $(TDFXHEADERS)
348 $(r128-objs):   $(R128HEADERS)
349 $(mga-objs):    $(MGAHEADERS)
350 $(i810-objs):   $(I810HEADERS)
351 $(i915-objs):   $(I915HEADERS)
352 $(radeon-objs): $(RADEONHEADERS)
353 $(sis-objs):    $(SISHEADERS)
354 $(ffb-objs):    $(FFBHEADERS)
355 $(savage-objs): $(SAVAGEHEADERS)
356 $(via-objs):    $(VIAHEADERS)
357 $(mach64-objs): $(MACH64HEADERS)
358 $(nv-objs):     $(NVHEADERS)
359 $(nouveau-objs): $(NOUVEAUHEADERS)
360 $(xgi-objs):    $(XGIHEADERS)
361
362 endif
363