CPP  = g++
CC   = gcc
# WINDRES = windres.exe
RES  =
OBJ  = arkanoid.o ball.o $(RES)
LINKOBJ  = arkanoid.o ball.o $(RES)
LIBS = `pkg-config --libs sdl2` `pkg-config --libs SDL2_ttf`
INCS = `pkg-config --cflags sdl2`
CXXINCS =
BIN  = arkanoid
CXXFLAGS = $(CXXINCS)   -g
CFLAGS = $(INCS)   -g
RM = rm -f
prefix=/usr

.PHONY: all all-before all-after clean clean-custom

all: all-before arkanoid all-after


clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
	$(CC) $(LINKOBJ) -o "arkanoid" $(LIBS)

arkanoid.o: arkanoid.c
	$(CC) -c arkanoid.c -o arkanoid.o $(CFLAGS) -DLINUX

ball.o: ball.c
	$(CC) -c ball.c -o ball.o $(CFLAGS) -DLINUX

install:
	mkdir -pm 0755 $(prefix)/share/arkanoid
	install -m 0755 arkanoid $(prefix)/bin
	install -m 0644 icon/arkanoid.png $(prefix)/share/pixmaps
	install -m 0644 icon/gumka_arkanoid.bmp $(prefix)/share/pixmaps
	install -m 0755 arkanoid.desktop /usr/share/applications
#	install -m 0644 SpicyRice.ttf $(prefix)/share/fonts/
	install -m 0644 SpicyRice.ttf $(prefix)/share/arkanoid
.PHONY: install

uninstall:
	rm $(prefix)/bin/arkanoid
	rm $(prefix)/share/pixmaps/arkanoid.png
	rm $(prefix)/share/pixmaps/gumka_arkanoid.bmp
#	rm $(prefix)/share/fonts/SpicyRice.ttf
	rm $(prefix)/share/arkanoid/SpicyRice.ttf
	rm /usr/share/applications/arkanoid.desktop
	rmdir $(prefix)/share/arkanoid
.PHONY: uninstall
