#####################################
# Makefile genérica
#  V. Santos, Oct-2011
####################################
#As minhas sources...  exemplos
SRC=main.c ChildMain.c FatherMain.c ChildCallback.c auxChild.c auxFather.c  
#O executável ... exemplo
PROG=Projecto_41674
#O ficheiro de configuração de documentação (a gerar)
DOXYFILE=Doxyfile
#Header files (exemplos)
HEADERS=prototype.h
#local da biblioteca 
LIBDIR=./myutils   #caminho para a libraria 


################################
## Daqui para baixo não deve ser preciso mexer muito :-)

###definições (macros)
CC=gcc
CFLAGS=-Wall 
#CFLAGS+=`pkg-config --cflags opencv`
CFLAGS+=`pkg-config --cflags gtk+-2.0`

INCLUDE=-I$(LIBDIR) 
OBJ=$(SRC:.c=.o)

LIBS=-L$(LIBDIR) -lmyutils 
LIBS+=`pkg-config --libs gtk+-2.0` -export-dynamic
#LIBS+=`pkg-config --libs opencv` -lm 
#### MACRO updates

# The -export-dynamic (or -E flag in the linker) is required to export all dynamic symbols.


#### Targets

$(PROG): proto $(OBJ)
	$(CC) $(OBJ) -o $(PROG) $(LIBS)

.c.o: 
	$(CC) $(CFLAGS) -c $(INCLUDE) $< -o $@

clean:
	rm -f $(PROG) $(OBJ)

allclean: clean
	rm -f $(OBJ)
	#rm -f $(DOXYFILE)
	rm -f $(HEADERS)
	rm -rf latex html

depend:
	@#redirect output to /dev/null due to some bugs in makedepend :-(
	makedepend -Y $(SRC) 2> /dev/null

doc:
	@ if ! [ -f $(DOXYFILE) ] ; then \
		doxygen -g $(DOXYFILE) ; \
		cat $(DOXYFILE) |\
		sed 's/^PROJECT_NAME.*$$/PROJECT_NAME      = $(PROG)/'|\
		sed 's/^QUIET.*$$/QUIET      = YES/'|\
		sed 's/^GENERATE_TREEVIEW.*$$/GENERATE_TREEVIEW      = ALL/'|\
		sed 's/^GENERATE_LATEX.*$$/GENERATE_LATEX      = NO/'|\
		sed 's/^HAVE_DOT.*$$/HAVE_DOT      = YES/'\
		> $(DOXYFILE) ; \
		doxygen $(DOXYFILE) ; \
	else \
		doxygen $(DOXYFILE); \
	fi

#Generate a list of functions (useful for prototypes)
#notice the $$ to escape the Make interpretation of $
proto prototype.h:
	@echo /*File generated automatically. Do not edit*/ > prototype.h
	@ ctags -x --c-kinds=f $(SRC) |\
	grep -v main | \
	awk '{for(n=5; n<=NF; n++) printf("%s ", $$n) ; printf(";\n");}' >> prototype.h

tags: $(SRC) $(HEADERS)
	ctags $(SRC) $(HEADERS)

# DO NOT DELETE
