diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2018-01-15 14:36:22 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2018-01-15 14:38:17 -0700 |
commit | 178921510fb527ef294b29b690ec2ac1ac696d8e (patch) | |
tree | 1fff6fbe3e2a6823a47a33a148d78f27a20f7ac6 | |
parent | 8519eb78ecf71da0d121d77265b9b70bc5f70561 (diff) | |
download | stm32l4-178921510fb527ef294b29b690ec2ac1ac696d8e.tar.gz stm32l4-178921510fb527ef294b29b690ec2ac1ac696d8e.tar.bz2 stm32l4-178921510fb527ef294b29b690ec2ac1ac696d8e.zip |
update the genmake system to put build files in their own directories
-rw-r--r-- | system-clock/Makefile.preamble | 10 | ||||
-rwxr-xr-x | system-clock/genmake.pl | 13 |
2 files changed, 14 insertions, 9 deletions
diff --git a/system-clock/Makefile.preamble b/system-clock/Makefile.preamble index 2a66399..b53a130 100644 --- a/system-clock/Makefile.preamble +++ b/system-clock/Makefile.preamble @@ -6,16 +6,16 @@ CFLAGS?=$(OPT) -mcpu=cortex-m4 -mthumb -g -lgcc -static -nostartfiles LD_FLAGS?=-T linker_script.ld -nostdlib --cref -Map main.map -static -all: main.elf +all: _$(PREFIX)_obs/main.elf -main.bin: main.elf - $(PREFIX)objcopy -O binary main.elf main.bin +_$(PREFIX)_obs/main.bin: main.elf + $(PREFIX)objcopy -O binary _$(PREFIX)_obs/main.elf _$(PREFIX)_obs/main.bin flash: main.bin - st-flash write main.bin 0x8000000 + st-flash write _$(PREFIX)_obs/main.bin 0x8000000 clean: - rm -f *.o *.elf *.bin + rm -rf _*_obs genmake: ./genmake.pl > Makefile diff --git a/system-clock/genmake.pl b/system-clock/genmake.pl index 26e91a8..80026b1 100755 --- a/system-clock/genmake.pl +++ b/system-clock/genmake.pl @@ -33,10 +33,14 @@ my $idempotency_cmd="ls *.c *.h| sha1sum | awk '{print \$ 1}'"; my $idempotency_cmd_make="ls *.c *.h | sha1sum | awk '{print \$\$1}'"; print "IDEMPOTENCY_HASH=" . `$idempotency_cmd` . "\n"; +my $arch_obs_dir = "_\$(PREFIX)_obs"; +print "$arch_obs_dir:\n\t"; +print "mkdir $arch_obs_dir\n"; + foreach $file (@files) { (my $file_no_ext = $file) =~ s/\.c$//g; - my $obj_file = "${file_no_ext}.o"; + my $obj_file = "$arch_obs_dir/${file_no_ext}.o"; my $c_file = "${file_no_ext}.c"; my $s_file = "${file_no_ext}.s"; @@ -46,7 +50,7 @@ foreach $file (@files) { my $deps_as_join = join(" ", @deps); # Emit the rule to make the object file. - print "$obj_file: $deps_as_join\n\t"; + print "$obj_file: $arch_obs_dir $deps_as_join\n\t"; print '$(CC) -c ' . $c_file . ' -o ' . $obj_file . ' $(CFLAGS)' . "\n\n"; # Emit the rule to make the assembly file. @@ -56,7 +60,8 @@ foreach $file (@files) { my $obj_files_deps = join(' ', @obj_files); print "FORCE:\n\t\n\n"; -print "main.elf: FORCE $obj_files_deps linker_script.ld\n\t"; +print "$arch_obs_dir/main.elf: FORCE $obj_files_deps linker_script.ld\n\t"; print "([ \"\$\$($idempotency_cmd_make)\" != \"\$(IDEMPOTENCY_HASH)\" ] " . "&& ./genmake.pl > Makefile && make main.elf ) " - . "|| " . '$(LD) -o main.elf $(LD_FLAGS) ' . "$obj_files_deps\n\n"; + . "|| " + . "\$(LD) -o $arch_obs_dir/main.elf \$(LD_FLAGS) $obj_files_deps\n\n"; |