summaryrefslogtreecommitdiff
path: root/v4l/Makefile
blob: 2a8dc144f69c54f59b2b51ab3918ed106160469f (plain)
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
ifeq ($(obj),)
obj = .
endif

#################################################
# configuration

include $(obj)/Make.config

# symbol exports
export-objs	:= video-buf.o v4l1-compat.o v4l2-common.o
export-objs	+= ir-common.o
export-objs	+= bttv-if.o btcx-risc.o
export-objs	+= cx88-cards.o cx88-core.o

# drivers objects
bttv-objs	:= bttv-driver.o bttv-cards.o bttv-risc.o bttv-if.o \
		   bttv-vbi.o bttv-i2c.o
saa7134-objs    := saa7134-core.o saa7134-i2c.o saa7134-video.o \
		   saa7134-vbi.o saa7134-tvaudio.o saa7134-oss.o \
		   saa7134-cards.o saa7134-ts.o saa7134-input.o \
		   saa7134-alsa.o
cx88xx-objs     := cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o \
                   cx88-input.o
cx8800-objs     := cx88-video.o cx88-vbi.o
cx8802-objs     := cx88-mpeg.o
tuner-objs	:= tuner-core.o tuner-simple.o mt20xx.o tda8290.o tea5767.o
list-multi	:= bttv.o saa7134.o cx88xx.o cx8800.o cx88-alsa.o cx8802.o
em28xx-objs     := em28xx-video.o em28xx-i2c.o em28xx-cards.o em28xx-core.o \
		   em28xx-input.o

# what to build
obj-m				:= video-buf.o v4l1-compat.o v4l2-common.o
obj-$(CONFIG_VIDEO_BTTV)	+= btcx-risc.o ir-common.o bttv.o tveeprom.o
obj-$(CONFIG_VIDEO_CX88)	+= btcx-risc.o cx88xx.o cx8800.o cx8802.o \
                                   cx88-blackbird.o tveeprom.o
obj-$(CONFIG_TVP5150)           += tvp5150.o
obj-$(CONFIG_SAA711X)           += saa711x.o
obj-$(CONFIG_EM28xx)		+= em28xx.o

# THIS IS NOT FINISHED YET --- IT IS HERE ONLY FOR DEVELOPERS !!!!
ifeq ($(CONFIG_VIDEO_ALSA),m)
  cx8801-objs                   := cx88-alsa.o
  obj-$(CONFIG_VIDEO_CX88)	+= cx88-alsa.o
endif

obj-$(CONFIG_VIDEO_SAA7134)	+= saa7134.o saa7134-empress.o saa6752hs.o
obj-$(CONFIG_VIDEO_IR)		+= ir-common.o
obj-$(CONFIG_VIDEO_TUNER)	+= tuner.o tda9887.o saa6588.o
obj-$(CONFIG_VIDEO_TVAUDIO)	+= msp3400.o tvaudio.o tvmixer.o wm8775.o \
				   cs53l32a.o

obj-$(CONFIG_VIDEO_CX88_DVB)	+= video-buf-dvb.o cx88-dvb.o
obj-$(CONFIG_VIDEO_SAA7134_DVB) += video-buf-dvb.o saa7134-dvb.o
obj-$(CONFIG_DVB_BT8XX)         += bt878.o dvb-bt8xx.o dst.o dst_ca.o
obj-$(CONFIG_DVB_FRONTENDS)     += cx22702.o dvb-pll.o or51132.o lgdt330x.o \
                                   mt352.o tda1004x.o sp887x.o nxt6000.o \
                                   cx24110.o or51211.o nxt200x.o

# 2.6-only stuff
ifeq ($(VERSION).$(PATCHLEVEL),2.6)
  ifeq ($(CONFIG_VIDEO_BTTV),m)
    bttv-objs			+= bttv-gpio.o
    obj-$(CONFIG_VIDEO_IR)	+= ir-kbd-gpio.o ir-kbd-i2c.o 
  endif
  ifeq ($(CONFIG_VIDEO_SAA7134),m)
    obj-$(CONFIG_VIDEO_IR)	+= ir-kbd-i2c.o 
  endif
