Help on creating a Makefile

December 12, 2005
When ever you download the source package of a software from the net and decide to compile it on your platform, you always move to its directory and issue a make command.

When you execute the 'make' command, it reads a file by name Makefile and according to the directions listed in this file, the source - which may be 100s of files of code - is automagically compiled (provided the necessary compilers are installed on your machine).

So one of the necessary ingredient in successful compiling of code using the make command is the Makefile. If you are a developer or aspiring to create your own programs, then it is imperative that you know how to create a Makefile because using make is much more efficient and time saving than directly compiling the source.

Guy keren has written a very clear tutorial on how to create a Makefile to aid the compilation of code. The author takes the reader through all the steps and syntax of the Makefile and explains it with the help of simple examples.

1 comments:

  • goatbar

    Hmmm... I think this is missing some stuff that makes things easier for beginners. My personal preference is to stick to gnu make, with things like DATE := ${shell date +'%b%d'} and SRCS := ${wildcard *.c} followed by SRCS += strange_name_for_c_code

    I also like an initial rule like

    help:
    @echo bunch of comments explaining what the options are