File: Makefile

package info (click to toggle)
lirc 0.7.1pre2-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,852 kB
  • ctags: 2,924
  • sloc: ansic: 31,205; sh: 12,021; makefile: 631
file content (166 lines) | stat: -rw-r--r-- 5,383 bytes parent folder | download
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
include /etc/lirc/lirc-modules-source.conf

# An space should be left at the end of each CFLAGS variable for the
# sanity-check to work.
SERIAL_CFLAGS	:= $(subst ",,$(LIRC_SERIAL_CFLAGS) \
				-DLIRC_PORT=$(LIRC_SERIAL_PORT) \
				-DLIRC_IRQ=$(LIRC_SERIAL_IRQ) ) 
SIR_CFLAGS	:= $(subst ",,$(LIRC_SIR_CFLAGS) \
				-DLIRC_PORT=$(LIRC_SIR_PORT) \
				-DLIRC_IRQ=$(LIRC_SIR_IRQ) )
PARALLEL_CFLAGS	:= $(subst ",,-DLIRC_PORT=$(LIRC_PARALLEL_PORT) \
				-DLIRC_TIMER=$(LIRC_PARALLEL_TIMER) \
				-DLIRC_IRQ=$(LIRC_PARALLEL_IRQ) )

i2c_SUBDIRS := "lirc_i2c lirc_dev"
gpio_SUBDIRS := "lirc_gpio lirc_dev"
it87_SUBDIRS := "lirc_it87"
bt829_SUBDIRS := "lirc_bt829"
serial_SUBDIRS := "lirc_serial"
parallel_SUBDIRS := "lirc_parallel"
sir_SUBDIRS := "lirc_sir"

i2c_MAKEFLAGS="-e"
gpio_MAKEFLAGS="-e"
it87_MAKEFLAGS="-e"
bt829_MAKEFLAGS="-e"

KSRC=/usr/src/linux/$(shell uname -r)/build
KERNEL_LOCATION = $(KSRC)
CC = gcc -D__KERNEL__ -I $(KSRC)/include
CFLAGS= -O2 -g -Wall
DEFS=-DHAVE_CONFIG_H -I. -I../..

KVERS=$(shell sed -n -e '/UTS_RELEASE/s/^[^"]*"\([^"]*\)".*$\/\1/p' $(KSRC)/include/linux/version.h)
KPATCHLEVEL=$(shell echo $(KVERS) | sed -n -e 's/^[0-9]*\.\([0-9]*\)\..*/\1/p')

KEXT=o
ifeq ($(KPATCHLEVEL),6)
KEXT=ko
endif


export KERNEL_LOCATION CC

all: atiusb i2c gpio it87 bt829 serial parallel sir

test:
	@echo '$(LIRC_SERIAL_IRQ)'
	@echo $(LIRC_SIR_IRQ)
	@echo $(LIRC_PARALLEL_IRQ)
	@echo $(SERIAL_CFLAGS)
	@echo $(SIR_CFLAGS)
	@echo $(PARALLEL_CFLAGS)

UNCONFIGURED: #Do nothing if the user didn't configure which drivers to build

debconf: $(subst ", ,$(LIRC_MODULES:,=))

modules:
	mkdir modules

sanity-check:
	@if \
		expr "$(DEFS)" : '.* -DLIRC_IRQ= ' > /dev/null\
		|| expr "$(DEFS)" : '.* -DLIRC_PORT= ' > /dev/null \
		|| expr "$(DEFS)" : '.* -DLIRC_TIMER= '> /dev/null \
		|| expr "$(DEFS)" : '.*UNCONFIGURED'> /dev/null;\
	then \
		echo ;\
		echo "##########################";\
		echo "## CONFIGURATION ERROR: ##";\
		echo "##########################";\
		echo ;\
		echo "You should reconfigure lirc-modules-source and make";\
		echo "sure you don't leave blank any one of IRQ, IO Port or ";\
		echo "Timer (parallel only)";\
		echo ;\
		echo "Hint1: use \"dpkg-reconfigure lirc-modules-source\"";\
		echo "Hint2: If you selected \"automagical\" configuration of";\
		echo "	kernel modules you should probably reconfigure lirc";\
		echo "	instead.";\
		echo "Hint3: you may instead edit /etc/lirc/lirc-modules-source.conf";\
		exit 1;\
	fi

atiusb:: modules sanity-check
	$(MAKE) -e -C drivers SUBDIRS="lirc_atiusb"
	mv drivers/atiusb_dev/lirc_dev.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_dev.$(KEXT).KVERS
	mv drivers/atiusb_i2c/lirc_atiusb.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_i2c.$(KEXT).KVERS

i2c: modules sanity-check
	$(MAKE) -e -C drivers SUBDIRS="lirc_i2c lirc_dev"
	mv drivers/lirc_dev/lirc_dev.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_dev.$(KEXT).KVERS
	mv drivers/lirc_i2c/lirc_i2c.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_i2c.$(KEXT).KVERS

gpio: modules sanity-check
	$(MAKE) -e -C drivers SUBDIRS="lirc_gpio lirc_dev"
	mv drivers/lirc_dev/lirc_dev.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_dev.$(KEXT).KVERS
	mv drivers/lirc_gpio/lirc_gpio.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_gpio.$(KEXT).KVERS

it87: modules sanity-check
	$(MAKE) -e -C drivers SUBDIRS="lirc_it87"
	@echo $(KVERS) $(KSRC) > modules/lirc_it87.o.KVERS
	mv drivers/lirc_it87/lirc_it87.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_it87.$(KEXT).KVERS
	
bt829: modules sanity-check
	$(MAKE) -e -C drivers SUBDIRS="lirc_bt829"
	mv drivers/lirc_bt829/lirc_bt829.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_bt829.$(KEXT).KVERS
	
serial: DEFS += $(SERIAL_CFLAGS)
serial: modules sanity-check
	$(MAKE) -C drivers SUBDIRS="lirc_serial lirc_dev" DEFS="$(DEFS)"
	mv drivers/lirc_dev/lirc_dev.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_dev.$(KEXT).KVERS
	mv drivers/lirc_serial/lirc_serial.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_serial.$(KEXT).KVERS

parallel: DEFS += $(PARALLEL_CFLAGS)
parallel: modules sanity-check
	$(MAKE) -C drivers SUBDIRS="lirc_parallel" DEFS="$(DEFS)"
	mv drivers/lirc_parallel/lirc_parallel.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_parallel.$(KEXT).KVERS

sir: DEFS += $(SIR_CFLAGS)
sir: modules sanity-check
	$(MAKE) -C drivers SUBDIRS="lirc_sir" DEFS="$(DEFS)"
	mv drivers/lirc_sir/lirc_sir.$(KEXT) modules
	@echo $(KVERS) $(KSRC) > modules/lirc_sir.$(KEXT).KVERS
	
install:
	@for file in modules/*.$(KEXT); \
	do \
		kvers=`cut -d" " -f1 $$file.KVERS` && \
		ksrc=`cut -d" " -f2 $$file.KVERS` && \
		dir="$(prefix)/lib/modules/$$kvers/misc/" && \
		( [ -d $$dir ] || mkdir -p $$dir ) && \
		cp -v $$file $$dir ; \
	done
depmod:
	@for file in modules/*.$(KEXT); \
	do \
		kvers=`cut -d" " -f1 $$file.KVERS` && \
		ksrc=`cut -d" " -f2 $$file.KVERS` && \
		dir="$(prefix)/lib/modules/$$kvers/misc/" && \
		if [ -f $$ksrc/System.map ];then \
			/sbin/depmod -r -b $(prefix)/ -a $$kvers \
					-F $$ksrc/System.map ; \
		elif [ -f /boot/System.map-$$kvers ];then \
			/sbin/depmod -r -b $(prefix)/ -a $$kvers \
					-F /boot/System.map-$$kvers; \
		else \
			/sbin/depmod -a ;\
		fi ;\
	done

clean:
	$(MAKE) clean -C drivers SUBDIRS="lirc_serial lirc_parallel lirc_i2c lirc_sir lirc_dev lirc_gpio"
	rm -rf modules