endif

# for DVB
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core/
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends/
ifeq ($(CONFIG_VIDEO_CX88_DVB),m)
 EXTRA_CFLAGS += -DCONFIG_VIDEO_CX88_DVB_MODULE=1
 EXTRA_CFLAGS += -DHAVE_CX22702=1
 EXTRA_CFLAGS += -DHAVE_OR51132=1
 EXTRA_CFLAGS += -DHAVE_LGDT330X=1
 EXTRA_CFLAGS += -DHAVE_MT352=1
 EXTRA_CFLAGS += -DHAVE_NXT200X=1
endif
ifeq ($(CONFIG_VIDEO_SAA7134_DVB),m)
 EXTRA_CFLAGS += -DHAVE_MT352=1
 EXTRA_CFLAGS += -DHAVE_TDA1004X=1
 EXTRA_CFLAGS += -DHAVE_NXT200X=1
endif
ifeq ($(CONFIG_VIDEO_BUF_DVB),m)
 EXTRA_CFLAGS += -DHAVE_VIDEO_BUF_DVB=1
endif

#################################################
# compile modules

ifneq ($(KERNELRELEASE),)

ifeq ($(VERSION).$(PATCHLEVEL),2.6)
 export-objs	:=
 list-multi	:=
else
 multi-m	:= $(filter $(list-multi), $(obj-m))
 int-m		:= $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
 export-objs	:= $(filter $(int-m) $(obj-m),$(export-objs))
endif

CC += -I$(obj)
EXTRA_CFLAGS += -g

EXTRA_CFLAGS += $(if $(wildcard $(srctree)/.mm), -DMM_KERNEL)

snapshot := $(wildcard $(obj)/.snapshot)
ifneq ($(snapshot),)
SNAPSHOT_CFLAGS	:= -DSNAPSHOT='$(shell cat $(snapshot))'
EXTRA_CFLAGS	+= $(SNAPSHOT_CFLAGS)
endif

bttv.o: $(bttv-objs)
	$(LD) -r -o $@ $(bttv-objs)

cx8800.o: $(cx8800-objs)
	$(LD) -g -r -o $@ $(cx8800-objs)

cx88xx.o: $(cx88xx-objs)
	$(LD) -g -r -o $@ $(cx88xx-objs)

saa7134.o: $(saa7134-objs)
	$(LD) -g -r -o $@ $(saa7134-objs)

-include $(TOPDIR)/Rules.make
else
# take version info from last module build if available
-include $(obj)/.version
endif

KDIR		:= /lib/modules/$(KERNELRELEASE)/build
PWD		:= $(shell pwd)
DEST		:= /lib/modules/$(KERNELRELEASE)/$(MDIR)
KDIR26		:= /lib/modules/$(KERNELRELEASE)/kernel/drivers/media
KDIRUSB         := /lib/modules/$(KERNELRELEASE)/kernel/drivers/usb/media

ifeq ($(VERSION).$(PATCHLEVEL),2.6)
 CPPFLAGS := -I$(SUBDIRS)/../linux/include $(CPPFLAGS) -I$(SUBDIRS)/
 MYCFLAGS :=
else
 MYCFLAGS := CFLAGS="-I../linux/include -D__KERNEL__ -I$(KDIR)/include -DEXPORT_SYMTAB"
endif

# which files to install?
inst-m		:= $(wildcard *.ko)
ifeq ($(inst-m),)
  inst-m	:= $(obj-m)
endif

