Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 1.82 KB

README.md

File metadata and controls

41 lines (32 loc) · 1.82 KB

This is a tiny set of files to help a tutorial by phone on GNU make. It is two variants of a hello world program (one is a single file helloworld1.c, another is a two files hello2.c and world2.c with a common header helloworld2.h). There are three makefiles: Makefile1, Makefile2plain and Makefile2timestamp (the later showing a generated timestamp2.c file with auto-dependencies).

Read wikipages on make and on Makefile-s. Remember that the tab character is significant in these Makefile-s (some editors may require special configuration for that, but most source editors are clever enough).

Read of course the documentation of GNU make and of GCC, notably the first sections of §3 GCC Command Options.

I am not sure if it is correct to use the GPLv3+ license for such a trivial example.

See discussion on https://opensource.stackexchange.com/q/7597/910

To use the first Makefile, type make -f Makefile1 (it builds the helloworld1 executable from source helloworld1.c).

To clean after that, type make -f Makefile1 clean

To use the second Makefile type make -f Makefile2plain (it builds the helloworld2 executable from hello2.c and world2.c, and they both include helloworld2.h) then later clean the mess with make -f Makefile2plain clean.

To use the third Makefile type make -f Makefile2timestamp (it generates a timestamp2.c and build the helloworld2timestamp; it also autogenerate make dependencies).

You can symlink one of the Makefile-s above to your Makefile and then just run make (or make clean).