annotate src/usr/CMakeLists.txt @ 62:a28580a75faa

fix build fs.img
author anatofuz
date Thu, 25 Jul 2019 20:04:17 +0900
parents b3a3224e1823
children ab729eb8356b
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
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
5
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
6 set(CMAKE_C_FLAGS_DEBUG "-O0")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
7 add_definitions(${PMAKE_ARGS})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
8 set(CMAKE_C_COMPILER "${CBC_COM}")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
9
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
10 include_directories("..")
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
11 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib")
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
12 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LIB} -nostdlib")
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
13
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
14 macro( GearsCommand )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
15 set( _OPTIONS_ARGS )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
16 set( _ONE_VALUE_ARGS TARGET )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
17 set( _MULTI_VALUE_ARGS SOURCES )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
18 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
19
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
20 set (_Gears_CBC_SOURCES)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
21 set (_Gears_CSOURCES)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
22 foreach(i ${_Gears_SOURCES})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
23 if (${i} MATCHES "\\.cbc")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
24 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
25 add_custom_command (
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
26 OUTPUT ${j}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
27 DEPENDS ${i}
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
28 COMMAND "perl" "../gearsTools/generate_stub.pl" "-o" ${j} ${i}
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
29 )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
30 list(APPEND _Gears_CBC_SOURCES ${j})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
31 elseif (${i} MATCHES "\\.cu")
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
32 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
33 add_custom_command (
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
34 OUTPUT ${j}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
35 DEPENDS ${i}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
36 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
37 )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
38 list(APPEND _Gears_CBC_SOURCES ${j})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
39 else()
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
40 set(j ${i})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
41 list(APPEND _Gears_CSOURCES ${j})
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
42 endif()
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
43 endforeach(i)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
44
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
45 add_custom_command (
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
46 OUTPUT c/${_Gears_TARGET}-context.c
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
47 DEPENDS ${_Gears_CBC_SOURCES}
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
48 COMMAND "perl" "../gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES}
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
49 )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
50 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c )
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
51 target_link_libraries(${_Gears_TARGET} ulib)
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
52 endmacro()
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
53
59
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
54 add_library(ulib STATIC ulib.c usys.S printf.c umalloc.c)
61
b3a3224e1823 fix link arguments...
anatofuz
parents: 60
diff changeset
55 #add_library(syslib string.c)
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
56
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
57 set(USR_COMMANDS cat echo grep init kill ln ls mkdir rm sh stressfs usertests wc zombie hello)
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
58
59
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
59 foreach(cmd ${USR_COMMANDS})
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
60 GearsCommand (TARGET _${cmd} SOURCES ${cmd}.c)
8f435de13b91 fix cmakefiles
tobaru
parents: 58
diff changeset
61 endforeach(cmd)
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
62
62
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
63 add_custom_target(fs.img
a28580a75faa fix build fs.img
anatofuz
parents: 61
diff changeset
64 COMMAND ../tools/mkfs fs.img ${USR_COMMANDS} UNIX
58
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
65 DEPENDS ${USR_COMMANDS}
f1b965f53d3b add tools userlists
tobaru
parents:
diff changeset
66 )