From Electron Cloud
Revision as of 14:55, 31 August 2006 by Ecloud (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is just a basic starting point for compiling a C project.

TARGET = theapp
SOURCES = $(wildcard *.c)
OBJECTS = $(subst .c$,.o,$(SOURCES))
HEADERS = $(wildcard *.h)
CC = gcc
LINK = gcc
STRIP = strip

$(TARGET): .depend $(OBJECTS)
        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBPATH) $(LIBS)
        $(STRIP) $(TARGET)

.c.o: $*.h common.h
        echo ".h $*.h"
        $(CC) -c $(CFLAGS) $(DEBUGFLAGS) $(INCPATH) -o $@ $<

-include .depend

version.h:
        echo "#define BUILD_DATE \"`/bin/date \"+%d %b %Y\"`\"" > version.h

clean:
        -rm -f .depend
        -rm -f $(OBJECTS)
        -rm -f *~ core *.core
        -rm -f version.h
        -rm -f $(TARGET)

depend:
.depend: Makefile $(SOURCES) $(HEADERS)
        @if [ ! -f .depend ]; then touch .depend; fi
        @makedepend -Y -f .depend  $(SOURCES) 2>/dev/null

test:
        echo $(OBJECTS)