Re: Simple question.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/15/07, LWATCDR <lwatcdr@xxxxxxxxx> wrote:
> Anyone have an example of a make file for a GTK application?
> Just a simple one for a helloworld would do.

If it's a single file, you can just do:

  gcc hello.c -o hello `pkg-config gtk+-2.0 --cflags --libs`

Put that in a comment on the first line and you can just copy/paste to build.

The last time I had to write a makefile by hand I did:

--------------
OUT = myprogram
prefix = /usr/local

SRCS = \
        a_lot_of.c \
        source.c \
        files.c

HDRS = \
        some.h \
        headers_as.h \
        well.h

OBJS = $(SRCS:.c=.o)

LIBS = `pkg-config gtk+-2.0 --libs`
CFLAGS = -g -Wall `pkg-config gtk+-2.0 --cflags`

all: $(OUT)

$(OUT): $(OBJS)
        $(LINK.c) $(OBJS) $(LIBS) -o $(OUT)

$(OBJS): $(HDRS)

tags: $(SRCS)
        ctags $(SRCS) $(HDRS)

clean:
        -rm -f $(OBJS)
        -rm -f $(OUT)
        -rm -f tags

install: $(OUT)
        -mkdir ${prefix}
        -mkdir ${prefix}/bin
        -mkdir ${prefix}/share
        -mkdir ${prefix}/share/$(OUT)

        cp $(OUT) ${prefix}/bin
        cp -r data ${prefix}/share/$(OUT)
---------------------

it's very crude :-( You can autotool your project pretty easily these
days, you could consider that too. Autotool is very handy if you can
stomach the steep learning curve and the bizarre collection of things
it's made out of.

The autobook has a simple example:

http://sources.redhat.com/autobook/

there's a section on how to autotool an existing project:

http://sources.redhat.com/autobook/autobook/autobook_237.html#SEC237

John
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux