Mercurial > hg > CbC > CbC_xv6
annotate src/gearsTools/pmake.pl @ 90:dd1d9ea1b7b5
tweak pmake.pl
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 17 Oct 2019 10:42:54 +0900 |
parents | df104b2de895 |
children | 0956648d24e5 |
rev | line source |
---|---|
60 | 1 #!/usr/bin/env perl |
2 use strict; | |
3 use warnings; | |
89
df104b2de895
remove commnad line arguments at pmake.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
4 use FindBin; |
df104b2de895
remove commnad line arguments at pmake.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
5 use Cwd 'getcwd'; |
60 | 6 |
66 | 7 my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake,$kernel_cflags,$kernel_ld_flags,$kernel_ld_command, $initcode_cflags, $initcode_ld_command); |
60 | 8 |
9 $cmake = 'cmake'; | |
10 | |
11 if ($^O =~ /darwin/){ | |
12 $cc = $ENV{CBC_LANG_COMPILER}; | |
13 $cflags = qq|-Wall -g -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 | |
14 -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare | |
15 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include | |
16 -Wno-nullability-completeness -Wno-expansion-to-defined"|; | |
17 $ldflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- | |
18 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0|; | |
19 } else { | |
20 $cc = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc'; | |
21 $asm = $cc; | |
22 $cflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- | |
86 | 23 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -g -O0|; |
60 | 24 $ld = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld'; |
25 chomp($libgcc = `$cc --print-libgcc-file-name`); | |
26 $cmake .= 3; | |
61 | 27 $ldflags = " -L. -T kernel-cmake.ld"; |
86 | 28 $kernel_cflags = '-march=armv6 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -g -O0 -iquote ../ -c'; |
64 | 29 # -DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags -o kernel.elf <OBJECTS> $libgcc -b binary initcode usr/fs.img\" |
63 | 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'; |
31 $kernel_ld_command = "$ld $kernel_ld_flags"; | |
86 | 32 $initcode_cflags = '-march=armv6 -nostdinc -c'; |
66 | 33 $initcode_ld_command = "$ld -L. -N -e start -Ttext 0 <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"; |
60 | 34 } |
35 | |
36 $cflags =~ s/\n//g; | |
37 create_link_script(); | |
89
df104b2de895
remove commnad line arguments at pmake.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
38 my $curdir = getcwd; |
df104b2de895
remove commnad line arguments at pmake.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
39 my $xv6_src_dir = $FindBin::Bin; |
90 | 40 $xv6_src_dir =~ s|(.*)/gearsTools(.*)|$1|; |
63 | 41 |
66 | 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\"", | |
89
df104b2de895
remove commnad line arguments at pmake.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
52 "-S $xv6_src_dir", |
df104b2de895
remove commnad line arguments at pmake.pl
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
86
diff
changeset
|
53 $curdir); |
63 | 54 |
60 | 55 system("make"); |
61 | 56 #system("sh","link.sh"); |
60 | 57 |
58 sub create_link_script { | |
59 my @link_script; | |
60 while (my $line = <DATA>){ | |
61 $line =~ s/LD/$ld/; | |
62 $line =~ s/LIBGCC/$libgcc/; | |
63 push @link_script,$line; | |
64 } | |
65 if ($^O =~ /darwin/){ | |
66 for (@link_script){ | |
67 s/CMakeFiles/build/; | |
68 s|kernel\.dir/||; | |
69 } | |
70 } | |
71 open my $fh, '>', 'link.sh'; | |
72 print $fh "@link_script"; | |
73 } | |
74 | |
75 sub print_exec_system { | |
76 my @query = @_; | |
77 print(join(' ',@query), "\n"); | |
90 | 78 system(join(' ',@query)); |
60 | 79 } |
80 | |
80 | 81 |
82 | |
60 | 83 __DATA__ |
84 cp initcode ./CMakeFiles/kernel.dir/initcode | |
85 cp fs.img ./CMakeFiles/kernel.dir/fs.img | |
86 | |
87 LD \ | |
88 -L. \ | |
89 -T \ | |
90 kernel-cmake.ld \ | |
91 -o \ | |
92 kernel.elf \ | |
93 \ | |
94 CMakeFiles/kernel.dir/lib/string.c.o \ | |
95 CMakeFiles/kernel.dir/arm.c.o \ | |
96 CMakeFiles/kernel.dir/asm.S.o \ | |
97 CMakeFiles/kernel.dir/bio.c.o \ | |
98 CMakeFiles/kernel.dir/buddy.c.o \ | |
99 CMakeFiles/kernel.dir/c/console.c.o \ | |
100 CMakeFiles/kernel.dir/exec.c.o \ | |
101 CMakeFiles/kernel.dir/c/file.c.o \ | |
102 CMakeFiles/kernel.dir/fs.c.o \ | |
103 CMakeFiles/kernel.dir/log.c.o \ | |
104 CMakeFiles/kernel.dir/main.c.o \ | |
105 CMakeFiles/kernel.dir/memide.c.o \ | |
106 CMakeFiles/kernel.dir/c/pipe.c.o \ | |
107 CMakeFiles/kernel.dir/c/proc.c.o \ | |
108 CMakeFiles/kernel.dir/c/spinlock.c.o \ | |
109 CMakeFiles/kernel.dir/start.c.o \ | |
110 CMakeFiles/kernel.dir/swtch.S.o \ | |
111 CMakeFiles/kernel.dir/c/syscall.c.o \ | |
112 CMakeFiles/kernel.dir/c/sysfile.c.o \ | |
113 CMakeFiles/kernel.dir/sysproc.c.o \ | |
114 CMakeFiles/kernel.dir/trap_asm.S.o \ | |
115 CMakeFiles/kernel.dir/trap.c.o \ | |
116 CMakeFiles/kernel.dir/vm.c.o \ | |
117 CMakeFiles/kernel.dir/device/picirq.c.o \ | |
118 CMakeFiles/kernel.dir/device/timer.c.o \ | |
119 CMakeFiles/kernel.dir/device/uart.c.o \ | |
120 CMakeFiles/kernel.dir/entry.S.o \ | |
121 CMakeFiles/kernel.dir/c/kernel-context.c.o \ | |
122 \ | |
123 \ | |
124 LIBGCC \ | |
125 \ | |
126 -b \ | |
127 binary \ | |
128 initcode \ | |
129 fs.img | |
80 | 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 |