inst_common := ir-common.ko
inst_video := btcx-risc.ko bttv.ko tda9887.ko tuner.ko tvaudio.ko tveeprom.ko saa6588.ko
inst_video += tvmixer.ko v4l1-compat.ko v4l2-common.ko
inst_video += video-buf.ko video-buf-dvb.ko
inst_video += ir-kbd-gpio.ko ir-kbd-i2c.ko msp3400.ko
inst_video += tvp5150.ko saa711x.ko
inst_cx88 := cx8800.ko cx8802.ko cx88-alsa.ko 
inst_cx88 += cx88-blackbird.ko cx88xx.ko cx88-dvb.ko
inst_saa7134 := saa6752hs.ko saa7134.ko saa7134-empress.ko saa7134-dvb.ko
inst_em28xx := em28xx.ko
inst_bt8xx := bt878.ko dvb-bt8xx.ko dst.ko dst_ca.ko
inst_frontends := cx22702.ko dvb-pll.ko lgdt330x.ko or51132.ko tda1004x.ko
inst_frontends += mt352.ko sp887x.ko nxt6000.ko cx24110.ko or51211.ko nxt200x.ko

v4l_modules := $(shell /sbin/lsmod|cut -d' ' -f1 ) $(patsubst %.ko,%,$(inst-m))

# locales seem to cause trouble sometimes.
LC_ALL = POSIX
export LC_ALL

default:: links .version
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) $(MYCFLAGS) modules

links::
	@echo creating symbolic links...
	@find ../linux/drivers/media/video -name '*.[c,h]' -type f -exec ln -sf '{}' . \;
	@find ../linux/drivers/usb/media -name '*.[c,h]' -type f -exec ln -sf '{}' . \;

#	@find ../linux/include -name '*.[h]' -type f -exec ln -sf '{}' . \;

	@ln -sf ../linux/drivers/media/common/ir-common.c .

dvb-links::
	@find ../linux/drivers/media/dvb/frontends -name '*.[c,h]' -type l -exec ln -sf '{}' . \;
	@find ../linux/drivers/media/dvb/bt8xx -name '*.[c,h]' -type l -exec ln -sf '{}' . \;

install:: rminstall
	@echo -e "\nInstalling new V4L modules at corresponding Kernel dir..."

	@strip --strip-debug $(inst-m)

	-install -d $(KDIR26)/common
	-install -m 644 -c $(inst_common) $(KDIR26)/common

	-install -d $(KDIR26)/video
	-install -m 644 -c $(inst_video) $(KDIR26)/video

	-install -d $(KDIR26)/video/cx88
	-install -m 644 -c $(inst_cx88) $(KDIR26)/video/cx88

	-install -d $(KDIR26)/video/saa7134
	-install -m 644 -c $(inst_saa7134) $(KDIR26)/video/saa7134

	-install -d $(KDIR26)/video/em28xx
	-install -m 644 -c $(inst_saa7134) $(KDIR26)/video/em28xx

#	-install -d $(KDIRUSB)
#	-install -m 644 -c $(inst_usb) $(KDIRUSB)/

	/sbin/depmod -a

v4l_install:: rminstall
	@echo -e "\nInstalling new V4L modules at $(DEST)..."

	@strip --strip-debug $(inst-m)

	-install -d $(DEST)
	install -m 644 -c $(inst-m) $(DEST)

	/sbin/depmod -a

kernel-links:: merge-trees
	cd ..;	v4l/scripts/makelinks.sh $(KDIR)

merge-trees::
	@scripts/merge-trees.sh

unmerge-trees::
	@scripts/unmerge-trees.sh

dvb-install:: dvb-rminstall
	@echo -e "\nInstalling new DVB modules at corresponding Kernel dir..."

	@strip --strip-debug $(inst-m)

	install -d $(KDIR26)/dvb/frontends
	install -m 644 -c $(inst_frontends) $(KDIR26)/dvb/frontends

	install -d $(KDIR26)/dvb/bt8xx
	install -m 644 -c $(inst_bt8xx) $(KDIR26)/dvb/bt8xx

	/sbin/depmod -a

