Herringway / ebsrc

Source code recreation for the game Earthbound
133 stars 8 forks source link

Add clean and distclean targets #29

Closed PhoenixBound closed 6 months ago

PhoenixBound commented 6 months ago

I was trying to rebuild ebsrc after not touching it for about 3 years, and I ran into #21, even though it was supposedly fixed. The old .dep file for bank26.asm was being recreated without going through the rule added in 87f514cb4b77fa3193bcb122ea51f5de5cfdd9cf for some reason. I thought that was a decent motivation to add targets to the Makefile to delete certain intermediate build files and start fresh.

While adding that, I realized that it was still trying to build bank26.asm for some reason, even though I was only running make clean. Eventually, after I poked around and got help from @charasyn, he identified the root cause. The condition for includeing the US .dep files wasn't right; it was assuming that one of the three .dep options had to be taken. So this fixes that to only include the US .deps when building with make/make all/make earthbound.

Since the .dep files were annoying, I also added a distclean target that removes them.

Herringway commented 6 months ago

What's the benefit? git clean already does the job pretty well, but without the maintenance cost.

PhoenixBound commented 6 months ago

After reading over the manpage for git clean...

Having a separate make target lets you make a common useful preset setting for what/how much is being deleted. git clean -dX in the repo root looks like it'll delete the ROM and .o files, the SPC binary, the extracted ROM data in the bin folder, the donor ROMs used by ebbinex for make extract, and the created .dep files and everything else mentioned in the .gitignore. The bin folder and donor ROMs in particular are things I wouldn't want to delete normally, so the full cleaning command I'd use would be some variant of git clean -dX -e bin -e donor*.sfc. I could remember that or rely on terminal history to enter it every time, but make clean is a bit easier to type and remember.

The main thing I was annoyed about was unrelated targets like make extract relying on valid .dep files being built. I don't really have strong feelings about adding these clean targets.

Herringway commented 6 months ago

It is definitely worth addressing the make extract problem, if you can separate that fix from this. As I'm sure you've noticed, the makefile is obnoxiously fragile, and because of that, I'd like to keep things minimal.

In the longterm, I really want to replace make with something saner, but I'm not sure what that would be right now...

PhoenixBound commented 6 months ago

Sure, I'll create a separate PR that just has the make extract fix. It should just be the part on lines 30-31 in the diff.