Ralf Hüsing

November 17, 2007

Einfaches GNU Makefile für C Programme

Abgelegt unter: Programmierung — ralf @ 7:53 pm

Falls wer mal ein Makefile auf die schnelle braucht und grad keins zur Hand hat, wie es mir irgendwie ständig geht, hier mal eins was halbwegs tut:

CC=gcc
CFLAGS+=-Wall -pedantic -std=c99 -O3 -g -D_GNU_SOURCE
LDFLAGS+=
VALGRIND=`which valgrind`
STRACE=`which strace`

PROGRAM=test_rh_event
OBJECTS=rh_event.o rh_event_poll.o rh_event_epoll.o

all: $(PROGRAM)

test_rh_event: test_rh_event.c $(OBJECTS) Makefile
        @echo "LD $@"
        @$(CC) $(CFLAGS) -o $@ $< $(OBJECTS) $(LDFLAGS)

valgrind: $(PROGRAM)
        $(VALGRIND) --track-fds=yes --leak-check=yes --show-reachable=yes ./$(PROGRAM)

strace: $(PROGRAM)
        $(STRACE) -f ./$(PROGRAM)

%.o: %.c %.h
        @echo "CC $@"
        @$(CC) $(CFLAGS) -c -o $@ $<

%.o: %.c
        @echo "CC $@"
        @$(CC) $(CFLAGS) -c -o $@ $<

clean:
        $(RM) $(OBJECTS) $(PROGRAM)

Keine Kommentare »

Noch keine Kommentare.

RSS-Feed für Kommentare zu diesem Artikel. TrackBack-URL

Einen Kommentar hinterlassen

Powered by WordPress ( WordPress Deutschland )