#Infos: http://www.ijon.de/comp/tutorials/makefile.html


VERSION = 1.0
CC      = cc
CFLAGS  = -Wall -g -D_GNU_SOURCE -D_REENTRANT -DVERSION=\"$(VERSION)\" `mysql_config --cflags`
#LDFLAGS = -lm -lpthread `gtk-config --cflags` `gtk-config --libs` -lgthread
LDFLAGS = -lwiringPi -lconfig `mysql_config --libs` -lcurl -lm

OBJ = main.o dht22.o sendmysql.o configreader.o cJSON.o restcurl.o calculate.o

dht22: $(OBJ)
	$(CC) $(CFLAGS) -o humiditypi $(OBJ) $(LDFLAGS)
        
%.o: %.c
	$(CC) $(CFLAGS) -c $<

.PHONY: clean
clean:
	rm -r *.o

install:
	sudo cp humiditypi /usr/bin
	if [ ! -d /etc/humiditypi ]; then sudo mkdir /etc/humiditypi; fi
	sudo cp settings.cfg /etc/humiditypi

uninstall:
	sudo rm /usr/bin/humiditypi
	rm -r /etc/humiditypi
