mini/Makefile
branchkernel2.6
changeset 22 e8c2cd004e0b
parent 16 f04e93b8af0f
child 24 d417dd9bdc2f
--- a/mini/Makefile	Fri Nov 25 10:16:50 2005 +0000
+++ b/mini/Makefile	Fri Nov 25 14:52:34 2005 +0000
@@ -8,47 +8,33 @@
 #
 #----------------------------------------------------------------
 
-CONFIG_FILE = ../ethercat.conf
+ifneq ($(KERNELRELEASE),)
 
-ifeq ($(CONFIG_FILE),$(wildcard $(CONFIG_FILE)))
-include $(CONFIG_FILE)
-else
-KERNELDIR = /vol/projekte/msr_messen_steuern_regeln/linux/kernel/2.4.20/include/linux-2.4.20.CX1100-rthal5
-RTAIDIR   = /vol/projekte/msr_messen_steuern_regeln/linux/kernel/2.4.20/include/rtai-24.1.13
-RTLIBDIR  = rt_lib
-endif
+#----------------------------------------------------------------
+# Kbuild-Abschnitt
 
-CFLAGS = -O2 -Wall -Wuninitialized -D__KERNEL__ \
-	-DMODULE -I$(KERNELDIR)/include
+obj-m := ec_mini_mod.o
 
-MODULE = ec_mini_mod.o
-SRC = ec_mini.c
-OBJ = $(SRC:.c=.o)
+ec_mini_mod-objs := ec_mini.o
 
 #----------------------------------------------------------------
 
-all: .output_dirs .depend Makefile $(MODULE)
+else
 
-$(MODULE): $(OBJ)
-	$(LD) -r $(OBJ) -o $@
+#----------------------------------------------------------------
+# Default-Abschnitt
 
-.output_dirs:
-	@echo "x-- Directories -------------"
-	@echo "| Kernel $(KERNELDIR)"
-	@echo "| RTAI   $(RTAIDIR)"
-	@echo "| RT_lib $(RTLIBDIR)"
-	@echo "x----------------------------"
+CONFIG_FILE = ../ethercat.conf
+PWD = $(shell pwd)
 
-depend .depend dep:
-	$(CC) $(CFLAGS) -M $(SRC) > .depend
+include $(CONFIG_FILE) # Für KERNELDIR
+
+default:
+	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
 
 clean:
-	rm -f *.o *~ core .depend
+	$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
 
 #----------------------------------------------------------------
 
-ifeq (.depend,$(wildcard .depend))
-include .depend
 endif
-
-#----------------------------------------------------------------