views:

1045

answers:

4

Hello, I'm new to Linux development, 'make' seems to be the standard for building applications.

I'm having difficulties understanding the structure of a makefile.

Please, can you point me to good resource or documentation to look at ?

+1  A: 

This is all you need: make

ennuikiller
+2  A: 

The best tutorial that I have found for makefiles so far has been this one. One of your other options is to learn autotools and let them produce your makefiles for you, though a little outdated this is the tutorial that I found best to learn from.

Mike Lowen
FYI: CMake also generates makefiles, and is simpler and less fragile then the autotools. You can find a tutorial for it at http://www.lazycodemonkey.com/?p=46=1 and the manual of CMake commands at http://www.cmake.org/cmake/help/cmake2.6docs.html . All it takes to use CMake is to create a "CMakeLists.txt" file and add the appropriate commands (using the manual).
Michael Aaron Safyan
+2  A: 

You could also use this tutorial by example. It provides very easy examples that will work for simple projects.

Freddy
+1  A: 

While it is well and good that you learn how to read and write a Makefile, I strongly recommend that you use CMake for your C/C++ builds instead of writing your own Makefile. It is very difficult to craft a portable Makefile, which is why the C++ community shifted from hand-crafted makefiles to using the GNU Autotools (Automake, Autoconf, Autoheader, Autoreconf, Libtool, etc.).However, the extreme complexity of the GNU Autotools left much to be desired, resulting in the creation of CMake, which is quickly becoming the build tool of choice for the C/C++ community. It has already been adopted by a growing list of projects, including KDE.

Michael Aaron Safyan
"the creation of CMake, which is quickly becoming the build tool of choice for the C/C++ community" I keep hearing this, and I keep not encountering it in the wild. Maybe I just use the wrong software, but could you point at a examples?
dmckee
I already gave a link to a list of some projects which use CMake for their build process. BOOST is currently experimenting with CMake (they still have their old build mechanism, but now have a CMake build, which will eventually replace their JAM-based process), with KDE4, KDE has switched to using CMake, the Robotics Operating System (ROS) uses CMake extensively, and I'm pretty sure that Mesa3D (a free implementation of OpenGL) now uses CMake. All of these are huge C/C++ projects or umbrella projects, and the list keeps growing.
Michael Aaron Safyan
See also: http://www.lazycodemonkey.com/?p=46=1
Michael Aaron Safyan