FreeBSD Bugzilla – Attachment 14232 Details for
Bug 26743
developers-handbook: makefiles and depend
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.05 KB, created by
edwin
on 2001-04-21 12:30:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
edwin
Created:
2001-04-21 12:30:01 UTC
Size:
2.05 KB
patch
obsolete
>--- chapter.sgml.old Fri Apr 20 14:50:17 2001 >+++ chapter.sgml Sat Apr 21 13:15:35 2001 >@@ -1146,6 +1146,55 @@ > </sect2> > > <sect2> >+ <title>Make and include-files</title> >+ >+ <para>C code often starts with a list of files to include, for >+ example stdio.h. Some of these files are system-include >+ files, some of them are from the project you're now working >+ on: >+ </para> >+ >+ <programlisting>#include <stdio.h> >+#include "foo.h" >+ >+int main(....</programlisting> >+ >+ <para>To make sure that this file is recompiled the moment >+ <filename>foo.h</filename> is changed, you have to add it in >+ your <filename>Makefile</filename>:</para> >+ >+ <programlisting>foo: foo.c foo.h</programlisting> >+ >+ <para>The moment your project is getting bigger and you have >+ more and more own include-files to maintain, it will be a >+ pain to keep track of all include files and the files which >+ are depending on it. If you change an include-file but >+ forget to recompile all the files which are depending on >+ it, the results will be devastating. <command>gcc</command> >+ has an option to analyze your files and to produce a list >+ of include-files and their dependencies: <option>-MM</option>. >+ </para> >+ >+ <para>If you add this to your Makefile:</para> >+ >+ <programlisting>depend: >+ gcc -E -MM *.c > .depend</programlisting> >+ >+ <para>and run <userinput>make depend</userinput>, the file >+ <filename>.depend</filename> will appear with a list of >+ object-files, C-files and the include-files:</para> >+ >+ <programlisting>foo.o: foo.c foo.h</programlisting> >+ >+ <para>If you change <filename>foo.h</filename>, next time >+ you run <command>make</command> all files depending on >+ <filename>foo.h</filename> will be recompiled.</para> >+ >+ <para>Don't forget to run <command>make depend</command> each >+ time you add an include-file to one of your files.</para> >+ </sect2> >+ >+ <sect2> > <title>FreeBSD Makefiles</title> > > <para>Makefiles can be rather complicated to write. Fortunately,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 26743
: 14232