Hi,
I joined some patches to have a Makefile compatible with both 2.4 and
2.6+ kernels. With this Makefile, in the 2.6+ case, the .ko files will
be correctly put in the package instead of the .o file.
The other difference for 2.6+ kernels is that for the serial driver,
lirc_dev is also compiled and packaged as lirc_serial depends now on
lirc_dev. I suppose it's the same for lirc_parallel and others, if
someone can confirm...
Patch Makefile1.patch just factor some code in the Makefile.
Patch Makefile2.patch add the 2.6+ case handling.
I also joined the final makefile.
(this bug is a duplicate of bug 287328)
Yann
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/
KERNEL_LOCATION = $(KSRC)
CC = gcc -D__KERNEL__ -I $(KSRC)/include
CFLAGS= -O2 -g -Wall
DEFS=-DHAVE_CONFIG_H -I. -I../..
KVERS=`sed -n -e '/UTS_RELEASE/s/^[^"]*"\([^"]*\)".*$$/\1/p'
$(KSRC)/include/linux/version.h`
KMAJOR := $(shell echo ${KVERS} | cut -d. -f1)
KMINOR := $(shell echo ${KVERS} | cut -d. -f2)
KERNEL26PLUS := $(shell [ ${KMAJOR} -ge 2 ] && [ ${KMINOR} -ge 6 ] && echo
"yes")
KERNELEXT = o
ifeq ($(KERNEL26PLUS),yes)
KERNELEXT = ko
serial_SUBDIRS := "lirc_serial lirc_dev"
endif
export KERNEL_LOCATION CC
all: 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
i2c gpio it87 bt829 serial parallel sir: DEFS += $([EMAIL PROTECTED])
i2c gpio it87 bt829 serial parallel sir: modules sanity-check
$(MAKE) [EMAIL PROTECTED] -C drivers [EMAIL PROTECTED] DEFS="$(DEFS)"
@[EMAIL PROTECTED]; for subdir in $$list; do \
mv drivers/$$subdir/$$subdir.${KERNELEXT} modules; \
echo $(KVERS) $(KSRC) > modules/$$subdir.${KERNELEXT}.KVERS; \
done
install:
@for file in modules/*.${KERNELEXT}; \
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/*.${KERNELEXT}; \
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
--- Makefile.orig 2005-01-13 23:54:52.000000000 +0100
+++ Makefile 2005-01-13 23:57:07.000000000 +0100
@@ -2,16 +2,28 @@
# An space should be left at the end of each CFLAGS variable for the
# sanity-check to work.
-SERIAL_CFLAGS := $(subst ",,$(LIRC_SERIAL_CFLAGS) \
+serial_CFLAGS := $(subst ",,$(LIRC_SERIAL_CFLAGS) \
-DLIRC_PORT=$(LIRC_SERIAL_PORT) \
-DLIRC_IRQ=$(LIRC_SERIAL_IRQ) )
-SIR_CFLAGS := $(subst ",,$(LIRC_SIR_CFLAGS) \
+sir_CFLAGS := $(subst ",,$(LIRC_SIR_CFLAGS) \
-DLIRC_PORT=$(LIRC_SIR_PORT) \
-DLIRC_IRQ=$(LIRC_SIR_IRQ) )
-PARALLEL_CFLAGS := $(subst ",,-DLIRC_PORT=$(LIRC_PARALLEL_PORT) \
+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/
KERNEL_LOCATION = $(KSRC)
@@ -64,47 +76,14 @@
exit 1;\
fi
-i2c: modules sanity-check
- $(MAKE) -e -C drivers SUBDIRS="lirc_i2c lirc_dev"
- mv drivers/lirc_dev/lirc_dev.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_dev.o.KVERS
- mv drivers/lirc_i2c/lirc_i2c.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_i2c.o.KVERS
-
-gpio: modules sanity-check
- $(MAKE) -e -C drivers SUBDIRS="lirc_gpio lirc_dev"
- mv drivers/lirc_dev/lirc_dev.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_dev.o.KVERS
- mv drivers/lirc_gpio/lirc_gpio.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_gpio.o.KVERS
-
-it87: modules sanity-check
- $(MAKE) -e -C drivers SUBDIRS="lirc_it87"
- mv drivers/lirc_it87/lirc_it87.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_it87.o.KVERS
-
-bt829: modules sanity-check
- $(MAKE) -e -C drivers SUBDIRS="lirc_bt829"
- mv drivers/lirc_bt829/lirc_bt829.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_bt829.o.KVERS
-
-serial: DEFS += $(SERIAL_CFLAGS)
-serial: modules sanity-check
- $(MAKE) -C drivers SUBDIRS="lirc_serial" DEFS="$(DEFS)"
- mv drivers/lirc_serial/lirc_serial.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_serial.o.KVERS
-
-parallel: DEFS += $(PARALLEL_CFLAGS)
-parallel: modules sanity-check
- $(MAKE) -C drivers SUBDIRS="lirc_parallel" DEFS="$(DEFS)"
- mv drivers/lirc_parallel/lirc_parallel.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_parallel.o.KVERS
-
-sir: DEFS += $(SIR_CFLAGS)
-sir: modules sanity-check
- $(MAKE) -C drivers SUBDIRS="lirc_sir" DEFS="$(DEFS)"
- mv drivers/lirc_sir/lirc_sir.o modules
- @echo $(KVERS) $(KSRC) > modules/lirc_sir.o.KVERS
+
+i2c gpio it87 bt829 serial parallel sir: DEFS += $([EMAIL PROTECTED])
+i2c gpio it87 bt829 serial parallel sir: modules sanity-check
+ $(MAKE) [EMAIL PROTECTED] -C drivers [EMAIL PROTECTED] DEFS="$(DEFS)"
+ @[EMAIL PROTECTED]; for subdir in $$list; do \
+ mv drivers/$$subdir/$$subdir.o modules; \
+ echo $(KVERS) $(KSRC) > modules/$$subdir.o.KVERS; \
+ done
install:
@for file in modules/*.o; \
--- Makefile 2005-01-14 00:23:08.000000000 +0100
+++ Makefile.best 2005-01-14 00:22:49.000000000 +0100
@@ -32,6 +32,16 @@
DEFS=-DHAVE_CONFIG_H -I. -I../..
KVERS=`sed -n -e '/UTS_RELEASE/s/^[^"]*"\([^"]*\)".*$$/\1/p' $(KSRC)/include/linux/version.h`
+KMAJOR := $(shell echo ${KVERS} | cut -d. -f1)
+KMINOR := $(shell echo ${KVERS} | cut -d. -f2)
+KERNEL26PLUS := $(shell [ ${KMAJOR} -ge 2 ] && [ ${KMINOR} -ge 6 ] && echo "yes")
+KERNELEXT = o
+
+ifeq ($(KERNEL26PLUS),yes)
+ KERNELEXT = ko
+ serial_SUBDIRS := "lirc_serial lirc_dev"
+endif
+
export KERNEL_LOCATION CC
@@ -81,12 +91,12 @@
i2c gpio it87 bt829 serial parallel sir: modules sanity-check
$(MAKE) [EMAIL PROTECTED] -C drivers [EMAIL PROTECTED] DEFS="$(DEFS)"
@[EMAIL PROTECTED]; for subdir in $$list; do \
- mv drivers/$$subdir/$$subdir.o modules; \
- echo $(KVERS) $(KSRC) > modules/$$subdir.o.KVERS; \
+ mv drivers/$$subdir/$$subdir.${KERNELEXT} modules; \
+ echo $(KVERS) $(KSRC) > modules/$$subdir.${KERNELEXT}.KVERS; \
done
install:
- @for file in modules/*.o; \
+ @for file in modules/*.${KERNELEXT}; \
do \
kvers=`cut -d" " -f1 $$file.KVERS` && \
ksrc=`cut -d" " -f2 $$file.KVERS` && \
@@ -95,7 +105,7 @@
cp -v $$file $$dir ; \
done
depmod:
- @for file in modules/*.o; \
+ @for file in modules/*.${KERNELEXT}; \
do \
kvers=`cut -d" " -f1 $$file.KVERS` && \
ksrc=`cut -d" " -f2 $$file.KVERS` && \