im-tomu / toboot

Bootloader for the EFM32HG Tomu Board
https://tomu.im/
GNU General Public License v3.0
72 stars 28 forks source link

modify the Makefiles so that 'make clean' cleans everything that was built #39

Closed baldurmen closed 5 years ago

baldurmen commented 5 years ago

In either the toboot or the booster directories, make clean leaves files behind. This patch modifies the Makefiles so that make clean cleans everything that was built with make.

Before the patch:

user@computer:~/git$ cp -R tomu-bootloader/ foo
user@computer:~/git$ cd foo/toboot/
user@computer:~/git/foo/toboot$ make
  CC       toboot.c toboot.o
  CC       usb_dev.c    usb_dev.o
  CC       usb_desc.c   usb_desc.o
  CC       vectors.c    vectors.o
  CC       updater.c    updater.o
  CC       reset_handler.c  reset_handler.o
  CC       main.c   main.o
  CC       xxhash.c xxhash.o
  CC       dfu.c    dfu.o
  LD       toboot.elf
  OBJCOPY  toboot.bin
  IHEX     toboot.ihex
  COPY  toboot.bin toboot.dfu
dfu-suffix (dfu-util) 0.9

Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Suffix successfully added to file
user@computer:~/git/foo/toboot$ make clean
  RM      .obj/toboot.d .obj/usb_desc.d .obj/vectors.d .obj/updater.d .obj/usb_dev.d .obj/reset_handler.d .obj/main.d .obj/xxhash.d .obj/dfu.d
  RM      .obj/toboot.d .obj/usb_desc.d .obj/vectors.d .obj/updater.d .obj/usb_dev.d .obj/reset_handler.d .obj/main.d .obj/xxhash.d .obj/dfu.d
  RM      toboot.elf toboot.bin toboot.symbol toboot.ihex
user@computer:~/git/foo/toboot$ cd ../booster/
user@computer:~/git/foo/booster$ make
  CC       main.c   main.o
  LD       booster.elf
  OBJCOPY  booster.bin
  IHEX     booster.ihex
user@computer:~/git/foo/booster$ make clean
user@computer:~/git/foo/booster$ cd ../../
user@computer:~/git$ diff tomu-bootloader/toboot/ foo/toboot/
Only in foo/toboot/: .obj
Only in foo/toboot/: toboot.dfu
user@computer:~/git$ diff tomu-bootloader/booster foo/booster
Only in foo/booster: booster.ihex
Only in foo/booster: .obj

After the patch:

user@computer:~/git$ cp -R tomu-bootloader/ foo
user@computer:~/git$ cd foo/toboot/
user@computer:~/git/foo/toboot$ make
  CC       toboot.c toboot.o
  CC       usb_dev.c    usb_dev.o
  CC       usb_desc.c   usb_desc.o
  CC       vectors.c    vectors.o
  CC       updater.c    updater.o
  CC       reset_handler.c  reset_handler.o
  CC       main.c   main.o
  CC       xxhash.c xxhash.o
  CC       dfu.c    dfu.o
  LD       toboot.elf
  OBJCOPY  toboot.bin
  IHEX     toboot.ihex
  COPY  toboot.bin toboot.dfu
dfu-suffix (dfu-util) 0.9

Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Suffix successfully added to file
user@computer:~/git/foo/toboot$ make clean
  RM      .obj/toboot.d .obj/usb_desc.d .obj/vectors.d .obj/updater.d .obj/usb_dev.d .obj/reset_handler.d .obj/main.d .obj/xxhash.d .obj/dfu.d
  RM      .obj/vectors.o .obj/updater.o .obj/usb_dev.o .obj/reset_handler.o .obj/main.o .obj/xxhash.o .obj/dfu.o .obj/toboot.o .obj/usb_desc.o .obj
  RM      toboot.elf toboot.bin toboot.dfu toboot.ihex
user@computer:~/git/foo/toboot$ cd ../booster/
user@computer:~/git/foo/booster$ make 
  CC       main.c   main.o
  LD       booster.elf
  OBJCOPY  booster.bin
  IHEX     booster.ihex
user@computer:~/git/foo/booster$ make clean
user@computer:~/git/foo/booster$ cd ../../
user@computer:~/git$ diff tomu-bootloader/toboot/ foo/toboot/
user@computer:~/git$ diff tomu-bootloader/booster/ foo/booster/

I'm not sure what $(PACKAGE).symbol was and since that file didn't seem to exist, I removed it from clean in both files.

baldurmen commented 5 years ago

For a little context, I'm working on packaging the tomu bootloader in Debian and if that patch was merged, it would simplify cleaning after the build process :D

xobs commented 5 years ago

Unfortunately, adding the entire object directory causes issues when building on Windows:

❯ make clean
"  RM      "
The syntax of the command is incorrect.
make: [Makefile:100: clean] Error 1 (ignored)
"  RM       .obj"
C:\Users\sean\Code\tomu\baldurmen-bl\toboot\.obj\*, Are you sure (Y/N)?

Modifying the Windows command to del /q seems to solve the problem on that platform. I'll add that, and merge the changes.

Thanks for the PR!