diff --git a/Rakefile b/Rakefile index 86006cc..8ac71a3 100644 --- a/Rakefile +++ b/Rakefile @@ -29,7 +29,8 @@ SRC_DIRS = [".", "lib"] # cross-compiler environment PREFIX = ENV["PREFIX"] || "arm-none-eabi" -CC = "clang -target #{PREFIX}" # use clang instead of gcc +CC = PREFIX+"-gcc" +#CC = "clang -target #{PREFIX}" # to use clang instead of gcc LD = PREFIX+"-ld" AR = PREFIX+"-ar" AS = PREFIX+"-as" @@ -53,10 +54,6 @@ cflags << "-fno-common -ffunction-sections -fdata-sections" cflags << "-fshort-enums" # don't use system main definition (the starting point) cflags << "-ffreestanding" -# don't use the standard library (only if you provide an alternative libc library) -cflags << "-nostdlib -nostdinc" -# standard C library (use musl libc) -cflags << "-I /usr/lib/musl/include/" # include own libraries cflags += SRC_DIRS.collect {|srd_dir| "-I #{srd_dir}"} # include libopencm3 library @@ -74,10 +71,11 @@ ldflags << "-static" ldflags << "-nostartfiles" # only keep used sections ldflags << "--gc-sections" -# don't use system libraries (only if you provide an alternative libc library) -ldflags << "-nostdlib -nostdinc -nosys" -# add standard libraries (for libc, libm, libnosys, libgcc) and libopencm3 -library_paths = ["/usr/arm-none-eabi/lib/armv7-m/", "/usr/lib/gcc/arm-none-eabi/*/armv7-m/", LIBOPENCM3_LIB] +# add standard libraries (for libc, libm, libnosys, libgcc) because we don't use arm-none-eabi-gcc to locate them +library_paths = ["/usr/arm-none-eabi/lib/armv7-m/", "/usr/lib/gcc/arm-none-eabi/*/armv7-m/"] +# add libopencm3 +library_paths += [LIBOPENCM3_LIB] +# include libraries in flags ldflags += library_paths.collect {|library_path| "--library-path #{library_path}"} ldflags *= ' ' # used libraries (gcc provides the ARM ABI)