What are the good practices of managing small dependencies?
I'm new to C. I have a small SDL2 project. At some point I needed to load and draw image sprites and found nice library stb_image.h. Probably best way here would be to just download the stb_image.h file and commit it to the repo, but I thought it would be a nice exercise towards learning how to manage dependencies. Since C doesn't seem to have anything like cargo, PyPi or npm, I started to look for best practices on how to do that.
So, this is what I came up with so far, with a Makefile:
- dependency file as a target, with commit pinned as separate var
STB_IMAGE_COMMIT := 013ac3beddff3dbffafd5177e7972067cd2b5083
vendor/stb/stb_image.h:
curl -fsSL --create-dirs https://raw.githubusercontent.com/nothings/stb/$(STB_IMAGE_COMMIT)/stb_image.h -o $@
- making it prerequisite to the main build target:
build/%.o: src/%.c | build vendor/stb/stb_image.h
$(CC) $(CFLAGS) -c $< -o $@
This seems simple, reproducible and efficient to me. But I'm not sure it would scale well and also - maybe there are better approaches out there?