#  Copyright (C) 2004   Ibn Cereijo Graa, Jairo Chapela Martnez.
#
#  This file is part of lingot.
#
#  lingot is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  lingot is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with lingot; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
PROYECTO  = lingot
FUENTES   = src/*.cc src/analizador/*.cc src/gui/*.cc

DEFINES   = -DGTK12 #-DOSS -DLIBSNDOBJ #-DLIB_FFTW
INCDIR    = `gtk-config --cflags` -Isrc/analizador -Isrc/gui -Isrc
C_FLAGS   = -g -Wall $(DEFINES) $(INCDIR)
LIBRERIAS = `gtk-config --libs` -lstdc++ -lpthread -lm #-lsndobj #-lfftw
EJECUTAR  = ls -l $(PROYECTO)

SRCS = $(wildcard $(FUENTES))
OBJS = $(SRCS:.cc=.o)

CXX       = g++
CXXLINKER = g++
CFLAGS  = -g -O2 -I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include -I/usr/X11R6/include -DPACKAGE_NAME=\"tuner\" -DPACKAGE_TARNAME=\"tuner\" -DPACKAGE_VERSION=\"0.5.8\" -DPACKAGE_STRING=\"tuner\ 0.5.8\" -DPACKAGE_BUGREPORT=\"BUG-REPORT-ADDRESS\" -DHAVE_LIBGTK=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_LANGINFO_H=1 -DHAVE_LIBINTL_H=1 -DHAVE_LOCALE_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_SYS_IOCTL_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_MEMSET=1 -DHAVE_MKDIR=1 -DHAVE_POW=1 -DHAVE_RINT=1 -DHAVE_SELECT=1 -DHAVE_SETLOCALE=1 -DHAVE_SQRT=1  $(INCLUDE_DIR) $(C_FLAGS)
LDFLAGS =  -lgtk  -L/usr/lib -L/usr/X11R6/lib -lgtk -lgdk -rdynamic -lgmodule -lglib -ldl -lXi -lXext -lX11 -lm


all: $(PROYECTO)

$(PROYECTO): .depend $(OBJS)
	$(CXX) -o $(PROYECTO) $(OBJS) $(LIBRERIAS)

%.o: %.cc .depend
	$(CXX) $(C_FLAGS) -c $< -o $@

install: $(PROYECTO)
	install -d /usr/local
	install -d /usr/local/bin
	install $(PROYECTO) /usr/local/bin

clean:
	find -type f -path '*.o' | xargs rm -f
	/bin/rm -f *~ .depend $(EXECS)

.PHONY: all run clean

.DEFAULT:
	@echo "Calculando requisitos"
	g++ $(INCDIR) -M $(FUENTES) > .depend

sinclude .depend