dvb-rminstall::
	@echo -e "\nEliminating old DVB modules (errors on this step is not a problem).."

	-@rm -r $(DEST) \
		$(addprefix $(KDIR26)/dvb/bt8xx/, $(inst_bt8xx)) \
		$(addprefix $(KDIR26)/dvb/bt8xx/, $(addsuffix .gz,$(inst_bt8xx))) \
		$(addprefix $(KDIR26)/dvb/frontends/, $(addsuffix .gz,$(inst_frontends))) 2>/dev/null
	@echo

rminstall::
	@echo -e "\nEliminating old V4L modules (errors on this step is not a problem).."

	-@rm -r $(DEST) \
		$(addprefix $(KDIR26)/common/, $(inst_common)) \
		$(addprefix $(KDIR26)/dvb/frontends/, $(inst_frontends)) \
		$(addprefix $(KDIR26)/video/, $(inst_video)) \
		$(addprefix $(KDIR26)/video/cx88/, $(inst_cx88)) \
		$(addprefix $(KDIR26)/video/saa7134/, $(inst_saa7134)) \
		$(addprefix $(KDIR26)/video/em28xx/, $(inst_em28xx)) \
		$(addprefix $(KDIRUSB)/, $(inst_em28xx)) \
		$(addprefix $(KDIR26)/common/, $(addsuffix .gz,$(inst_common))) \
		$(addprefix $(KDIR26)/dvb/frontends/, $(addsuffix .gz,$(inst_frontends))) \
		$(addprefix $(KDIR26)/video/, $(addsuffix .gz,$(inst_video))) \
		$(addprefix $(KDIR26)/video/cx88/, $(addsuffix .gz,$(inst_cx88))) \
		$(addprefix $(KDIR26)/video/saa7134/, $(addsuffix .gz,$(inst_saa7134))) 2>/dev/null \
		$(addprefix $(KDIR26)/video/em28xx/, $(addsuffix .gz,$(inst_em28xx))) 2>/dev/null \
		$(addprefix $(KDIRUSB)/, $(addsuffix .gz,$(inst_em28xx))) 2>/dev/null
	@echo

rmmodules::
	rmmod -w $(shell echo "$(v4l_modules)"|sed s,' ','\n',g|sed s,'-','_',g|sort|uniq -d)

clean::
	find . -name '*.c' -type l -exec rm '{}' \;
	find . -name '*.h' -type l -exec rm '{}' \;
	-rm -f *~ *.o *.ko *.mod.c

distclean:: clean
	-rm -f .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd
	-rm -rf .tmp_versions

change changes changelog::
	make -C .. changelog

cvscommit cvs commit::
	cd ..; cvs commit

.version:
ifneq ($(KERNELRELEASE),)
	echo -e VERSION=$(VERSION)\\nPATCHLEVEL:=$(PATCHLEVEL)\\nSUBLEVEL:=$(SUBLEVEL)\\nKERNELRELEASE:=$(KERNELRELEASE) > $(obj)/.version
else
	echo "No version yet."
	uname -r|perl -ne 'if (/^([0-9]*)\.([0-9])*\.([0-9]*)(.*)$$/) { printf ("VERSION=%s\nPATCHLEVEL:=%s\nSUBLEVEL:=%s\nKERNELRELEASE:=%s.%s.%s%s\n",$$1,$$2,$$3,$$1,$$2,$$3,$$4); };' > $(obj)/.version

endif

#################################################
# build tarballs

RPWD	:= $(shell cd .. && pwd)
thisdir	:= $(notdir $(RPWD))
name    := $(thisdir)
date    := $(shell date +%Y%m%d)
tardest	?= .

snapdir := $(HOME)/snapshot
snap	:= $(name)

snapshot snap tarball: clean
	echo $(thisdir)
	echo $(name)
	echo $(date) > .snapshot
	(cd ..; tar czf $(snapdir)/$(snap)-$(date).tar.gz .)
	cp ChangeLog /$(snapdir)/$(snap)-ChangeLog-$(date)
	$(MAKE) -C $(snapdir)


#################################################
# other stuff

%.asm: %.o
	objdump -S $< > $@

card cardlist cardlists:
	scripts/cardlist