TARGETS	= $(OBJDIR)clint.log $(OBJDIR)fixme.log $(OBJDIR)htmllint.log $(OBJDIR)mime$(EXEEXT) $(OBJDIR)mimehandler$(EXEEXT) $(OBJDIR)tests.log $(OBJDIR)widget$(EXEEXT) $(OBJDIR)xmllint.log
OBJDIR	=
PREFIX	= /usr/local
DESTDIR	=
BINDIR	= $(PREFIX)/bin
SBINDIR	= $(PREFIX)/sbin
CC	= cc
CPPFLAGSF= -I ../include
CPPFLAGS=
CFLAGSF	= `pkg-config --cflags libSystem gtk+-3.0 x11`
CFLAGS	= -W -Wall -g -O2 -fPIE -D_FORTIFY_SOURCE=2 -fstack-protector
LDFLAGSF= `pkg-config --libs libSystem gtk+-3.0 x11` $(OBJDIR)../src/libDesktop.a
LDFLAGS	= -pie -Wl,-z,relro -Wl,-z,now
EXEEXT	=
RM	= rm -f
LN	= ln -f
MKDIR	= mkdir -m 0755 -p
INSTALL	= install


all: $(OBJDIR)mime$(EXEEXT) $(OBJDIR)mimehandler$(EXEEXT) $(OBJDIR)widget$(EXEEXT)

$(OBJDIR)clint.log: clint.sh $(OBJDIR)../src/libDesktop.a
	./clint.sh -P "$(PREFIX)" -- "$(OBJDIR)clint.log"

$(OBJDIR)fixme.log: fixme.sh $(OBJDIR)../src/libDesktop.a
	./fixme.sh -P "$(PREFIX)" -- "$(OBJDIR)fixme.log"

$(OBJDIR)htmllint.log: htmllint.sh
	./htmllint.sh -P "$(PREFIX)" -- "$(OBJDIR)htmllint.log"

mime_OBJS = $(OBJDIR)mime.o
mime_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
mime_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)

$(OBJDIR)mime$(EXEEXT): $(mime_OBJS)
	$(CC) -o $(OBJDIR)mime$(EXEEXT) $(mime_OBJS) $(mime_LDFLAGS)

mimehandler_OBJS = $(OBJDIR)mimehandler.o
mimehandler_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
mimehandler_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)

$(OBJDIR)mimehandler$(EXEEXT): $(mimehandler_OBJS) applications/Root.desktop applications/Widget.desktop
	$(CC) -o $(OBJDIR)mimehandler$(EXEEXT) $(mimehandler_OBJS) $(mimehandler_LDFLAGS)

$(OBJDIR)tests.log: $(OBJDIR)mime$(EXEEXT) $(OBJDIR)mimehandler$(EXEEXT) pkgconfig.sh tests.sh
	./tests.sh -P "$(PREFIX)" -- "$(OBJDIR)tests.log"

widget_OBJS = $(OBJDIR)widget.o
widget_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
widget_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)

$(OBJDIR)widget$(EXEEXT): $(widget_OBJS)
	$(CC) -o $(OBJDIR)widget$(EXEEXT) $(widget_OBJS) $(widget_LDFLAGS)

$(OBJDIR)xmllint.log: xmllint.sh
	./xmllint.sh -P "$(PREFIX)" -- "$(OBJDIR)xmllint.log"

$(OBJDIR)mime.o: mime.c $(OBJDIR)../src/libDesktop.a
	$(CC) $(mime_CFLAGS) -o $(OBJDIR)mime.o -c mime.c

$(OBJDIR)mimehandler.o: mimehandler.c $(OBJDIR)../src/libDesktop.a
	$(CC) $(mimehandler_CFLAGS) -o $(OBJDIR)mimehandler.o -c mimehandler.c

$(OBJDIR)widget.o: widget.c $(OBJDIR)../src/libDesktop.a
	$(CC) $(widget_CFLAGS) -o $(OBJDIR)widget.o -c widget.c

clean:
	$(RM) -- $(mime_OBJS) $(mimehandler_OBJS) $(widget_OBJS)
	./clint.sh -c -P "$(PREFIX)" -- "$(OBJDIR)clint.log"
	./fixme.sh -c -P "$(PREFIX)" -- "$(OBJDIR)fixme.log"
	./htmllint.sh -c -P "$(PREFIX)" -- "$(OBJDIR)htmllint.log"
	./tests.sh -c -P "$(PREFIX)" -- "$(OBJDIR)tests.log"
	./xmllint.sh -c -P "$(PREFIX)" -- "$(OBJDIR)xmllint.log"

distclean: clean
	$(RM) -- $(TARGETS)

install: all

uninstall:

.PHONY: all clean distclean install uninstall
