-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile.linux
316 lines (241 loc) · 11.6 KB
/
Makefile.linux
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
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
MMT=sunxi_cedar
MMM=$(MMT)
MMU=$(shell echo "$(MMM)" | tr "[a-z]" "[A-Z]")
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
EXTRA_CFLAGS +=
MMH_HEADERS=
PROGS = $(MMT).mod.c linux $(MMM)_modes.h
##---------------------------------------------------------------------------------------------------------------
$(MMT)-objs := cedar_ve.o
##---------------------------------------------------------------------------------------------------------------
## crw-r--r-- 1 root root 10, 180 Aug 23 2000 /dev/isb0
## minicom -s isb0
##
##
## lircd -d /dev/isb0 # daemon
## irw # client - test
#-----------------------------------------------------------------------------------------------------------------------------------------
KERNEL_SOURCE=$(KDIR)
LINUXDIR=$(KDIR)
KBUILD=$(KDIR)
RUNNING_REL := $(shell uname -r)
GETCONFIG := MAKEFILES=$(shell pwd)/.config
HAVECONFIG := y
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
CONFIG_VIDEO_ENCODER_DECODER_SUNXI=y
#-----------------------------------------------------------------------------------------------------------------------------------------
#ccflags-y += -Idrivers/media/dvb-core/
#-----------------------------------------------------------------------------------------------------------------------------------------
#EXTRA_CFLAGS += -DDEF_KIEC61883_KSB -DDEF_LIRC
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#include $(shell pwd)/Makefile
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
.SUFFIXES:
ifndef LINUXDIR
RUNNING_REL := $(shell uname -r)
LINUXDIR := /lib/modules/$(RUNNING_REL)/build
MODULEDIR := /lib/modules/$(RUNNING_REL)
endif #LINUXDIR
MACHINE := $(shell uname -m)
# Modules for all architectures
MODULE_LIST := $(MMT).o
# Modules only for ix86 architectures
#ifneq (,$(findstring 86,$(MACHINE)))
#ARCHX86 := 1
#MODULE_LIST +=
#endif #(,$(findstring 86,$(MACHINE)))
# Add ffb.o for sparc??
OPT_MODULES ?= $(MODULE_LIST)
CLEANFILES = *.o *.ko $(PROGS) .depend .*.flags .*.d .*.cmd Modules.symvers Module.symvers
# 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 #($(V),"$(RUNNING_REL)")
# 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 #HAVECONFIG
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 #HAVECONFIG
ifneq ($(HAVECONFIG),y)
$(error Cannot find a kernel config file)
endif #HAVECONFIG
endif #RUNNING_REL
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 && [ -e Makefile._xx_ ]; then \
(set -x; rm -f Makefile; \
mv -f Makefile._xx_ Makefile); fi
install: includes
make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` INSTALL_MOD_DIR="$(INSTALL_MOD_DIR)" MOD_DESTDIR="../" modules_install
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 #HEADERFROMBOOT
# 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 #HEADERFROMBOOT
# Make sure that the shared source files are linked into this directory.
includes:: linux
linux:
rm -f linux
ln -s . linux
clean cleandir:
rm -f $(CLEANFILES)
rm -Rf .tmp_versions modules.order
$(MODULE_LIST)::
make -f Makefile.linux OPT_MODULES=$@ modules
KVER=$(shell cat $(LINUXDIR)/Makefile | sed -n 's/^VERSION[ ]*=[ ]*\([0-9]*\).*/\1/p')
KPTT=$(shell cat $(LINUXDIR)/Makefile | sed -n 's/^PATCHLEVEL[ ]*=[ ]*\([0-9]*\).*/\1/p')
KPTU=$(shell cat $(LINUXDIR)/Makefile | sed -n 's/^SUBLEVEL[ ]*=[ ]*\([0-9]*\).*/\1/p')
KPTV=$(shell cat $(LINUXDIR)/Makefile | sed -n 's/^EXTRAVERSION[ ]*=[ ]*\([0-9a-fA-F.]*\).*/\1/p')
KPTW=$(shell echo $$[ $(KVER)*16 + $(KPTT) ])
KH26=$(shell if [ $(KPTW) -ge $$[0x26] ]; then echo 1;else echo 0;fi)
KVVV=$(KVER).$(KPTT).$(KPTU)$(KPTV)
MODULEDIR="/lib/modules/$(KVVV)/"
# 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../../..
endif #VERSION
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
ifdef VERSION
# Check for kernel versions that we don't support.
BELOW24 := $(shell if [ $(VERSION) -lt 2 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -lt 4 \) ]; then echo y; fi)
ifeq ($(BELOW24),y)
$(error Only 2.4.x and later kernels are supported ($(VERSION).$(PATCHLEVEL).$(SUBLEVEL)))
endif
ifdef ARCHX86
ifndef CONFIG_X86_CMPXCHG
##$(error CONFIG_X86_CMPXCHG needs to be enabled in the kernel)
endif
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)
ifneq ($(DOMUNMAP),0)
EXTRA_CFLAGS += -DDO_MUNMAP_4_ARGS
endif
# 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 ($(RPR),0)
EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_5_ARGS
endif
# Check for 4-argument vmap() in some 2.5.x and 2.4.x kernels
VMAP := $(shell grep -A1 'vmap.*count,$$' $(LINUXDIR)/include/linux/vmalloc.h | grep -c prot)
ifneq ($(VMAP),0)
EXTRA_CFLAGS += -DVMAP_4_ARGS
endif
# Check for PAGE_AGP definition
PAGE_AGP := $(shell cat $(LINUXDIR)/include/asm/agp.h 2>/dev/null | grep -c PAGE_AGP)
ifneq ($(PAGE_AGP),0)
EXTRA_CFLAGS += -DHAVE_PAGE_AGP
endif
# Start with all modules turned...
CONFIG_$(MMU) := m
# Enable module builds for the modules requested/supported.
ifneq (,$(findstring $(MMT),$(OPT_MODULES)))
CONFIG_$(MMU) := m
endif
# Kernel version checks
BELOW25 := $(shell if [ $(VERSION) -lt 2 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -lt 5 \) ]; then echo y; fi)
# There were major build changes starting with 2.5.52
ifneq ($(BELOW25),y)
BELOW2552 := $(shell if [ $(VERSION) -lt 2 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -lt 52 \) ]; then echo y; fi)
else
BELOW2552 := y
endif
ifeq ($(BELOW25),y)
O_TARGET := $(MMT).o
list-multi := $(MMT).o
obj-m :=
obj-n :=
obj- :=
export-objs :=
endif
obj-$(CONFIG_$(MMU)) += $(MMT).o
ifeq ($(BELOW2552),y)
include $(TOPDIR)/Rules.make
endif
ifeq ($(BELOW25),y)
$(MMT).o: $($(MMT)-objs) $(lib)
$(LD) -r -o $@ $($(MMT)-objs) $(lib)
endif
endif #VERSION
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------