# Makefile - Makefile template for Linux/Unix
# Copyright (c) 2007 - 2011 Michael Riepe
#  
# This program 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.
#  
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# @(#) $Id$

srcdir = @srcdir@
top_srcdir = @top_srcdir@
topdir = ..
subdir = src

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@
datarootdir = @datarootdir@
mandir = @mandir@
man1dir = $(mandir)/man1
helpdir = $(prefix)/share/dvbcut

installdirs = $(DESTDIR)$(bindir) $(DESTDIR)$(helpdir)

CXX = @CXX@
CXXFLAGS = @CXXFLAGS@ -Wall -Wcast-align $(DEFS) $(CPPFLAGS)
CPPFLAGS = @CPPFLAGS@ -I.
DEFS = @DEFS@
LDFLAGS = @LDFLAGS@
FFMPEG_LIBS = @FFMPEG_LIBS@
LIBS = $(FFMPEG_LIBS) @LIBS@

INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
STRIP = @STRIP@

EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
STDLIB = @STDLIB@

QTDIR = @QTDIR@

PATH := $(QTDIR)/bin:$(PATH)

ui_%.h: %.ui
	uic -o $@ $<

uic_%.cpp: %.h
	uic -o $@ $<

moc_%.cpp: %.h
	moc -o $@ $<

%.qm: %.ts
	lrelease $< -qm $@

MOC = \
	moc_dvbcut.cpp \
	moc_exportdialog.cpp \
	moc_mplayererrorbase.cpp \
	moc_progressstatusbar.cpp \
	moc_progresswindow.cpp \

UIC = \
	ui_dvbcutbase.h \
	ui_exportdialogbase.h \
	ui_mplayererrorbase.h \
	ui_progresswindowbase.h

QM = \
	dvbcut.qm \
	dvbcut_cs.qm \
	dvbcut_de.qm

QRC = \
	qrc_icons.cpp

SRCS = \
	avframe.cpp differenceimageprovider.cpp buffer.cpp \
	dvbcut.cpp eventlistitem.cpp exception.cpp exportdialog.cpp \
	imageprovider.cpp index.cpp lavfmuxer.cpp logoutput.cpp \
	main.cpp mpegmuxer.cpp mpgfile.cpp mplayererrorbase.cpp playaudio.cpp \
	progressstatusbar.cpp progresswindow.cpp psfile.cpp \
	pts.cpp streamdata.cpp tsfile.cpp settings.cpp $(MOC) $(QRC) \
	$(STDLIB)

OBJS = $(SRCS:.cpp=.$(OBJEXT))

all: $(topdir)/bin $(topdir)/bin/dvbcut$(EXEEXT) $(QM)

check:

install: all installdirs
	$(INSTALL_PROGRAM) dvbcut$(EXEEXT) $(DESTDIR)$(bindir)
	$(INSTALL_DATA) dvbcut_cs.html $(DESTDIR)$(helpdir)
	$(INSTALL_DATA) dvbcut_en.html $(DESTDIR)$(helpdir)
	$(INSTALL_DATA) dvbcut_de.html $(DESTDIR)$(helpdir)

installdirs: $(installdirs)

$(installdirs):
	$(SHELL) $(top_srcdir)/mkinstalldirs $@

$(topdir)/bin:
	mkdir $@

qrc_icons.cpp:
	rcc -name icons -o $@ ../icons/icons.qrc

$(topdir)/bin/dvbcut$(EXEEXT): dvbcut$(EXEEXT)
	$(INSTALL_PROGRAM) dvbcut$(EXEEXT) $(topdir)/bin/dvbcut$(EXEEXT)
	$(STRIP) $(topdir)/bin/dvbcut$(EXEEXT)

dvbcut$(EXEEXT): $(SRCS) $(UIC) $(OBJS)
	$(CXX) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

clean:
	-rm -f *.$(OBJEXT)

distclean: clean
	-rm -f $(MOC) $(UIC) $(QM) $(QRC) $(topdir)/bin/dvbcut$(EXEEXT) dvbcut$(EXEEXT)
	-rmdir $(topdir)/bin
	-rm -f .depend stamp-depend

maintainer-clean: distclean

dep: stamp-depend
stamp-depend: $(SRCS)
	-@rm -f .depend $@
	-$(CXX) -MM $(DEFS) $(CPPFLAGS) $(SRCS) > .depend
	echo timestamp > $@

-include .depend

# static dependencies:

moc_dvbcut.cpp: dvbcut.h
moc_exportdialog.cpp: exportdialog.h
moc_progressstatusbar.cpp: progressstatusbar.h
moc_progresswindow.cpp: progresswindow.h
uic_dvbcutbase.cpp: dvbcutbase.h
uic_exportdialogbase.cpp: exportdialogbase.h
uic_mplayererrorbase.cpp: mplayererrorbase.h
uic_progresswindowbase.cpp: progresswindowbase.h
dvbcutbase.h: dvbcutbase.ui
exportdialogbase.h: exportdialogbase.ui
mplayererrorbase.h: mplayererrorbase.ui
progresswindowbase.h: progresswindowbase.ui

distfiles: \
	dvbcutbase.h \
	exportdialogbase.h \
	moc_dvbcut.cpp \
	moc_dvbcutbase.cpp \
	moc_exportdialog.cpp \
	moc_mplayererrorbase.cpp \
	moc_progressstatusbar.cpp \
	moc_progresswindow.cpp \
	moc_progresswindowbase.cpp \
	mplayererrorbase.h \
	progresswindowbase.h \
	uic_dvbcutbase.cpp \
	uic_exportdialogbase.cpp \
	uic_mplayererrorbase.cpp \
	uic_progresswindowbase.cpp \
        qrc_icons.cpp
