1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
# Makefile -- For the Direct Rendering Manager module (drm)
#
# Based on David Woodhouse's mtd build.
#
# Modified to handle the DRM requirements and builds on a wider range of
# platforms in a flexible way by David Dawes. It's not clear, however,
# that this approach is simpler than the old one.
#
# The purpose of this Makefile.linux file is to handle setting up everything
# needed for an out-of-kernel source build. Makefile.kernel contains
# everything required for in-kernel source builds. It is included into
# this file, so none of that should be duplicated here.
#
# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux,v 1.37 2003/04/23 01:48:57 dawes Exp $
#
#
# By default, the build is done against the running linux kernel source.
# To build against a different kernel source tree, set LINUXDIR:
#
# make -f Makefile.linux LINUXDIR=/path/to/kernel/source
#
# To build only some modules, either set DRM_MODULES to the list of modules,
# or specify the modules as targets:
#
# make -f Makefile.linux r128.o radeon.o
#
# or:
#
# make -f Makefile.linux DRM_MODULES="r128 radeon"
#
SHELL=/bin/sh
.SUFFIXES:
ifndef LINUXDIR
RUNNING_REL := $(shell uname -r)
LINUXDIR := /lib/modules/$(RUNNING_REL)/build
endif
MACHINE := $(shell uname -m)
# Modules for all architectures
MODULE_LIST := gamma.o tdfx.o r128.o radeon.o mga.o #sis.o
# Modules only for ix86 architectures
ifneq (,$(findstring 86,$(MACHINE)))
MODULE_LIST += i830.o i810.o
endif
# Add ffb.o for sparc??
DRM_MODULES ?= $(MODULE_LIST)
# These definitions are for handling dependencies in the out of kernel build.
DRMTEMPLATES = drm_auth.h drm_bufs.h drm_context.h drm_dma.h drm_drawable.h \
drm_drv.h drm_fops.h drm_init.h drm_ioctl.h \
drm_lock.h drm_memory.h drm_proc.h drm_stub.h drm_vm.h
DRMSHARED = drm_sarea.h
DRMHEADERS = drm.h drmP.h $(DRMSHARED)
GAMMAHEADERS = gamma.h gamma_context.h gamma_drm.h gamma_drv.h gamma_lists.h \
gamma_old_dma.h gamma_lock.h $(DRMHEADERS) $(DRMTEMPLATES)
TDFXHEADERS = tdfx.h $(DRMHEADERS) $(DRMTEMPLATES)
R128HEADERS = r128.h r128_drv.h r128_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
R128SHARED = r128.h r128_drv.h r128_drm.h r128_cce.c r128_state.c r128_irq.c
RADEONHEADERS = radeon.h radeon_drv.h radeon_drm.h $(DRMHEADERS) \
$(DRMTEMPLATES)
RADEONSHARED = radeon.h radeon_drv.h radeon_drm.h radeon_cp.c radeon_irq.c \
radeon_mem.c radeon_state.c
MGAHEADERS = mga.h mga_drv.h mga_drm.h mga_ucode.h $(DRMHEADERS) \
$(DRMTEMPLATES)
MGASHARED = mga.h mga_dma.c mga_drm.h mga_drv.h mga_irq.c mga_state.c \
mga_ucode.h mga_warp.c
I810HEADERS = i810.h i810_drv.h i810_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
I830HEADERS = i830.h i830_drv.h i830_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
SISHEADERS= sis_drv.h sis_drm.h $(DRMHEADERS)
SHAREDSRC = $(DRMSHARED) $(MGASHARED) $(R128SHARED) $(RADEONSHARED)
PROGS = dristat drmstat
CLEANFILES = *.o *.ko $(PROGS) .depend .*.flags .*.d .*.cmd
# VERSION is not defined from the initial invocation. It is defined when
# this Makefile is invoked from the kernel's root Makefile.
ifndef VERSION
ifdef RUNNING_REL
# SuSE has the version.h and autoconf.h headers for the current kernel
# in /boot as /boot/vmlinuz.version.h and /boot/vmlinuz.autoconf.h.
# Check these first to see if they match the running kernel.
BOOTVERSION_PREFIX = /boot/vmlinuz.
V := $(shell if [ -f $(BOOTVERSION_PREFIX)version.h ]; then \
grep UTS_RELEASE $(BOOTVERSION_PREFIX)version.h | \
cut -d' ' -f3; fi)
ifeq ($(V),"$(RUNNING_REL)")
HEADERFROMBOOT := 1
GETCONFIG := MAKEFILES=$(shell pwd)/.config
HAVECONFIG := y
endif
# On Red Hat we need to check if there is a .config file in the kernel
# source directory. If there isn't, we need to check if there's a
# matching file in the configs subdirectory.
ifneq ($(HAVECONFIG),y)
HAVECONFIG := $(shell if [ -e $(LINUXDIR)/.config ]; then echo y; fi)
endif
ifneq ($(HAVECONFIG),y)
REL_BASE := $(shell echo $(RUNNING_REL) | sed 's/-.*//')
REL_TYPE := $(shell echo $(RUNNING_REL) | sed 's/[0-9.-]//g')
ifeq ($(REL_TYPE),)
RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE).config
else
RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE)-$(REL_TYPE).config
endif
HAVECONFIG := $(shell if [ -e $(LINUXDIR)/$(RHCONFIG) ]; then echo y; fi)
ifneq ($(HAVECONFIG),y)
RHCONFIG :=
endif
endif
ifneq ($(HAVECONFIG),y)
$(error Cannot find a kernel config file)
endif
endif
CLEANCONFIG := $(shell if cmp -s $(LINUXDIR)/.config .config; then echo y; fi)
ifeq ($(CLEANCONFIG),y)
CLEANFILES += $(LINUXDIR)/.config .config $(LINUXDIR)/tmp_include_depends
endif
# The Makefile renaming hack is required because the standard kernel build,
# especially 2.5.52 and later, explicitly references the Makefile by the
# name "Makefile". For builds prior to 2.5.52, the name GNUmakefile could
# have been used.
all: modules
modules: includes
@if test -f Makefile && cmp -s Makefile Makefile.linux; then : ; \
else \
if [ -e Makefile ]; then \
(set -x; mv -f Makefile Makefile._xx_); fi; \
(set -x; ln -s Makefile.linux Makefile); fi
make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules
@if cmp -s Makefile Makefile.linux; then \
(set -x; rm -f Makefile); \
if [ -e Makefile._xx_ ]; then \
(set -x; mv -f Makefile._xx_ Makefile); fi; fi
ifeq ($(HEADERFROMBOOT),1)
BOOTHEADERS = version.h autoconf.h
BOOTCONFIG = .config
CLEANFILES += $(BOOTHEADERS) $(BOOTCONFIG)
includes:: $(BOOTHEADERS) $(BOOTCONFIG)
version.h: $(BOOTVERSION_PREFIX)version.h
rm -f $@
ln -s $< $@
autoconf.h: $(BOOTVERSION_PREFIX)autoconf.h
rm -f $@
ln -s $< $@
.config: $(BOOTVERSION_PREFIX)config
rm -f $@
ln -s $< $@
endif
# This prepares an unused Red Hat kernel tree for the build.
ifneq ($(RHCONFIG),)
includes:: $(LINUXDIR)/.config $(LINUXDIR)/tmp_include_depends .config
$(LINUXDIR)/.config: $(LINUXDIR)/$(RHCONFIG)
rm -f $@
ln -s $< $@
.config: $(LINUXDIR)/$(RHCONFIG)
rm -f $@
ln -s $< $@
$(LINUXDIR)/tmp_include_depends:
echo all: > $@
endif
# Make sure that the shared source files are linked into this directory.
SHAREDDIR := ../../../shared/drm/kernel
HASSHARED := $(shell if [ -d $(SHAREDDIR) ]; then echo y; fi)
ifeq ($(HASSHARED),y)
includes:: $(SHAREDSRC)
$(SHAREDSRC):
@if [ -r $(SHAREDDIR)/$@ ]; then \
(rm -f $@; set -x; ln -s $(SHAREDDIR)/$@ $@); fi
CLEANFILES += $(SHAREDSRC)
endif
includes:: linux
linux:
rm -f linux
ln -s . linux
clean cleandir:
rm -f $(CLEANFILES)
$(MODULE_LIST)::
make -f Makefile.linux DRM_MODULES=$@ modules
# Build test utilities
PRGCFLAGS = $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
-D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
-I. -I../../..
DRMSTATLIBS = -L../../.. -L.. -ldrm -lxf86_os \
-L../../../../dummylib -ldummy -lm
programs: $(PROGS)
dristat: dristat.c
$(CC) $(PRGCFLAGS) $< -o $@
drmstat: drmstat.c
$(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS)
else
# Check for kernel versions that we don't support.
BELOW24 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 4 ]; then \
echo y; fi)
ifeq ($(BELOW24),y)
$(error Only 2.4.x and later kernels are supported \
($(VERSION).$(PATCHLEVEL).$(SUBLEVEL)))
endif
# This needs to go before all other include paths.
CC += -I$(DRMSRCDIR)
# Check for Red Hat's 4-argument do_munmap().
DOMUNMAP := $(shell grep do_munmap $(LINUXDIR)/include/linux/mm.h | \
grep -c acct)
# Check for 5-argument remap_page_range() in RH9 kernel, and 2.5.x kernels
RPR := $(shell grep remap_page_range $(LINUXDIR)/include/linux/mm.h | \
grep -c vma)
ifneq ($(DOMUNMAP),0)
EXTRA_CFLAGS += -DDO_MUNMAP_4_ARGS
endif
ifneq ($(RPR),0)
EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_5_ARGS
endif
# Start with all modules turned off.
CONFIG_DRM_GAMMA := n
CONFIG_DRM_TDFX := n
CONFIG_DRM_MGA := n
CONFIG_DRM_I810 := n
CONFIG_DRM_R128 := n
CONFIG_DRM_RADEON := n
CONFIG_DRM_I830 := n
CONFIG_DRM_SIS := n
CONFIG_DRM_FFB := n
# Enable module builds for the modules requested/supported.
ifneq (,$(findstring gamma,$(DRM_MODULES)))
CONFIG_DRM_GAMMA := m
endif
ifneq (,$(findstring tdfx,$(DRM_MODULES)))
CONFIG_DRM_TDFX := m
endif
ifneq (,$(findstring r128,$(DRM_MODULES)))
CONFIG_DRM_R128 := m
endif
ifneq (,$(findstring radeon,$(DRM_MODULES)))
CONFIG_DRM_RADEON := m
endif
ifneq (,$(findstring sis,$(DRM_MODULES)))
CONFIG_DRM_SIS := m
endif
# These require AGP support
ifdef CONFIG_AGP
ifneq (,$(findstring mga,$(DRM_MODULES)))
CONFIG_DRM_MGA := m
endif
ifneq (,$(findstring i810,$(DRM_MODULES)))
CONFIG_DRM_I810 := m
endif
ifneq (,$(findstring i830,$(DRM_MODULES)))
CONFIG_DRM_I830 := m
endif
endif
include $(DRMSRCDIR)/Makefile.kernel
# Depencencies
$(gamma-objs): $(GAMMAHEADERS)
$(tdfx-objs): $(TDFXHEADERS)
$(r128-objs): $(R128HEADERS)
$(mga-objs): $(MGAHEADERS)
$(i810-objs): $(I810HEADERS)
$(i830-objs): $(I830HEADERS)
$(radeon-objs): $(RADEONHEADERS)
$(sis-objs): $(SISHEADERS)
$(ffb-objs): $(FFBHEADERS)
endif
|