Re: Simple question.

On 1/15/07, LWATCDR <lwatcdr gmail com> 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 \

HDRS = \
       some.h \
       headers_as.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)

       -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:

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


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