Take a look at this C++ example: for a file mybin this creates mybin.o and then links it, spitting out a mybin executable:
env CXXFLAGS="-std=c++14 -Wall -Wextra -pedantic" LDLIBS="-lstdc++" make mybin
To see what's going on, and what kind of file types are supported: make --print-data-base | egrep 'COMPILE.cc|LINK.cc'
This not only shows you what is going on, but also what kind of environment variables are involved and can therefore be customized.For small projects I would create a config.mk (e.g. with CXXFLAGS, CXX, ...) and provide a small Makefile, something along the lines of:
include config.mk
all: mybin
mybin: mybin.o
watch:
while ! inotifywait -e modify *.cc; do make; done
clean:
$(RM) *.o mybin
.PHONY: all watch clean
This allows you to easily 1/ add dependencies for binaries and 2/ speed up the development proccess, using the make watch target (note: this does not include header dependencies).Disclaimer: Makefiles seem to be wonderful build-systems (not dependency managers!) for small projects; but as soon as you find yourself searching for hacks to build into your little Makefile, ditch it and switch to something serious. That's at least my experience.