changeset 63:ab729eb8356b

fix build usr command and fs.img
author anatofuz
date Fri, 26 Jul 2019 17:20:50 +0900
parents a28580a75faa
children 58c79e0c5101
files src/gearsTools/pmake.pl src/usr/CMakeLists.txt
diffstat 2 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gearsTools/pmake.pl	Thu Jul 25 20:04:17 2019 +0900
+++ b/src/gearsTools/pmake.pl	Fri Jul 26 17:20:50 2019 +0900
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake);
+my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake,$kernel_cflags,$kernel_ld_flags,$kernel_ld_command);
 
 $cmake = 'cmake';
 
@@ -24,12 +24,17 @@
     $cflags .= " $libgcc";
     $cmake  .= 3;
     $ldflags = " -L. -T kernel-cmake.ld";
+    $kernel_cflags   = '-march=armv6 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 -iquote ../   -c';
+    # -DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags  -o kernel.elf <OBJECTS> $libgcc   -b binary initcode fs.img\"
+    $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';
+    $kernel_ld_command = "$ld $kernel_ld_flags";
 }
 
 $cflags =~ s/\n//g;
 create_link_script();
-#cmake -DCMAKE_LINKER=/path/to/linker -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
-print_exec_system($cmake, "-DGCC_LIB=$libgcc", "-DCBC_COM=$cc", "-DPMAKE_ARGS=\"$cflags\"","-DCMAKE_ASM_COMPILER=$cc","-DX_CMAKE_LINKER=$ld","-DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags  -o kernel.elf <OBJECTS> $libgcc   -b binary initcode fs.img\"","-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE",@ARGV);
+
+print_exec_system($cmake, "-DGCC_LIB=$libgcc", "-DCBC_COM=$cc", "-DPMAKE_ARGS=\"$cflags\"","-DCMAKE_ASM_COMPILER=$cc","-DX_CMAKE_LINKER=$ld","-DX_CMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags  -o kernel.elf <OBJECTS> $libgcc   -b binary initcode fs.img\"","-DKERNEL_LINK_EXECUTABLE=\"$kernel_ld_command\"","-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE",@ARGV);
+
 system("make");
 #system("sh","link.sh");
 
--- a/src/usr/CMakeLists.txt	Thu Jul 25 20:04:17 2019 +0900
+++ b/src/usr/CMakeLists.txt	Fri Jul 26 17:20:50 2019 +0900
@@ -8,7 +8,8 @@
 set(CMAKE_C_COMPILER "${CBC_COM}")
 
 include_directories("..")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdlib")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ")
+set(CMAKE_C_LINK_EXECUTABLE "${KERNEL_LINK_EXECUTABLE}")
 set(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_LIB} -nostdlib")
 
 macro( GearsCommand )
@@ -60,7 +61,12 @@
     GearsCommand (TARGET _${cmd} SOURCES ${cmd}.c) 
 endforeach(cmd)
 
-add_custom_target(fs.img
-  COMMAND ../tools/mkfs fs.img ${USR_COMMANDS} UNIX
+set(_USR_COMMANDS)
+foreach (i ${USR_COMMANDS})
+  list(APPEND _USR_COMMANDS "_${i}")
+endforeach(i)
+
+add_custom_target(fs.img ALL
+  COMMAND ../tools/mkfs fs.img ${_USR_COMMANDS} UNIX
   DEPENDS ${USR_COMMANDS}
 )