CC=gcc
OPTIONS=-fpic -Wall -O2 -fomit-frame-pointer -pipe

#execute o comando 
#pg_config --includedir-server 
#para saber onde estao os cabecalhos no seu sistema

INCLUDE:=`pg_config --includedir-server`
LIBDIR=`pg_config --pkglibdir`

all:execPostgreSQL.o

install:execPostgreSQL.o
	$(CC) -shared -o execPostgreSQL.so execPostgreSQL.o
	mv execPostgreSQL.so $(LIBDIR)/
	cp envia_email.sh $(LIBDIR)/
	psql -U $(username) -d $(database) --file instala.sql 

execPostgreSQL.o:execPostgreSQL.c
	$(CC) -I$(INCLUDE) -I/usr/local/include $(OPTIONS) -c -o $@ $<

clean:
	rm -f *.o execPostgreSQL.o
