Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 376 lines (300 sloc) 9.634 kb
0c4490c2 »
2009-07-01 initial 4.40 import
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 psb.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 PSBHEADERS= psb_drv.h psb_drm.h psb_reg.h psb_kreg.h psb_scene.h \
95 psb_schedule.h psb_detear.h $(DRMHEADERS)
96 XGIHEADERS = xgi_cmdlist.h xgi_drv.h xgi_misc.h xgi_regs.h $(DRMHEADERS)
97
98 PROGS = dristat drmstat
99
04a95866 »
2009-07-02 add some more files to delete to the Makefile
100 CLEANFILES = *.o *.ko $(PROGS) .depend .*.flags .*.d .*.cmd *.mod.c .tmp_versions modules.order *.symvers
0c4490c2 »
2009-07-01 initial 4.40 import
101
102 # VERSION is not defined from the initial invocation. It is defined when
103 # this Makefile is invoked from the kernel's root Makefile.
104
105 ifndef VERSION
106
107 ifdef RUNNING_REL
108
109 # SuSE has the version.h and autoconf.h headers for the current kernel
110 # in /boot as /boot/vmlinuz.version.h and /boot/vmlinuz.autoconf.h.
111 # Check these first to see if they match the running kernel.
112
113 BOOTVERSION_PREFIX = /boot/vmlinuz.
114
115 V := $(shell if [ -f $(BOOTVERSION_PREFIX)version.h ]; then \
116 grep UTS_RELEASE $(BOOTVERSION_PREFIX)version.h | \
117 cut -d' ' -f3; fi)
118
119 ifeq ($(V),"$(RUNNING_REL)")
120 HEADERFROMBOOT := 1
121 GETCONFIG := MAKEFILES=$(shell pwd)/.config
122 HAVECONFIG := y
123 endif
124
125 # On Red Hat we need to check if there is a .config file in the kernel
126 # source directory. If there isn't, we need to check if there's a
127 # matching file in the configs subdirectory.
128
129 ifneq ($(HAVECONFIG),y)
130 HAVECONFIG := $(shell if [ -e $(LINUXDIR)/.config ]; then echo y; fi)
131 endif
132
133 ifneq ($(HAVECONFIG),y)
134 REL_BASE := $(shell echo $(RUNNING_REL) | sed 's/-.*//')
135 REL_TYPE := $(shell echo $(RUNNING_REL) | sed 's/[0-9.-]//g')
136 ifeq ($(REL_TYPE),)
137 RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE).config
138 else
139 RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE)-$(REL_TYPE).config
140 endif
141 HAVECONFIG := $(shell if [ -e $(LINUXDIR)/$(RHCONFIG) ]; then echo y; fi)
142 ifneq ($(HAVECONFIG),y)
143 RHCONFIG :=
144 endif
145 endif
146
147 ifneq ($(HAVECONFIG),y)
148 ifneq ($(0),$(LINUXDIR))
149 GETCONFIG += O=$(O)
150 endif
151 HAVECONFIG := $(shell if [ -e $(O)/.config ]; then echo y; fi)
152 endif
153
154 ifneq ($(HAVECONFIG),y)
155 $(error Cannot find a kernel config file)
156 endif
157
158 endif
159
160 CLEANCONFIG := $(shell if cmp -s $(LINUXDIR)/.config .config; then echo y; fi)
161 ifeq ($(CLEANCONFIG),y)
162 CLEANFILES += $(LINUXDIR)/.config .config $(LINUXDIR)/tmp_include_depends
163 endif
164
165 all: modules
166
167 modules: includes
168 +make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules
169
170 ifeq ($(HEADERFROMBOOT),1)
171
172 BOOTHEADERS = version.h autoconf.h
173 BOOTCONFIG = .config
174
175 CLEANFILES += $(BOOTHEADERS) $(BOOTCONFIG)
176
177 includes:: $(BOOTHEADERS) $(BOOTCONFIG)
178
179 version.h: $(BOOTVERSION_PREFIX)version.h
180 rm -f $@
181 ln -s $< $@
182
183 autoconf.h: $(BOOTVERSION_PREFIX)autoconf.h
184 rm -f $@
185 ln -s $< $@
186
187 .config: $(BOOTVERSION_PREFIX)config
188 rm -f $@
189 ln -s $< $@
190 endif
191
192 # This prepares an unused Red Hat kernel tree for the build.
193 ifneq ($(RHCONFIG),)
194 includes:: $(LINUXDIR)/.config $(LINUXDIR)/tmp_include_depends .config
195
196 $(LINUXDIR)/.config: $(LINUXDIR)/$(RHCONFIG)
197 rm -f $@
198 ln -s $< $@
199
200 .config: $(LINUXDIR)/$(RHCONFIG)
201 rm -f $@
202 ln -s $< $@
203
204 $(LINUXDIR)/tmp_include_depends:
205 echo all: > $@
206 endif
207
208 # Make sure that the shared source files are linked into this directory.
209
210
211 SHAREDDIR := .
212
213 ifeq ($(shell if [ -d $(SHAREDDIR) ]; then echo y; fi),y)
214 includes:: drm_pciids.h
215
216 drm_pciids.h: $(SHAREDDIR)/drm_pciids.txt
217 sh ./create_linux_pci_lists.sh < $(SHAREDDIR)/drm_pciids.txt
218 else
219 includes::
220
221 endif
222
98b5307e »
2009-07-02 add 'release' target to Makefile
223 DATE:=$(shell date +%m%d%Y)
224 NAME:=psb-kmp
225 RELEASE:=$(NAME)-$(DATE)
226 release:
227 @ echo "Date = $(DATE)"
228 - rm -f $(RELEASE).tar.gz
229 git archive --format=tar --prefix=$(RELEASE)/ HEAD | gzip -9v > $(RELEASE).tar.gz
230
231 .PHONY: release
232
0c4490c2 »
2009-07-01 initial 4.40 import
233 clean cleandir:
234 rm -rf $(CLEANFILES)
235
236 $(MODULE_LIST)::
237 make DRM_MODULES=$@ modules
238
239 # Build test utilities
240
241 PRGCFLAGS = $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
242 -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
243 -I. -I../../..
244
245 DRMSTATLIBS = -L../../.. -L.. -ldrm -lxf86_os \
246 -L../../../../dummylib -ldummy -lm
247
248 programs: $(PROGS)
249
250 dristat: dristat.c
251 $(CC) $(PRGCFLAGS) $< -o $@
252
253 drmstat: drmstat.c
254 $(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS)
255
256 install:
257 make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules_install
258
259 else
260
261 # Check for kernel versions that we don't support.
262
263 BELOW26 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 6 ]; then \
264 echo y; fi)
265
266 ifeq ($(BELOW26),y)
267 $(error Only 2.6.x and later kernels are supported \
268 ($(VERSION).$(PATCHLEVEL).$(SUBLEVEL)))
269 endif
270
271 ifdef ARCHX86
272 ifndef CONFIG_X86_CMPXCHG
273 $(error CONFIG_X86_CMPXCHG needs to be enabled in the kernel)
274 endif
275 endif
276
277 # This needs to go before all other include paths.
278 CC += -I$(DRMSRCDIR)
279
280 # Check for PAGE_AGP definition
281 PAGE_AGP := $(shell cat $(LINUXDIR)/include/asm/agp.h 2>/dev/null | \
282 grep -c PAGE_AGP)
283
284 ifneq ($(PAGE_AGP),0)
285 EXTRA_CFLAGS += -DHAVE_PAGE_AGP
286 endif
287
288 # Start with all modules turned off.
289 CONFIG_DRM_GAMMA := n
290 CONFIG_DRM_TDFX := n
291 CONFIG_DRM_MGA := n
292 CONFIG_DRM_I810 := n
293 CONFIG_DRM_R128 := n
294 CONFIG_DRM_RADEON := n
295 CONFIG_DRM_I915 := n
296 CONFIG_DRM_SIS := n
297 CONFIG_DRM_FFB := n
298 CONFIG_DRM_SAVAGE := n
299 CONFIG_DRM_VIA := n
300 CONFIG_DRM_MACH64 := n
301 CONFIG_DRM_NV := n
302 CONFIG_DRM_NOUVEAU := n
303 CONFIG_DRM_PSB := n
304 CONFIG_DRM_XGI := n
305
306 # Enable module builds for the modules requested/supported.
307
308 ifneq (,$(findstring tdfx,$(DRM_MODULES)))
309 CONFIG_DRM_TDFX := m
310 endif
311 ifneq (,$(findstring r128,$(DRM_MODULES)))
312 CONFIG_DRM_R128 := m
313 endif
314 ifneq (,$(findstring radeon,$(DRM_MODULES)))
315 CONFIG_DRM_RADEON := m
316 endif
317 ifneq (,$(findstring sis,$(DRM_MODULES)))
318 CONFIG_DRM_SIS := m
319 endif
320 ifneq (,$(findstring via,$(DRM_MODULES)))
321 CONFIG_DRM_VIA := m
322 endif
323 ifneq (,$(findstring mach64,$(DRM_MODULES)))
324 CONFIG_DRM_MACH64 := m
325 endif
326 ifneq (,$(findstring ffb,$(DRM_MODULES)))
327 CONFIG_DRM_FFB := m
328 endif
329 ifneq (,$(findstring savage,$(DRM_MODULES)))
330 CONFIG_DRM_SAVAGE := m
331 endif
332 ifneq (,$(findstring mga,$(DRM_MODULES)))
333 CONFIG_DRM_MGA := m
334 endif
335 ifneq (,$(findstring nv,$(DRM_MODULES)))
336 CONFIG_DRM_NV := m
337 endif
338 ifneq (,$(findstring nouveau,$(DRM_MODULES)))
339 CONFIG_DRM_NOUVEAU := m
340 endif
341 ifneq (,$(findstring xgi,$(DRM_MODULES)))
342 CONFIG_DRM_XGI := m
343 endif
344
345 # These require AGP support
346
347 ifneq (,$(findstring i810,$(DRM_MODULES)))
348 CONFIG_DRM_I810 := m
349 endif
350 ifneq (,$(findstring i915,$(DRM_MODULES)))
351 CONFIG_DRM_I915 := m
352 endif
353 ifneq (,$(findstring psb,$(DRM_MODULES)))
354 CONFIG_DRM_PSB := m
355 endif
356 include $(DRMSRCDIR)/Makefile.kernel
357
358 # Depencencies
359 $(drm-objs): $(DRMHEADERS) $(COREHEADERS)
360 $(tdfx-objs): $(TDFXHEADERS)
361 $(r128-objs): $(R128HEADERS)
362 $(mga-objs): $(MGAHEADERS)
363 $(i810-objs): $(I810HEADERS)
364 $(i915-objs): $(I915HEADERS)
365 $(radeon-objs): $(RADEONHEADERS)
366 $(sis-objs): $(SISHEADERS)
367 $(ffb-objs): $(FFBHEADERS)
368 $(savage-objs): $(SAVAGEHEADERS)
369 $(via-objs): $(VIAHEADERS)
370 $(mach64-objs): $(MACH64HEADERS)
371 $(nv-objs): $(NVHEADERS)
372 $(nouveau-objs): $(NOUVEAUHEADERS)
373 $(psb-objs): $(PSBHEADERS)
374 $(xgi-objs): $(XGIHEADERS)
375
376 endif
377
Something went wrong with that request. Please try again.