annotate src/CMakeLists.txt @ 395:17e8a4bc06a7 default tip

add macOS AR/RANLIB
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 14 Dec 2020 21:59:50 +0900
parents 72c38f531ae2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
997c54d8912c fix include dir
kono
parents:
diff changeset
1 cmake_minimum_required(VERSION 3.8)
94
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
2 project(xv6cbc NONE)
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
3 set(BUILD_DIR ${PROJECT_BINARY_DIR})
94
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
4
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
5
59
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
6 add_subdirectory(tools)
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
7 add_subdirectory(usr)
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
8 enable_language(C ASM)
42
997c54d8912c fix include dir
kono
parents:
diff changeset
9
997c54d8912c fix include dir
kono
parents:
diff changeset
10 set(USE_CUDA,0)
997c54d8912c fix include dir
kono
parents:
diff changeset
11 # -DUSE_CUDA
997c54d8912c fix include dir
kono
parents:
diff changeset
12 # add_definitions("-Wall -g -O")
997c54d8912c fix include dir
kono
parents:
diff changeset
13
997c54d8912c fix include dir
kono
parents:
diff changeset
14 # -DCMAKE_BUILD_TYPE=Debug
997c54d8912c fix include dir
kono
parents:
diff changeset
15 set(CMAKE_C_FLAGS_DEBUG "-O0")
58
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
16 add_definitions(${PMAKE_ARGS})
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
17
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
18 #add_custom_command(OUTPUT tools
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
19 # COMMAND "cd ${CMAKE_CURRENT_SOURCE_DIR}/tools && make run"
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
20 #)
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
21 # #WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools
f1b965f53d3b add tools userlists
tobaru
parents: 56
diff changeset
22
42
997c54d8912c fix include dir
kono
parents:
diff changeset
23
997c54d8912c fix include dir
kono
parents:
diff changeset
24 if (${USE_CUDA})
997c54d8912c fix include dir
kono
parents:
diff changeset
25 include_directories("/usr/local/cuda/include")
86
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
26 #include_directories(${CMAKE_SOURCE_DIR})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
27 set(NVCCFLAG "-std=c++11" "-g" "-O0" )
997c54d8912c fix include dir
kono
parents:
diff changeset
28 if (UNIX AND NOT APPLE) # LINUX
997c54d8912c fix include dir
kono
parents:
diff changeset
29 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart")
997c54d8912c fix include dir
kono
parents:
diff changeset
30 elseif (APPLE)
997c54d8912c fix include dir
kono
parents:
diff changeset
31 set(CUDA_LINK_FLAGS "-framework CUDA -lc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names /usr/local/cuda/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib")
997c54d8912c fix include dir
kono
parents:
diff changeset
32 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
33 find_package(CUDA REQUIRED)
997c54d8912c fix include dir
kono
parents:
diff changeset
34 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
997c54d8912c fix include dir
kono
parents:
diff changeset
35 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
36
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
37 set(CMAKE_BEFORE_PROJECT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
38 configure_file("${CMAKE_SOURCE_DIR}/kernel-cmake.ld" "${CMAKE_CURRENT_BINARY_DIR}/kernel-cmake.ld" COPYONLY)
42
997c54d8912c fix include dir
kono
parents:
diff changeset
39
997c54d8912c fix include dir
kono
parents:
diff changeset
40 macro( GearsCommand )
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
41 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DXV6KERNEL")
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
42 set(CMAKE_C_COMPILER "${CBC_COM}")
94
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
43 set(CMAKE_ASM_COMPILER "${CBC_COM}")
0956648d24e5 impl cmake on macos
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
44
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
45 set(CMAKE_LINKER "${X_CMAKE_LINKER}")
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
46 set(CMAKE_C_LINK_EXECUTABLE "${X_CMAKE_C_LINK_EXECUTABLE}")
42
997c54d8912c fix include dir
kono
parents:
diff changeset
47 set( _OPTIONS_ARGS )
997c54d8912c fix include dir
kono
parents:
diff changeset
48 set( _ONE_VALUE_ARGS TARGET )
997c54d8912c fix include dir
kono
parents:
diff changeset
49 set( _MULTI_VALUE_ARGS SOURCES )
997c54d8912c fix include dir
kono
parents:
diff changeset
50 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
84
a4307abefd0b include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents: 83
diff changeset
51 set(CMAKE_KERNEL_DIR "${CMAKE_BINARY_DIR}")
a4307abefd0b include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents: 83
diff changeset
52 set(CMAKE_KERNEL_DIR_C "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${_Gears_TARGET}.dir")
42
997c54d8912c fix include dir
kono
parents:
diff changeset
53
43
b94d72292dfa fix build arm asm file
anatofuz
parents: 42
diff changeset
54 set (_Gears_CBC_SOURCES)
42
997c54d8912c fix include dir
kono
parents:
diff changeset
55 set (_Gears_CSOURCES)
997c54d8912c fix include dir
kono
parents:
diff changeset
56 foreach(i ${_Gears_SOURCES})
997c54d8912c fix include dir
kono
parents:
diff changeset
57 if (${i} MATCHES "\\.cbc")
997c54d8912c fix include dir
kono
parents:
diff changeset
58 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
997c54d8912c fix include dir
kono
parents:
diff changeset
59 add_custom_command (
84
a4307abefd0b include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents: 83
diff changeset
60 OUTPUT ${CMAKE_KERNEL_DIR_C}/${j}
42
997c54d8912c fix include dir
kono
parents:
diff changeset
61 DEPENDS ${i}
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
62 COMMAND "cd" "${CMAKE_KERNEL_DIR_C}" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "--project" "xv6" "-o" ${j} ${CMAKE_SOURCE_DIR}/${i}
42
997c54d8912c fix include dir
kono
parents:
diff changeset
63 )
84
a4307abefd0b include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents: 83
diff changeset
64 list(APPEND _Gears_CBC_SOURCES "${CMAKE_KERNEL_DIR_C}/${j}")
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
65 #list(APPEND _Gears_CBC_SOURCES ${j})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
66 elseif (${i} MATCHES "\\.cu")
997c54d8912c fix include dir
kono
parents:
diff changeset
67 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
997c54d8912c fix include dir
kono
parents:
diff changeset
68 add_custom_command (
74
10d09cd9fad3 set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents: 73
diff changeset
69 OUTPUT ${CMAKE_KERNEL_DIR}/${j}
42
997c54d8912c fix include dir
kono
parents:
diff changeset
70 DEPENDS ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
71 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
72 )
74
10d09cd9fad3 set variable CMAKE_KERNEL_DIR on src/CMakeLists.txt
anatofuz
parents: 73
diff changeset
73 list(APPEND _Gears_CBC_SOURCES ${CMAKE_KERNEL_DIR}/${j})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
74 else()
997c54d8912c fix include dir
kono
parents:
diff changeset
75 set(j ${i})
73
0bf6872eb250 fix build kernel.dir
anatofuz
parents: 70
diff changeset
76 #list(APPEND _Gears_CSOURCES "${CMAKE_BINARY_DIR}/${_Gears_TARGET}.dir/${j}")
43
b94d72292dfa fix build arm asm file
anatofuz
parents: 42
diff changeset
77 list(APPEND _Gears_CSOURCES ${j})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
78 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
79 endforeach(i)
997c54d8912c fix include dir
kono
parents:
diff changeset
80
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 59
diff changeset
81 #target_link_libraries(syslib)
84
a4307abefd0b include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents: 83
diff changeset
82 file(COPY "${CMAKE_SOURCE_DIR}/interface/" DESTINATION ${CMAKE_KERNEL_DIR_C})
87
add5e775339c tweak origin-context.h to context.t
anatofuz
parents: 86
diff changeset
83 file(GLOB XV6_HEADERS "${CMAKE_SOURCE_DIR}/*.h")
add5e775339c tweak origin-context.h to context.t
anatofuz
parents: 86
diff changeset
84 file(COPY ${XV6_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C})
193
1301727600cc success build
anatofuz
parents: 192
diff changeset
85 file(GLOB XV6_IMPL_HEADERS "${CMAKE_SOURCE_DIR}/impl/*.h")
1301727600cc success build
anatofuz
parents: 192
diff changeset
86 file(COPY ${XV6_IMPL_HEADERS} DESTINATION ${CMAKE_KERNEL_DIR_C})
87
add5e775339c tweak origin-context.h to context.t
anatofuz
parents: 86
diff changeset
87 include_directories(${CMAKE_KERNEL_DIR_C})
42
997c54d8912c fix include dir
kono
parents:
diff changeset
88 add_custom_command (
86
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
89 OUTPUT ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
90 DEPENDS ${_Gears_CBC_SOURCES} fs.img initcode
354
fde5f96c6ff1 use common perl script
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
91 COMMAND "cd" "CMakeFiles/kernel.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "--project" "xv6" "-o" ${_Gears_TARGET} "-w" ${_Gears_CBC_SOURCES}
42
997c54d8912c fix include dir
kono
parents:
diff changeset
92 )
84
a4307abefd0b include context.h on proc.h and ajastment directory on CMakeList.txt
tobaru
parents: 83
diff changeset
93 # add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR}/c/${_Gears_TARGET}-context.c )
86
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
94 file(COPY "${CMAKE_SOURCE_DIR}/device" DESTINATION "${CMAKE_KERNEL_DIR_C}")
765449889623 fix translate interface routine
anatofuz
parents: 85
diff changeset
95 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${CMAKE_KERNEL_DIR_C}/c/${_Gears_TARGET}-context.c )
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
96 # target_link_libraries(${_Gears_TARGET} m pthread)
42
997c54d8912c fix include dir
kono
parents:
diff changeset
97 endmacro()
997c54d8912c fix include dir
kono
parents:
diff changeset
98
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
99
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
100 set(CMAKE_C_FLAGS "${INITOCDE_CFLAGS}")
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
101 set(CMAKE_ASM_LINK_EXECUTABLE "${INITOCDE_LINK_EXECUTABLE}")
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
102 add_executable(initcode.o ${CMAKE_SOURCE_DIR}/initcode.S)
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
103 set_target_properties(initcode.o PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir")
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
104 add_custom_command(
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
105 OUTPUT "initcode"
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
106 DEPENDS initcode.o
107
5f01480e8f12 Mac build
tobaru
parents: 94
diff changeset
107 COMMAND "${XV6_OBJCOPY}" "-S" "-O" "binary" "--prefix-symbols=\"_binary_build/initcode\"" "${CMAKE_BEFORE_PROJECT_PATH}/kernel.dir/initcode.o" "initcode"
66
101b229f182d build initcode
anatofuz
parents: 64
diff changeset
108 )
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
109 #file(COPY "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/initcode.o.dir/initcode" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
126
99be03babde3 copy debug scripts from cmake sources
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 111
diff changeset
110 file(COPY "${CMAKE_SOURCE_DIR}/debug.sh" "${CMAKE_SOURCE_DIR}/run-debug.sh" "${CMAKE_SOURCE_DIR}/connect.gdb" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
70
1e1c6feb7d83 fix build initcode
anatofuz
parents: 69
diff changeset
111
42
997c54d8912c fix include dir
kono
parents:
diff changeset
112
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
113 GearsCommand (
42
997c54d8912c fix include dir
kono
parents:
diff changeset
114 TARGET
997c54d8912c fix include dir
kono
parents:
diff changeset
115 kernel
997c54d8912c fix include dir
kono
parents:
diff changeset
116 SOURCES
367
anatofuz
parents: 354
diff changeset
117 string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.cbc fs.c log.c main.c memide.c pipe.cbc proc.cbc spinlock.cbc
anatofuz
parents: 354
diff changeset
118 start.c swtch.S syscall.cbc sysfile.cbc sysproc.c trap_asm.S trap.cbc vm.c device/picirq.c device/timer.c device/uart.c
389
174e02ed3509 remove vm_impl.cbc
anatofuz
parents: 387
diff changeset
119 SingleLinkedStack.cbc entry.S
174e02ed3509 remove vm_impl.cbc
anatofuz
parents: 387
diff changeset
120 impl/KernelRetImpl.cbc impl/KernelError.cbc impl/SyscallDispatchImpl.cbc impl/CbCProcImpl.cbc init_kernel_context.cbc impl/ReadSyscallImpl.cbc impl/ReadSyscallEntry.cbc
42
997c54d8912c fix include dir
kono
parents:
diff changeset
121 )
149
654f2dadd744 add inode.h
menikon
parents: 132
diff changeset
122
154
343f8f3c8f18 add pipe.h
anatofuz
parents: 149
diff changeset
123 # sys_read_impl.cbc