annotate src/usr/CMakeLists.txt @ 94:d876c9a65239 default tip

impl mac os target
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 23 Oct 2019 14:31:38 +0900
parents add5e775339c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
1 cmake_minimum_required(VERSION 3.8)
59
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
2 set(CMAKE_C_COMPILER "/usr/bin/cc")
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
3 project(usr C ASM)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
4
94
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
5 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
6 set(CMAKE_SYSROOT "${CBC_XV6_SYSROOT}")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
7 set(CMAKE_OSX_SYSROOT "${CBC_XV6_SYSROOT}")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
8 include_directories("${CMAKE_OSX_SYSROOT}")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
9 include_directories(SYSTEM "${CMAKE_OSX_SYSROOT}/usr/include")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
10 include_directories(SYSTEM "${CMAKE_OSX_SYSROOT}/usr/include/arm-linux-gnueabihf")
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
11 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
12 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
13 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
14 set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
15 endif()
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
16
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
17
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
18 set(CMAKE_C_FLAGS_DEBUG "-O0")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
19 add_definitions(${PMAKE_ARGS})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
20 set(CMAKE_C_COMPILER "${CBC_COM}")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
21
69
f236eba62a76 off-the-shelf cmakefile
anatofuz
parents: 65
diff changeset
22 #include_directories("..")
63
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
23 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ")
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
24 set(CMAKE_C_LINK_EXECUTABLE "${KERNEL_LINK_EXECUTABLE}")
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
25 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LIB} -nostdlib")
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
26
94
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
27
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
28 macro( GearsCommand )
69
f236eba62a76 off-the-shelf cmakefile
anatofuz
parents: 65
diff changeset
29 include_directories(${CMAKE_SOURCE_DIR})
f236eba62a76 off-the-shelf cmakefile
anatofuz
parents: 65
diff changeset
30 include_directories(${CMAKE_SOURCE_DIR}/usr)
f236eba62a76 off-the-shelf cmakefile
anatofuz
parents: 65
diff changeset
31 include_directories(${CMAKE_BINARY_DIR}/usr/c)
f236eba62a76 off-the-shelf cmakefile
anatofuz
parents: 65
diff changeset
32
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
33 set( _OPTIONS_ARGS )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
34 set( _ONE_VALUE_ARGS TARGET )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
35 set( _MULTI_VALUE_ARGS SOURCES )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
36 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
37
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
38 set (_Gears_CBC_SOURCES)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
39 set (_Gears_CSOURCES)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
40 foreach(i ${_Gears_SOURCES})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
41 if (${i} MATCHES "\\.cbc")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
42 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
43 add_custom_command (
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
44 OUTPUT ${j}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
45 DEPENDS ${i}
69
f236eba62a76 off-the-shelf cmakefile
anatofuz
parents: 65
diff changeset
46 COMMAND "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_stub.pl" "-o" ${j} ${i}
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
47 )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
48 list(APPEND _Gears_CBC_SOURCES ${j})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
49 elseif (${i} MATCHES "\\.cu")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
50 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
51 add_custom_command (
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
52 OUTPUT ${j}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
53 DEPENDS ${i}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
54 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
55 )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
56 list(APPEND _Gears_CBC_SOURCES ${j})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
57 else()
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
58 set(j ${i})
87
add5e775339c tweak origin-context.h to context.t
anatofuz
parents: 86
diff changeset
59 file(COPY "${CMAKE_SOURCE_DIR}/context.h" DESTINATION "${CMAKE_BINARY_DIR}/usr/${_Gears_TARGET}.dir")
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
60 list(APPEND _Gears_CSOURCES ${j})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
61 endif()
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
62 endforeach(i)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
63
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
64 add_custom_command (
71
6ebe7043702c fix generated source at usr commands
anatofuz
parents: 69
diff changeset
65 OUTPUT ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
66 DEPENDS ${_Gears_CBC_SOURCES}
71
6ebe7043702c fix generated source at usr commands
anatofuz
parents: 69
diff changeset
67 COMMAND "cd" "${_Gears_TARGET}.dir" ";" "perl" "${CMAKE_SOURCE_DIR}/gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${CMAKE_SOURCE_DIR}/usr/${_Gears_CSOURCES}
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
68 )
71
6ebe7043702c fix generated source at usr commands
anatofuz
parents: 69
diff changeset
69 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} ${_Gears_TARGET}.dir/c/${_Gears_TARGET}-context.c )
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
70 target_link_libraries(${_Gears_TARGET} ulib)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
71 endmacro()
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
72
59
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
73 add_library(ulib STATIC ulib.c usys.S printf.c umalloc.c)
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 60
diff changeset
74 #add_library(syslib string.c)
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
75
75
624fe2ec975c reduce user command to achive fs space
kono
parents: 72
diff changeset
76 # set(USR_COMMANDS cat echo grep init kill ln ls mkdir rm sh stressfs usertests wc zombie hello)
94
d876c9a65239 impl mac os target
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
77 set(USR_COMMANDS ls echo grep init kill ln cat mkdir rm sh hello)
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
78
59
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
79 foreach(cmd ${USR_COMMANDS})
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
80 GearsCommand (TARGET _${cmd} SOURCES ${cmd}.c)
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
81 endforeach(cmd)
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
82
63
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
83 set(_USR_COMMANDS)
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
84 foreach (i ${USR_COMMANDS})
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
85 list(APPEND _USR_COMMANDS "_${i}")
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
86 endforeach(i)
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
87
72
4051ad3e0958 fix build fs.img
anatofuz
parents: 71
diff changeset
88
4051ad3e0958 fix build fs.img
anatofuz
parents: 71
diff changeset
89 file(COPY "${CMAKE_SOURCE_DIR}/usr/UNIX" DESTINATION "${CMAKE_BINARY_DIR}/usr")
4051ad3e0958 fix build fs.img
anatofuz
parents: 71
diff changeset
90
63
ab729eb8356b fix build usr command and fs.img
anatofuz
parents: 62
diff changeset
91 add_custom_target(fs.img ALL
72
4051ad3e0958 fix build fs.img
anatofuz
parents: 71
diff changeset
92 COMMAND ${CMAKE_BINARY_DIR}/tools/mkfs fs.img ${_USR_COMMANDS} UNIX \; cp fs.img ${CMAKE_BINARY_DIR}
64
58c79e0c5101 fix depend mkfs
one
parents: 63
diff changeset
93 DEPENDS ${_USR_COMMANDS} mkfs
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
94 )