SRCS := $(wildcard *.c)
OBJS := $(patsubst %.c,%.o,$(SRCS))
DEPS := $(patsubst %.c,%.d,$(SRCS))

all: $(DEPS) $(OBJS)

clean: 
	rm -f *~ *.o *.d main

COMPILE ?= g++ -g -Wall -c
LINK ?= g++ -g -Wall
MAKEDEP ?= g++ -M


%d:%c
	$(MAKEDEP) $< > $@
	$(MAKEDEP) $< | sed s/\\.o/.d/ >> $@

%.o: %.c
	$(COMPILE) $<


-include $(DEPS)
