Advertisement
Guest User

Untitled

a guest
Feb 15th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.94 KB | None | 0 0
  1. ################################################################
  2. #
  3. # TDRV009 Device Driver Makefile
  4. #
  5. # Copyright (c) 2007 by TEWS-TECHNOLOGIES GmbH
  6. #
  7. ################################################################
  8.  
  9. MOD_PREFIX = tdrv009
  10.  
  11. #
  12. #
  13. #
  14.  
  15. VER := $(shell uname -r)
  16. LINUX_2_6_x := 2.6.
  17. KVERSION_AE_2_6 := $(findstring $(strip $(LINUX_2_6_x)),$(VER))
  18. INCLUDEDIR = /lib/modules/$(VER)/build/include
  19. INSTALL_DIR = /lib/modules/$(VER)/misc
  20.  
  21. TARGET = $(MOD_PREFIX)drv
  22. DRV_C = $(MOD_PREFIX).c
  23. DRV_PRIV_H = $(MOD_PREFIX)def.h
  24. DRV_PUB_H = $(MOD_PREFIX).h
  25. DI_MODS_SRC = include/*.c include/*.h
  26.  
  27.  
  28. ifeq ($(KVERSION_AE_2_6),)
  29. ###########################
  30. # Compiling for old kernels
  31. ###########################
  32.  
  33. # Use this for older Kernel Versions before 2.4.4
  34. #INCLUDEDIR = /usr/include
  35.  
  36. CFLAGS = -D__KERNEL__ -I$(INCLUDEDIR) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
  37.           -pipe -fno-strength-reduce -DMODULE
  38.  
  39. OBJS = $(TARGET).o
  40.  
  41. all:    $(OBJS)
  42.  
  43. clean:
  44.     rm -f *.o
  45.  
  46. $(TARGET).o: $(DRV_C) $(DRV_PRIV_H) $(DRV_PUB_H) $(DI_MODS_SRC) Makefile
  47.     @echo "Compiling for kernels older than 2.6.x..."
  48.     $(CC) $(CFLAGS) -c $< -o $@
  49.  
  50. install:    $(TARGET).o
  51.     install -d $(INSTALL_DIR)
  52.     install -c $(TARGET).o $(INSTALL_DIR)
  53.  
  54. uninstall:
  55.     rm -f $(INSTALL_DIR)/$(TARGET).o
  56.  
  57.  
  58.  
  59. else
  60. #############################
  61. # Compiling for 2.6.x kernels
  62. #############################
  63.  
  64. ifneq ($(KERNELRELEASE),)
  65. obj-m += $(TARGET).o
  66. $(TARGET)-objs := $(MOD_PREFIX).o
  67.  
  68. else
  69.  
  70. KDIR:= /lib/modules/$(shell uname -r)/build
  71. PWD:= $(shell pwd)
  72.  
  73. clean:
  74.     rm -f *.ko
  75.     rm -f *.o
  76.     rm -f *.mod.c
  77.     rm -f .tp*
  78.     rm -f .$(MOD_PREFIX)*
  79.     rm -fr .tmp_versions
  80.  
  81. install:    $(DRV_C) $(DRV_PRIV_H) $(DRV_PUB_H) $(DI_MODS_SRC) Makefile
  82.     @echo "Compiling for a 2.6.x+ kernel..."
  83.     $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
  84.     install -d $(INSTALL_DIR)
  85.     install -c $(TARGET).ko $(INSTALL_DIR)
  86.  
  87. uninstall:
  88.     rm -f $(INSTALL_DIR)/$(TARGET).ko
  89.  
  90. endif
  91.  
  92. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement