Mercurial > hg > Members > menikon > CbC_xv6
comparison src/gearsTools/pmake.pl @ 60:e5f099108a6e
fix cmake link argument
author | anatofuz |
---|---|
date | Thu, 11 Jul 2019 16:12:16 +0900 |
parents | |
children | b3a3224e1823 |
comparison
equal
deleted
inserted
replaced
59:8f435de13b91 | 60:e5f099108a6e |
---|---|
1 #!/usr/bin/env perl | |
2 use strict; | |
3 use warnings; | |
4 | |
5 my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake); | |
6 | |
7 $cmake = 'cmake'; | |
8 | |
9 if ($^O =~ /darwin/){ | |
10 $cc = $ENV{CBC_LANG_COMPILER}; | |
11 $cflags = qq|-Wall -g -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 | |
12 -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare | |
13 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include | |
14 -Wno-nullability-completeness -Wno-expansion-to-defined"|; | |
15 $ldflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- | |
16 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0|; | |
17 } else { | |
18 $cc = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc'; | |
19 $asm = $cc; | |
20 $cflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi- | |
21 -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0|; | |
22 $ld = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld'; | |
23 chomp($libgcc = `$cc --print-libgcc-file-name`); | |
24 $cflags .= " $libgcc"; | |
25 $cmake .= 3; | |
26 $ldflags = " -L. -T kernel-cmake.ld $libgcc -b binary initcode fs.img"; | |
27 } | |
28 | |
29 $cflags =~ s/\n//g; | |
30 create_link_script(); | |
31 #cmake -DCMAKE_LINKER=/path/to/linker -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" | |
32 print_exec_system($cmake, "-DCBC_COM=$cc", "-DPMAKE_ARGS=\"$cflags\"","-DCMAKE_ASM_COMPILER=$cc","-DCMAKE_LINKER=$ld","-DCMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags <OBJECTS> -o kernel.elf\"","-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE",'.'); | |
33 system("make"); | |
34 system("sh","link.sh"); | |
35 | |
36 sub create_link_script { | |
37 my @link_script; | |
38 while (my $line = <DATA>){ | |
39 $line =~ s/LD/$ld/; | |
40 $line =~ s/LIBGCC/$libgcc/; | |
41 push @link_script,$line; | |
42 } | |
43 if ($^O =~ /darwin/){ | |
44 for (@link_script){ | |
45 s/CMakeFiles/build/; | |
46 s|kernel\.dir/||; | |
47 } | |
48 } | |
49 open my $fh, '>', 'link.sh'; | |
50 print $fh "@link_script"; | |
51 } | |
52 | |
53 sub print_exec_system { | |
54 my @query = @_; | |
55 print(join(' ',@query), "\n"); | |
56 system(join(' ',@query)); | |
57 } | |
58 | |
59 __DATA__ | |
60 cp initcode ./CMakeFiles/kernel.dir/initcode | |
61 cp fs.img ./CMakeFiles/kernel.dir/fs.img | |
62 | |
63 LD \ | |
64 -L. \ | |
65 -T \ | |
66 kernel-cmake.ld \ | |
67 -o \ | |
68 kernel.elf \ | |
69 \ | |
70 CMakeFiles/kernel.dir/lib/string.c.o \ | |
71 CMakeFiles/kernel.dir/arm.c.o \ | |
72 CMakeFiles/kernel.dir/asm.S.o \ | |
73 CMakeFiles/kernel.dir/bio.c.o \ | |
74 CMakeFiles/kernel.dir/buddy.c.o \ | |
75 CMakeFiles/kernel.dir/c/console.c.o \ | |
76 CMakeFiles/kernel.dir/exec.c.o \ | |
77 CMakeFiles/kernel.dir/c/file.c.o \ | |
78 CMakeFiles/kernel.dir/fs.c.o \ | |
79 CMakeFiles/kernel.dir/log.c.o \ | |
80 CMakeFiles/kernel.dir/main.c.o \ | |
81 CMakeFiles/kernel.dir/memide.c.o \ | |
82 CMakeFiles/kernel.dir/c/pipe.c.o \ | |
83 CMakeFiles/kernel.dir/c/proc.c.o \ | |
84 CMakeFiles/kernel.dir/c/spinlock.c.o \ | |
85 CMakeFiles/kernel.dir/start.c.o \ | |
86 CMakeFiles/kernel.dir/swtch.S.o \ | |
87 CMakeFiles/kernel.dir/c/syscall.c.o \ | |
88 CMakeFiles/kernel.dir/c/sysfile.c.o \ | |
89 CMakeFiles/kernel.dir/sysproc.c.o \ | |
90 CMakeFiles/kernel.dir/trap_asm.S.o \ | |
91 CMakeFiles/kernel.dir/trap.c.o \ | |
92 CMakeFiles/kernel.dir/vm.c.o \ | |
93 CMakeFiles/kernel.dir/device/picirq.c.o \ | |
94 CMakeFiles/kernel.dir/device/timer.c.o \ | |
95 CMakeFiles/kernel.dir/device/uart.c.o \ | |
96 CMakeFiles/kernel.dir/entry.S.o \ | |
97 CMakeFiles/kernel.dir/c/kernel-context.c.o \ | |
98 \ | |
99 \ | |
100 LIBGCC \ | |
101 \ | |
102 -b \ | |
103 binary \ | |
104 initcode \ | |
105 fs.img |