annotate maintainers_add_add_rathaxes_lkm_in_use_rathaxes_cmake_file.patch @ 15:74d9d18d4732

WIP on the ethernet part of the LKM sample
author Louis Opter <louis@lse.epitech.net>
date Fri, 06 Jan 2012 22:46:33 +0100
parents 5b128dbd2c17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
1 # HG changeset patch
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 6
diff changeset
2 # Parent dd92091de0edd583c8dd1ff884b5ca5fcd080c3d
6
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
3 maintainers: add the equivalent of ADD_RATHAXES_EXECUTABLE for kernel modules, only support Linux for now
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
4
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
5 diff --git a/maintainers/CMakeScripts/Templates/MakefileLKM.in b/maintainers/CMakeScripts/Templates/MakefileLKM.in
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
6 new file mode 100644
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
7 --- /dev/null
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
8 +++ b/maintainers/CMakeScripts/Templates/MakefileLKM.in
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
9 @@ -0,0 +1,12 @@
15
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 6
diff changeset
10 +KDIR = /lib/modules/$(shell uname -r)/build
74d9d18d4732 WIP on the ethernet part of the LKM sample
Louis Opter <louis@lse.epitech.net>
parents: 6
diff changeset
11 +obj-m := @LKM_OBJECTS@
6
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
12 +
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
13 +all:
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
14 + $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) modules
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
15 +
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
16 +install:
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
17 + $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) modules_install
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
18 + depmod -a
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
19 +clean:
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
20 + rm -rf *~
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
21 + $(MAKE) -C $(KDIR) M=$(PWD) clean
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
22 diff --git a/maintainers/CMakeScripts/UseRathaxes.cmake b/maintainers/CMakeScripts/UseRathaxes.cmake
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
23 --- a/maintainers/CMakeScripts/UseRathaxes.cmake
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
24 +++ b/maintainers/CMakeScripts/UseRathaxes.cmake
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
25 @@ -114,6 +114,8 @@
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
26 "${RATHAXES_SOURCE_DIR}/rathaxes/compiler/rtx*.cw[sp]"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
27 "${RATHAXES_SOURCE_DIR}/rathaxes/compiler/rathaxes.cws")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
28
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
29 + # ADD_CUSTOM_COMMAND + ADD_CUSTOM_TARGET is a CMake idiom to add a target
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
30 + # that should be rebuilt automatically when its sources change.
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
31 STRING(REPLACE ";" ", " SYSTEMS "${SYSTEMS}")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
32 ADD_CUSTOM_COMMAND(OUTPUT ${OUTPUTS}
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
33 COMMAND ${_RTX_CODEWORKER_COMMAND} "cache" "clear"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
34 @@ -160,3 +162,51 @@
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
35 ADD_EXECUTABLE(${NAME} "${RATHAXES_SOURCE}_${SYSTEM}.c")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
36 ADD_DEPENDENCIES(${NAME} ${RATHAXES_SOURCE})
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
37 ENDFUNCTION(ADD_RATHAXES_EXECUTABLE NAME RATHAXES_SOURCE)
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
38 +
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
39 +# This function build a native kernel module from a previously generated
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
40 +# Rathaxes sources. It works by setting up a build directory and calling the
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
41 +# native build tools from there.
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
42 +#
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
43 +# Usage: ADD_RATHAXES_LKM(NAME RATHAXES_SOURCE [SYSTEM])
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
44 +#
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
45 +# RATHAXES_SOURCE must corresponds to the first argument of a call to
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
46 +# ADD_RATHAXES_SOURCES.
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
47 +#
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
48 +# The third argument SYSTEM may be used if the target system doesn't correspond
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
49 +# to CMAKE_SYSTEM_NAME.
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
50 +FUNCTION(ADD_RATHAXES_LKM NAME RATHAXES_SOURCE)
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
51 + IF (${ARGC} EQUAL 2)
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
52 + SET(SYSTEM ${CMAKE_SYSTEM_NAME})
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
53 + ELSE (${ARGC} EQUAL 2)
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
54 + SET(SYSTEM ${ARGV2})
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
55 + ENDIF (${ARGC} EQUAL 2)
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
56 +
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
57 + IF (${SYSTEM} MATCHES "Linux")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
58 + # Create a little build space for the native Linux build-chain.
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
59 + SET(MODULE_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${NAME}.dir/${SYSTEM}Build/")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
60 +
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
61 + # Generate the Linux Makefile to build a Linux kernel module
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
62 + SET(MODULE_MAKEFILE "${MODULE_BUILD_DIR}/Makefile")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
63 + SET(LKM_OBJECTS "${RATHAXES_SOURCE}_${SYSTEM}.o")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
64 + CONFIGURE_FILE("${RATHAXES_SOURCE_DIR}/maintainers/CMakeScripts/Templates/MakefileLKM.in"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
65 + "${MODULE_MAKEFILE}")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
66 +
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
67 + SET(KERNEL_OBJECT_NAME "${RATHAXES_SOURCE}_${SYSTEM}.ko")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
68 + ADD_CUSTOM_COMMAND(OUTPUT "${KERNEL_OBJECT_NAME}"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
69 + # The linux Makefile to build kernel module is quite
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
70 + # picky about file location and its own name. Let's
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
71 + # copy our source side by side with the Makefile:
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
72 + COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${RATHAXES_SOURCE}_${SYSTEM}.c" "${MODULE_BUILD_DIR}"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
73 + # Then call make in the little build space we created
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
74 + COMMAND "${CMAKE_COMMAND}" "-E" "chdir" "${MODULE_BUILD_DIR}" "${CMAKE_BUILD_TOOL}"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
75 + # Finally copy the generated .ko back into the current binary dir
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
76 + COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${MODULE_BUILD_DIR}/${KERNEL_OBJECT_NAME}" "${CMAKE_CURRENT_BINARY_DIR}"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
77 + COMMENT "Building Rathaxes Linux LKM for ${NAME}"
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
78 + VERBATIM
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
79 + DEPENDS "${RATHAXES_SOURCE}_${SYSTEM}.c")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
80 +
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
81 + ADD_CUSTOM_TARGET("${NAME}" ALL DEPENDS "${KERNEL_OBJECT_NAME}")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
82 + ELSE (${SYSTEM} MATCHES "Linux")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
83 + MESSAGE(STATUS "Don't know how to build kernel modules for ${SYSTEM} (yet)")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
84 + ENDIF (${SYSTEM} MATCHES "Linux")
5b128dbd2c17 WIP on the PCI LKM + improve the UseRathaxes CMake "library" to easily build a kernel module from the sources generated by rathaxes
Louis Opter <louis@lse.epitech.net>
parents:
diff changeset
85 +ENDFUNCTION(ADD_RATHAXES_LKM NAME RATHAXES_SOURCE)