Re: Making a Makefile
- From: "Kevin Mahoney" <kmahoney40 hotmail com>
- To: horrorvacui gmx net, vladeck sezampro yu, gtk-app-devel-list gnome org
- Subject: Re: Making a Makefile
- Date: Wed, 20 Nov 2002 18:42:50 -0800
Thanks, Horror and Vladimir
The big key is
PKG_CONFIG=`pkg-config --libs --cflags gtk+-2.0`
I know a bit more about makefiles now :)
Kevin
From: Horror Vacui <horrorvacui gmx net>
To: Kevin Mahoney <kmahoney40 hotmail com>
Subject: Re: Making a Makefile
Date: Thu, 21 Nov 2002 03:32:06 +0100
Kevin Mahoney wrote:
Hi,
I am new to this list and makefiles. From the online documentation I was
able to compile a simple 1 file program using:
$ g++ -Wall -g helloworld.cpp -o helloworld `pkg-config --cflags gtk+-2.0`
`pkg-config --libs gtk+-2.0`
You need to specify a "target", what it depends on and the action to obtain
it. For this program the Makefile could look like this:
#Makefile helloworld
CC=gcc
CFLAGS=-Wall -g
PKG_CONFIG=`pkg-config --libs --cflags gtk+-2.0`
helloworld: helloworld.cpp helloworld.h
$(CC) $(CFLAGS) $(PKG_CONFIG) helloworld.cpp -o
helloworld
#end Makefile
Targets don't have any whitespace before them, actions MUST have whitespace
- this is the way to distinguish them. First target specified is the
default target, and will be processed when make is called without an
argument in the directory containing this Makefile; after the colon (:)
come the dependancies, in this case helloworld depends on helloworld.cpp
and helloworld.h, and will be recompiled if either or both of them have
changed. The line below that is the command that needs to be executed to
get the target. You can have more targets, for example:
foobar: foo.o bar.o
gcc foo.o bar.o -o foobar
foo.o: foo.c
gcc -c foo.c
bar.o: bar.c
gcc -c bar.c
here, foobar depends on foo.o (which depends on foo.c) and bar.o (which
depends on bar.c), if you change foo.c, foo.o and foobar will be
recompiled.
Cheers
Horror Vacui
_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]