Sources :=	$(wildcard *.[ch])
CFiles :=	$(wildcard *.c)
Objects :=	$(patsubst %.c,%.o,$(CFiles))
System :=	$(shell uname)
MainSources :=	${shell grep -l '\<main *(' $(CFiles)}
Targets :=	${patsubst %.c,%,$(MainSources)}
AuxSources :=	$(filter-out $(MainSources),$(CFiles))
AuxObjects :=	${patsubst %.c,%.o,$(AuxSources)}

ifeq ($(System), SunOS)
CC :=		gcc
CFLAGS :=	-std=gnu11 -Wall -g
LDLIBS :=	-lafb -lowfat -lm
endif

ifeq ($(System), Linux)
CC :=		gcc
CFLAGS :=	-std=gnu11 -Wall -g
LDLIBS :=	-lafb -lowfat -lpthread -lm
endif

CFLAGS +=	$(shell pkg-config --cflags gdk-pixbuf-2.0)
LDLIBS +=	$(shell pkg-config --libs gdk-pixbuf-2.0)

.PHONY:		all
all:		$(Objects) $(Targets)

$(Targets):	%: %.o $(AuxObjects)
		$(CC) $(LDFLAGS) -o $@ $*.o $(AuxObjects) $(LDLIBS)

.PHONY:		depend clean realclean
depend: ;	gcc-makedepend $(CPPFLAGS) $(Sources)
clean: ;	rm -f $(Objects)
realclean:	clean
		rm -f $(Targets)
# DO NOT DELETE
