Makefiles, “configure” files, and other compilation tools — How do they work? Why do they work the way they do?

I'm still new to the UNIX/Linux world, and, in particular, to related tools, such as the GCC compiler. Namely, I'm still new to makefiles and things like that (I use MinGW on Windows), since so far, most of my development has been with IDEs like Visual Studio and Eclipse.

When I open a typical project folder, I see files like these:

configure
make
INSTALL
install-sh  (or a variant)

There's quite a few things I don't understand here, and my main questions are these:

  1. What's the difference between these, and why do we need each one? (In the IDE world, all you have is a project file; that's it. So I'm confused why we have more than just a makefile here.)

  2. How are these files generated? For small projects, you could probably write them by hand, but for big projects like GCC, it would be ridiculous to even try. I've found editing these files to be a pain, and I've come to the conclusion that I'm not supposed to be modifying them by hand. But if so, then what tools do people typically use for adding and modifying these files?

  3. Why don't they use wildcards inside a makefile? Why is there a single line for every single object file? Is this because of a restriction, or is there an advantage to it?

  4. What's the difference between having a shell script that calls the compiler with every file, and having a makefile that does the same thing? In Windows, I'd be very tempted to just create a batch file inside the folder, and compile everything with that -- no need for more than just one file. What's the difference? Why isn't there just a single .sh file, to compile everything?

Bonus question:

  • Is there a "standard" makefile format? I've seen different make tools that don't accept each other's formats... how do I know what to use? Is GCC just the usual tool here, or is there some standard everyone should follow?

I'll probably have more questions as I learn more about the structure of projects like this, but for now, these are my biggest questions. :)

9
задан Mehrdad 22 March 2011 в 09:22
поделиться