Mercurial > hg > Members > anatofuz > CbC_xv6
comparison src/gearsTools/pmake.pl @ 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 | dd1d9ea1b7b5 |
children |
comparison
equal
deleted
inserted
replaced
93:7d0ec88cdd22 | 94:d876c9a65239 |
---|---|
1 #!/usr/bin/env perl | 1 #!/usr/bin/env perl |
2 use strict; | 2 use strict; |
3 use warnings; | 3 use warnings; |
4 use FindBin; | 4 use FindBin; |
5 use Cwd 'getcwd'; | 5 use Cwd 'getcwd'; |
6 use File::Path 'rmtree'; | |
6 | 7 |
7 my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake,$kernel_cflags,$kernel_ld_flags,$kernel_ld_command, $initcode_cflags, $initcode_ld_command); | 8 my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake,$kernel_cflags,$kernel_ld_flags,$kernel_ld_command, $initcode_cflags, $initcode_ld_command); |
8 | 9 |
10 my $curdir = getcwd; | |
11 | |
12 if (@ARGV) { | |
13 if ($ARGV[0] =~ /--delete/) { | |
14 my @current_dir_file = glob "*"; | |
15 map { print "$_\n";} @current_dir_file; | |
16 print "delete all files? > [y/n]\n"; | |
17 my $ans = <STDIN>; | |
18 if ($ans =~ /y/) { | |
19 print "delete ...\n"; | |
20 map { rmtree $_ } @current_dir_file; | |
21 } | |
22 } | |
23 } | |
24 | |
9 $cmake = 'cmake'; | 25 $cmake = 'cmake'; |
26 my @cmake_arg = (); | |
27 my $xv6_src_dir = $FindBin::Bin; | |
28 $xv6_src_dir =~ s|(.*)/gearsTools(.*)|$1|; | |
29 | |
10 | 30 |
11 if ($^O =~ /darwin/){ | 31 if ($^O =~ /darwin/){ |
12 $cc = $ENV{CBC_LANG_COMPILER}; | 32 $cc = "$ENV{CBC_LANG_COMPILER}-7.0"; |
13 $cflags = qq|-Wall -g -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 | 33 $asm = "$ENV{CBC_LANG_COMPILER}-7.0"; |
14 -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare | 34 $cflags = qq|-Wall -g --target=armv6-linux-gnueabihf -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -DCBCXV6=1 -g -O0 -nodefaultlibs |
15 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include | 35 -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare |
16 -Wno-nullability-completeness -Wno-expansion-to-defined"|; | 36 -Wno-nullability-completeness -Wno-expansion-to-defined |; |
17 $ldflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- | 37 $cflags .= ' -B' . $ENV{HOME} .'/workspace/cr/arm_library/usr/lib/gcc/arm-linux-gnueabihf/6.3.0'; |
18 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0|; | 38 $cflags .= ' --gcc-toolchain=arm-linux-gnueabihf-raspbian'; |
39 #$ld = '/Users/anatofuz/workspace/compiler/llvm/llvm-project/build/bin/lld'; | |
40 #$ld = '/Users/anatofuz/workspace/compiler/llvm/llvm-project/build/bin/ld.lld'; | |
41 $ld = '/usr/local/linaro/arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-ld'; | |
42 | |
43 #$libgcc = '/Users/anatofuz/workspace/cr/arm_library/usr/lib/gcc/arm-linux-gnueabihf/6.3.0/libgcc.a'; | |
44 $libgcc = '/usr/local/lib/gcc/arm-none-eabi/7.3.1/libgcc.a'; | |
45 #chomp($libgcc = `$cc --print-libgcc-file-name`); | |
46 $ldflags = " -L. -T kernel-cmake.ld"; | |
47 $kernel_cflags = '--target=armv6-linux-gnueabihf -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -g -O0 -iquote ../ -c'; | |
48 # -DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode usr/fs.img\" | |
49 $kernel_ld_flags = ' -L. -N -e main -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L ../ ' . $libgcc; | |
50 #$kernel_ld_flags = ' -L. -N -e main -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES>' ; | |
51 $kernel_ld_command = "$ld $kernel_ld_flags"; | |
52 $initcode_cflags = '--target=armv6-linux-gnueabihf -nostdinc -c'; | |
53 $initcode_ld_command = "$ld -L. -N -e start -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"; | |
54 | |
55 my $arm_library = '/Users/anatofuz/workspace/cr/arm_library'; | |
56 | |
57 push(@cmake_arg, | |
58 "-DCBC_XV6_SYSROOT=\"$arm_library\"", | |
59 # "-DCMAKE_OSX_SYSROOT=\"$arm_library\"", | |
60 #"-DCMAKE_AR=\"/Users/anatofuz/workspace/compiler/llvm/llvm-project/build/bin/llvm-ar\"", | |
61 #"-DCMAKE_RANLIB=\"/Users/anatofuz/workspace/compiler/llvm/llvm-project/build/bin/llvm-ar\"", | |
62 "-DCMAKE_AR=\"/usr/local/linaro/arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-ar\"", | |
63 "-DCMAKE_RANLIB=\"/usr/local/linaro/arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-ranlib\"", | |
64 # "-DCMAKE_OSX_XV6_INCLUDE_DIR=\"$arm_library/usr/include\"", | |
65 ); | |
66 | |
19 } else { | 67 } else { |
20 $cc = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc'; | 68 $cc = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc'; |
21 $asm = $cc; | 69 $asm = $cc; |
22 $cflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- | 70 $cflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- |
23 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -g -O0|; | 71 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -g -O0|; |
29 # -DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode usr/fs.img\" | 77 # -DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode usr/fs.img\" |
30 $kernel_ld_flags = ' -L. -N -e main -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L ../ /mnt/dalmore-home/one/src/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/libgcc.a'; | 78 $kernel_ld_flags = ' -L. -N -e main -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L ../ /mnt/dalmore-home/one/src/gcc-arm-none-eabi-6-2017-q2-update/bin/../lib/gcc/arm-none-eabi/6.3.1/libgcc.a'; |
31 $kernel_ld_command = "$ld $kernel_ld_flags"; | 79 $kernel_ld_command = "$ld $kernel_ld_flags"; |
32 $initcode_cflags = '-march=armv6 -nostdinc -c'; | 80 $initcode_cflags = '-march=armv6 -nostdinc -c'; |
33 $initcode_ld_command = "$ld -L. -N -e start -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"; | 81 $initcode_ld_command = "$ld -L. -N -e start -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"; |
82 | |
83 $cflags =~ s/\n//g; | |
34 } | 84 } |
35 | 85 |
36 $cflags =~ s/\n//g; | 86 push(@cmake_arg, |
87 "-DCBC_COM=$cc", | |
88 "-DPMAKE_ARGS=\"$cflags\"", | |
89 "-DCBC_ASM_COMPILER=$cc", | |
90 "-DX_CMAKE_LINKER=$ld", | |
91 "-DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode fs.img\"", | |
92 "-DKERNEL_LINK_EXECUTABLE=\"$kernel_ld_command\"", | |
93 "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE", | |
94 "-DINITOCDE_CFLAGS=\"$initcode_cflags\"", | |
95 "-DINITOCDE_LINK_EXECUTABLE=\"$initcode_ld_command\"", | |
96 "-S $xv6_src_dir", | |
97 $curdir); | |
98 | |
99 unshift(@cmake_arg, $cmake); | |
100 | |
37 create_link_script(); | 101 create_link_script(); |
38 my $curdir = getcwd; | 102 print_exec_system(@cmake_arg); |
39 my $xv6_src_dir = $FindBin::Bin; | |
40 $xv6_src_dir =~ s|(.*)/gearsTools(.*)|$1|; | |
41 | |
42 print_exec_system($cmake, | |
43 "-DCBC_COM=$cc", | |
44 "-DPMAKE_ARGS=\"$cflags\"", | |
45 "-DCMAKE_ASM_COMPILER=$cc", | |
46 "-DX_CMAKE_LINKER=$ld", | |
47 "-DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode fs.img\"", | |
48 "-DKERNEL_LINK_EXECUTABLE=\"$kernel_ld_command\"", | |
49 "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE", | |
50 "-DINITOCDE_CFLAGS=\"$initcode_cflags\"", | |
51 "-DINITOCDE_LINK_EXECUTABLE=\"$initcode_ld_command\"", | |
52 "-S $xv6_src_dir", | |
53 $curdir); | |
54 | 103 |
55 system("make"); | 104 system("make"); |
56 #system("sh","link.sh"); | 105 #system("sh","link.sh"); |
57 | 106 |
58 sub create_link_script { | 107 sub create_link_script { |
125 \ | 174 \ |
126 -b \ | 175 -b \ |
127 binary \ | 176 binary \ |
128 initcode \ | 177 initcode \ |
129 fs.img | 178 fs.img |
130 | |
131 __END__ | |
132 | |
133 =encoding utf-8 | |
134 | |
135 =head1 NAME | |
136 | |
137 pmake.pl - pmake is a wrapper at cmake in xv6. | |
138 | |
139 =head1 SYNOPSIS | |
140 | |
141 pmake.pl <build directory> <cbcxv6 src direcory> | |
142 | |
143 =cut |