1 # Makefile -- For the Direct Rendering Manager module (drm)
3 # Based on David Woodhouse's mtd build.
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.
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.
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 $
18 # By default, the build is done against the running linux kernel source.
19 # To build against a different kernel source tree, set LINUXDIR:
21 # make LINUXDIR=/path/to/kernel/source
24 # To build only some modules, either set DRM_MODULES to the list of modules,
25 # or specify the modules as targets:
27 # make r128.o radeon.o
31 # make DRM_MODULES="r128 radeon"
39 RUNNING_REL := $(shell uname -r)
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)
47 O := $(shell if [ -e /lib/modules/$(RUNNING_REL)/build ]; then \
48 echo /lib/modules/$(RUNNING_REL)/build; \
56 MACHINE := $(shell uname -m)
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
63 # Modules only for ix86 architectures
64 ifneq (,$(findstring 86,$(MACHINE)))
66 MODULE_LIST += i810.o i915.o
69 ifneq (,$(findstring sparc64,$(MACHINE)))
74 DRM_MODULES ?= $(MODULE_LIST)
76 # These definitions are for handling dependencies in the out of kernel build.
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
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)
96 PROGS = dristat drmstat
98 CLEANFILES = *.o *.ko $(PROGS) .depend .*.flags .*.d .*.cmd *.mod.c drm_pciids.h .tmp_versions
100 # VERSION is not defined from the initial invocation. It is defined when
101 # this Makefile is invoked from the kernel's root Makefile.
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.
111 BOOTVERSION_PREFIX = /boot/vmlinuz.
113 V := $(shell if [ -f $(BOOTVERSION_PREFIX)version.h ]; then \
114 grep UTS_RELEASE $(BOOTVERSION_PREFIX)version.h | \
117 ifeq ($(V),"$(RUNNING_REL)")
119 GETCONFIG := MAKEFILES=$(shell pwd)/.config
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.
127 ifneq ($(HAVECONFIG),y)
128 HAVECONFIG := $(shell if [ -e $(LINUXDIR)/.config ]; then echo y; fi)
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')
135 RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE).config
137 RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE)-$(REL_TYPE).config
139 HAVECONFIG := $(shell if [ -e $(LINUXDIR)/$(RHCONFIG) ]; then echo y; fi)
140 ifneq ($(HAVECONFIG),y)
145 ifneq ($(HAVECONFIG),y)
146 ifneq ($(0),$(LINUXDIR))
149 HAVECONFIG := $(shell if [ -e $(O)/.config ]; then echo y; fi)
152 ifneq ($(HAVECONFIG),y)
153 $(error Cannot find a kernel config file)
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
166 +make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules
168 ifeq ($(HEADERFROMBOOT),1)
170 BOOTHEADERS = version.h autoconf.h
173 CLEANFILES += $(BOOTHEADERS) $(BOOTCONFIG)
175 includes:: $(BOOTHEADERS) $(BOOTCONFIG)
177 version.h: $(BOOTVERSION_PREFIX)version.h
181 autoconf.h: $(BOOTVERSION_PREFIX)autoconf.h
185 .config: $(BOOTVERSION_PREFIX)config
190 # This prepares an unused Red Hat kernel tree for the build.
192 includes:: $(LINUXDIR)/.config $(LINUXDIR)/tmp_include_depends .config
194 $(LINUXDIR)/.config: $(LINUXDIR)/$(RHCONFIG)
198 .config: $(LINUXDIR)/$(RHCONFIG)
202 $(LINUXDIR)/tmp_include_depends:
206 # Make sure that the shared source files are linked into this directory.
209 SHAREDDIR := ../shared-core
211 ifeq ($(shell if [ -d $(SHAREDDIR) ]; then echo y; fi),y)
212 includes:: drm_pciids.h
214 drm_pciids.h: $(SHAREDDIR)/drm_pciids.txt
215 sh ../scripts/create_linux_pci_lists.sh < $(SHAREDDIR)/drm_pciids.txt
222 make DRM_MODULES=$@ modules
224 # Build test utilities
226 PRGCFLAGS = $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
227 -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
230 DRMSTATLIBS = -L../../.. -L.. -ldrm -lxf86_os \
231 -L../../../../dummylib -ldummy -lm
236 $(CC) $(PRGCFLAGS) $< -o $@
239 $(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS)
242 make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules_install
246 # Check for kernel versions that we don't support.
248 BELOW26 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 6 ]; then \
252 $(error Only 2.6.x and later kernels are supported \
253 ($(VERSION).$(PATCHLEVEL).$(SUBLEVEL)))
257 ifndef CONFIG_X86_CMPXCHG
258 $(error CONFIG_X86_CMPXCHG needs to be enabled in the kernel)
262 # This needs to go before all other include paths.
265 # Check for PAGE_AGP definition
266 PAGE_AGP := $(shell cat $(LINUXDIR)/include/asm/agp.h 2>/dev/null | \
269 ifneq ($(PAGE_AGP),0)
270 EXTRA_CFLAGS += -DHAVE_PAGE_AGP
273 # Start with all modules turned off.
274 CONFIG_DRM_GAMMA := n
279 CONFIG_DRM_RADEON := n
283 CONFIG_DRM_SAVAGE := n
285 CONFIG_DRM_MACH64 := n
287 CONFIG_DRM_NOUVEAU := n
290 # Enable module builds for the modules requested/supported.
292 ifneq (,$(findstring tdfx,$(DRM_MODULES)))
295 ifneq (,$(findstring r128,$(DRM_MODULES)))
298 ifneq (,$(findstring radeon,$(DRM_MODULES)))
299 CONFIG_DRM_RADEON := m
301 ifneq (,$(findstring sis,$(DRM_MODULES)))
304 ifneq (,$(findstring via,$(DRM_MODULES)))
307 ifneq (,$(findstring mach64,$(DRM_MODULES)))
308 CONFIG_DRM_MACH64 := m
310 ifneq (,$(findstring ffb,$(DRM_MODULES)))
313 ifneq (,$(findstring savage,$(DRM_MODULES)))
314 CONFIG_DRM_SAVAGE := m
316 ifneq (,$(findstring mga,$(DRM_MODULES)))
319 ifneq (,$(findstring nv,$(DRM_MODULES)))
322 ifneq (,$(findstring nouveau,$(DRM_MODULES)))
323 CONFIG_DRM_NOUVEAU := m
325 ifneq (,$(findstring xgi,$(DRM_MODULES)))
329 # These require AGP support
331 ifneq (,$(findstring i810,$(DRM_MODULES)))
334 ifneq (,$(findstring i915,$(DRM_MODULES)))
338 include $(DRMSRCDIR)/Makefile.kernel
341 $(drm-objs): $(DRMHEADERS) $(COREHEADERS)
342 $(tdfx-objs): $(TDFXHEADERS)
343 $(r128-objs): $(R128HEADERS)
344 $(mga-objs): $(MGAHEADERS)
345 $(i810-objs): $(I810HEADERS)
346 $(i915-objs): $(I915HEADERS)
347 $(radeon-objs): $(RADEONHEADERS)
348 $(sis-objs): $(SISHEADERS)
349 $(ffb-objs): $(FFBHEADERS)
350 $(savage-objs): $(SAVAGEHEADERS)
351 $(via-objs): $(VIAHEADERS)
352 $(mach64-objs): $(MACH64HEADERS)
353 $(nv-objs): $(NVHEADERS)
354 $(nouveau-objs): $(NOUVEAUHEADERS)
355 $(xgi-objs): $(XGIHEADERS)