58
|
1 cmake_minimum_required(VERSION 3.8)
|
59
|
2 set(CMAKE_C_COMPILER "/usr/bin/cc")
|
58
|
3 project(usr C ASM)
|
|
4
|
|
5
|
|
6 set(CMAKE_C_FLAGS_DEBUG "-O0")
|
|
7 add_definitions(${PMAKE_ARGS})
|
|
8 set(CMAKE_C_COMPILER "${CBC_COM}")
|
|
9
|
|
10 include_directories("..")
|
62
|
11 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib")
|
|
12 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LIB} -nostdlib")
|
58
|
13
|
|
14 macro( GearsCommand )
|
|
15 set( _OPTIONS_ARGS )
|
|
16 set( _ONE_VALUE_ARGS TARGET )
|
|
17 set( _MULTI_VALUE_ARGS SOURCES )
|
|
18 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
|
|
19
|
|
20 set (_Gears_CBC_SOURCES)
|
|
21 set (_Gears_CSOURCES)
|
|
22 foreach(i ${_Gears_SOURCES})
|
|
23 if (${i} MATCHES "\\.cbc")
|
|
24 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
|
|
25 add_custom_command (
|
|
26 OUTPUT ${j}
|
|
27 DEPENDS ${i}
|
62
|
28 COMMAND "perl" "../gearsTools/generate_stub.pl" "-o" ${j} ${i}
|
58
|
29 )
|
|
30 list(APPEND _Gears_CBC_SOURCES ${j})
|
|
31 elseif (${i} MATCHES "\\.cu")
|
|
32 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
|
|
33 add_custom_command (
|
|
34 OUTPUT ${j}
|
|
35 DEPENDS ${i}
|
|
36 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
|
|
37 )
|
|
38 list(APPEND _Gears_CBC_SOURCES ${j})
|
|
39 else()
|
|
40 set(j ${i})
|
|
41 list(APPEND _Gears_CSOURCES ${j})
|
|
42 endif()
|
|
43 endforeach(i)
|
|
44
|
|
45 add_custom_command (
|
|
46 OUTPUT c/${_Gears_TARGET}-context.c
|
|
47 DEPENDS ${_Gears_CBC_SOURCES}
|
62
|
48 COMMAND "perl" "../gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES}
|
58
|
49 )
|
|
50 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c )
|
|
51 target_link_libraries(${_Gears_TARGET} ulib)
|
|
52 endmacro()
|
|
53
|
59
|
54 add_library(ulib STATIC ulib.c usys.S printf.c umalloc.c)
|
61
|
55 #add_library(syslib string.c)
|
58
|
56
|
62
|
57 set(USR_COMMANDS cat echo grep init kill ln ls mkdir rm sh stressfs usertests wc zombie hello)
|
58
|
58
|
59
|
59 foreach(cmd ${USR_COMMANDS})
|
|
60 GearsCommand (TARGET _${cmd} SOURCES ${cmd}.c)
|
|
61 endforeach(cmd)
|
58
|
62
|
62
|
63 add_custom_target(fs.img
|
|
64 COMMAND ../tools/mkfs fs.img ${USR_COMMANDS} UNIX
|
58
|
65 DEPENDS ${USR_COMMANDS}
|
|
66 )
|