«

»

Nov
17

Einfaches GNU Makefile für C Programme

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)

Hinterlasse eine Antwort

Ihre E-Mail-Adresse wird nicht veröffentlicht.

Sie können diese HTML-Tags verwenden: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What is 2 + 2 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)