Editing Documentation/Maemo 5 Developer Guide/GNU Build System

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.

Warning: This page is 71 kilobytes long; some browsers may have problems editing pages approaching or longer than 32kb. Please consider breaking the page into smaller sections.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 241: Line 241:
N.B. Other parts of the makefile do not change. [https://vcs.maemo.org/svn/maemoexamples/tags/maemo_5.0/simple-make-files/Makefile.2 simple-make-files/Makefile.2]
N.B. Other parts of the makefile do not change. [https://vcs.maemo.org/svn/maemoexamples/tags/maemo_5.0/simple-make-files/Makefile.2 simple-make-files/Makefile.2]
-
<source lang="make">
+
<tt><span>''<span><font color="#9A1900"><nowiki># add a cleaning target (to get rid of the binaries)</nowiki></font></span>''</span>
-
# add a cleaning target (to get rid of the binaries)
+
<span>''<span><font color="#9A1900"><nowiki># define default target (first target = default)</nowiki></font></span>''</span>
-
# define default target (first target = default)
+
<span>''<span><font color="#9A1900"><nowiki># it depends on 'hello.o' (which must exist)</nowiki></font></span>''</span>
-
# it depends on 'hello.o' (which must exist)
+
<span>''<span><font color="#9A1900"><nowiki># and hello_func.o</nowiki></font></span>''</span>
-
# and hello_func.o
+
hello<span><font color="#990000"><nowiki>:</nowiki></font></span> hello<span><font color="#990000">.</font></span>o hello_func<span><font color="#990000">.</font></span>o
-
hello: hello.o hello_func.o
+
        gcc -Wall hello<span><font color="#990000">.</font></span>o hello_func<span><font color="#990000">.</font></span>o -o hello
-
        gcc -Wall hello.o hello_func.o -o hello
+
<span>''<span><font color="#9A1900"><nowiki># define hello.o target</nowiki></font></span>''</span>
-
# define hello.o target
+
<span>''<span><font color="#9A1900"><nowiki># it depends on hello.c (and is created from)</nowiki></font></span>''</span>
-
# it depends on hello.c (and is created from)
+
<span>''<span><font color="#9A1900"><nowiki># also depends on hello_api.h which would mean that</nowiki></font></span>''</span>
-
# also depends on hello_api.h which would mean that
+
<span>''<span><font color="#9A1900"><nowiki># changing the hello.h api would force make to rebuild</nowiki></font></span>''</span>
-
# changing the hello.h api would force make to rebuild
+
<span>''<span><font color="#9A1900"><nowiki># this target (hello.o).</nowiki></font></span>''</span>
-
# this target (hello.o).
+
<span>''<span><font color="#9A1900"><nowiki># gcc -c: compile only, do not link</nowiki></font></span>''</span>
-
# gcc -c: compile only, do not link
+
hello<span><font color="#990000">.</font></span>o<span><font color="#990000"><nowiki>:</nowiki></font></span> hello<span><font color="#990000">.</font></span>c hello_api<span><font color="#990000">.</font></span>h
-
hello.o: hello.c hello_api.h
+
        gcc -Wall -c hello<span><font color="#990000">.</font></span>c -o hello<span><font color="#990000">.</font></span>o
-
        gcc -Wall -c hello.c -o hello.o
+
<span>''<span><font color="#9A1900"><nowiki># define hello_func.o target</nowiki></font></span>''</span>
-
# define hello_func.o target
+
<span>''<span><font color="#9A1900"><nowiki># it depends on hello_func.c (and is created from)</nowiki></font></span>''</span>
-
# it depends on hello_func.c (and is created from)
+
<span>''<span><font color="#9A1900"><nowiki># and hello_api.h (since that's it's declaration)</nowiki></font></span>''</span>
-
# and hello_api.h (since that's it's declaration)
+
hello_func<span><font color="#990000">.</font></span>o<span><font color="#990000"><nowiki>:</nowiki></font></span> hello_func<span><font color="#990000">.</font></span>c hello_api<span><font color="#990000">.</font></span>h
-
hello_func.o: hello_func.c hello_api.h
+
        gcc -Wall -c hello_func<span><font color="#990000">.</font></span>c -o hello_func<span><font color="#990000">.</font></span>o
-
        gcc -Wall -c hello_func.c -o hello_func.o
+
<span>''<span><font color="#9A1900"><nowiki># This is the definition of the target 'clean'</nowiki></font></span>''</span>
-
# This is the definition of the target 'clean'
+
<span>''<span><font color="#9A1900"><nowiki># Here we'll remove all the built binaries and</nowiki></font></span>''</span>
-
# Here we'll remove all the built binaries and
+
<span>''<span><font color="#9A1900"><nowiki># all the object files that we might have generated</nowiki></font></span>''</span>
-
# all the object files that we might have generated
+
<span>''<span><font color="#9A1900"><nowiki># Notice the -f flag for rm, it means "force" which</nowiki></font></span>''</span>
-
# Notice the -f flag for rm, it means "force" which
+
<span>''<span><font color="#9A1900"><nowiki># in turn means that rm will try to remove the given</nowiki></font></span>''</span>
-
# in turn means that rm will try to remove the given
+
<span>''<span><font color="#9A1900"><nowiki># files, and if there are none, then that's ok. Also</nowiki></font></span>''</span>
-
# files, and if there are none, then that's ok. Also
+
<span>''<span><font color="#9A1900"><nowiki># it means that we have no writing permission to that</nowiki></font></span>''</span>
-
# it means that we have no writing permission to that
+
<span>''<span><font color="#9A1900"><nowiki># file and have writing permission to the directory</nowiki></font></span>''</span>
-
# file and have writing permission to the directory
+
<span>''<span><font color="#9A1900"><nowiki># holding the file, rm will not then ask for permission</nowiki></font></span>''</span>
-
# holding the file, rm will not then ask for permission
+
<span>''<span><font color="#9A1900"><nowiki># interactivelly.</nowiki></font></span>''</span>
-
# interactivelly.
+
clean<span><font color="#990000"><nowiki>:</nowiki></font></span>
-
clean:
+
        rm -f hello hello<span><font color="#990000">.</font></span>o hello_func<span><font color="#990000">.</font></span>o
-
        rm -f hello hello.o hello_func.o
+
</tt>
-
</source>
+
To get make to use this file instead of the default Makefile, use the -f command line parameter as follows:
To get make to use this file instead of the default Makefile, use the -f command line parameter as follows:

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: