SRCS=$(wildcard noarch/*.cpp) $(wildcard linux/*.cpp) TARGET=Blinker CPP=g++ INCLUDE=-Inoarch -Ilinux CFLAGS=-Wall -Wextra -g2 LDFLAGS= LIBS=-lBlinkenLib SRCS_BASE=$(patsubst %.cpp,%,$(SRCS)) DEPS=$(addsuffix .d,$(SRCS_BASE)) OBJS=$(addsuffix .o,$(SRCS_BASE)) .PHONY: all clean .SUFFIXES: .SECONDARY: all: deps $(TARGET) ifneq ($(MAKECMDGOALS),clean) include deps endif deps: $(DEPS) cat /dev/null $+ >$@ %.d: %.cpp Makefile $(CPP) $(INCLUDE) $(CFLAGS) -M -o $@ $< sed -i 1s!^!$(dir $<)! $@ %.o: %.cpp Makefile $(CPP) $(INCLUDE) $(CFLAGS) -c -o $@ $< $(TARGET): $(OBJS) $(CPP) $(LDFLAGS) -o $@ $+ $(LIBS) clean: rm -f deps $(DEPS) $(OBJS) $(TARGET)