42
|
1 cmake_minimum_required(VERSION 3.8)
|
43
|
2 project(xv6cbc C ASM)
|
42
|
3
|
|
4 set(USE_CUDA,0)
|
|
5 # -DUSE_CUDA
|
|
6 # add_definitions("-Wall -g -O")
|
|
7
|
47
|
8 if (APPLE)
|
|
9 set(CMAKE_C_COMPILER $ENV{CBC_LANG_COMPILER})
|
|
10 add_definitions("-Wall -g -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0
|
|
11 -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare
|
|
12 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include
|
|
13 -Wno-nullability-completeness -Wno-expansion-to-defined")
|
|
14 else (APPLE)
|
|
15 set(CMAKE_C_COMPILER /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc)
|
|
16 add_definitions("-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-
|
|
17 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0")
|
|
18 endif (APPLE)
|
42
|
19
|
|
20 # -DCMAKE_BUILD_TYPE=Debug
|
|
21 set(CMAKE_C_FLAGS_DEBUG "-O0")
|
45
|
22 set(CMAKE_EXE_LINKER_FLAGS "-L. -arch armv7 -T kernel.ld -o kernel.elf ")
|
42
|
23
|
|
24 if (${USE_CUDA})
|
|
25 include_directories("/usr/local/cuda/include")
|
|
26 set(NVCCFLAG "-std=c++11" "-g" "-O0" )
|
|
27 if (UNIX AND NOT APPLE) # LINUX
|
|
28 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart")
|
|
29 elseif (APPLE)
|
|
30 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")
|
|
31 endif()
|
|
32 find_package(CUDA REQUIRED)
|
|
33 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
|
|
34 endif()
|
|
35
|
|
36 include_directories(".")
|
|
37
|
|
38 macro( GearsCommand )
|
|
39 set( _OPTIONS_ARGS )
|
|
40 set( _ONE_VALUE_ARGS TARGET )
|
|
41 set( _MULTI_VALUE_ARGS SOURCES )
|
|
42 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
|
|
43
|
43
|
44 set (_Gears_CBC_SOURCES)
|
42
|
45 set (_Gears_CSOURCES)
|
|
46 foreach(i ${_Gears_SOURCES})
|
|
47 if (${i} MATCHES "\\.cbc")
|
|
48 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
|
|
49 add_custom_command (
|
|
50 OUTPUT ${j}
|
|
51 DEPENDS ${i}
|
|
52 COMMAND "perl" "gearsTools/generate_stub.pl" "-o" ${j} ${i}
|
|
53 )
|
43
|
54 list(APPEND _Gears_CBC_SOURCES ${j})
|
42
|
55 elseif (${i} MATCHES "\\.cu")
|
|
56 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
|
|
57 add_custom_command (
|
|
58 OUTPUT ${j}
|
|
59 DEPENDS ${i}
|
|
60 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
|
|
61 )
|
43
|
62 list(APPEND _Gears_CBC_SOURCES ${j})
|
42
|
63 else()
|
|
64 set(j ${i})
|
43
|
65 list(APPEND _Gears_CSOURCES ${j})
|
42
|
66 endif()
|
|
67 endforeach(i)
|
|
68
|
|
69 add_custom_command (
|
|
70 OUTPUT c/${_Gears_TARGET}-context.c
|
43
|
71 DEPENDS ${_Gears_CBC_SOURCES}
|
|
72 COMMAND "perl" "gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CBC_SOURCES}
|
42
|
73 )
|
43
|
74 add_executable(${_Gears_TARGET} ${_Gears_CBC_SOURCES} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c)
|
42
|
75 target_link_libraries(${_Gears_TARGET} m pthread)
|
|
76 endmacro()
|
|
77
|
|
78
|
|
79 GearsCommand(
|
|
80 TARGET
|
|
81 kernel
|
|
82 SOURCES
|
47
|
83 lib/string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.c fs.c log.c main.c memide.c pipe.c proc.c spinlock.c
|
42
|
84 start.c swtch.S syscall.c sysfile.c sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c
|
|
85 entry-osx.S
|
|
86 )
|
|
87
|
|
88
|
|
89
|