# add a cleaning target (to get rid of the binaries) # define default target (first target = default) # it depends on 'hello.o' (which must exist) # and hello_func.o hello: hello.o hello_func.o gcc -Wall hello.o hello_func.o -o hello # define hello.o target # it depends on hello.c (and is created from) # also depends on hello_api.h which would mean that # changing the hello.h api would force make to rebuild # this target (hello.o). # gcc -c: compile only, do not link hello.o: hello.c hello_api.h gcc -Wall -c hello.c -o hello.o # define hello_func.o target # it depends on hello_func.c (and is created from) # and hello_api.h (since that's it's declaration) hello_func.o: hello_func.c hello_api.h gcc -Wall -c hello_func.c -o hello_func.o # This is the definition of the target 'clean' # Here we'll remove all the built binaries and # all the object files that we might have generated # Notice the -f flag for rm, it means "force" which # in turn means that rm will try to remove the given # files, and if there are none, then that's ok. Also # it means that we have no writing permission to that # file and have writing permission to the directory # holding the file, rm will not then ask for permission # interactivelly. clean: rm -f hello hello.o hello_func.o