# QTDIR should be set in your environment variable

# Compiler programs
CC=@CC@
CXX=@CXX@
MOC=@MOC@
UIC=@UIC@

# Extra defines
prefix=@prefix@
exec_prefix=@exec_prefix@
SHARE_DIR=@datadir@/camstream
BIN_DIR=@bindir@

MOREDEFS=-DSHARE_DIR=\"$(SHARE_DIR)\"

# Flags and options
AFLAGS=-g
CFLAGS=@CFLAGS@ -I. -Idevices -Ivideo @DEFS@ $(MOREDEFS)
CXXFLAGS=$(CFLAGS)
LIBS=@LIBS@
LDFLAGS=@LDFLAGS@ -g

# 
SUBDIRS=gui codec devices video lib
SUBS	:=$(foreach sub,$(SUBDIRS), $(sub)/$(sub).a)

# Compile targets
MLIBS=-L@top_srcdir@/../lib/ccvt -lccvt

STREAMOBJS=\
	VideoOptions.o\
	CamWindow.o CamWindow.moc.o\
	WebCamViewer.o WebCamViewer.moc.o\
	CamStreamMainWindow.o CamStreamMainWindow.moc.o\
	CamStreamApp.o camstream.o

INFOOBJS=\
	caminfo.o

FTPOBJS=\
	ftpput.o ftpput.moc.o

PROGS=camstream caminfo ftpput

# 
.cc.o:
	$(CXX) $(CXXFLAGS) -c -o $@ $<

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

.S.o:
	$(CC) $(AFLAGS) -c -o $@ $<

%.moc.cc: %.h
	$(MOC) -o $@ $<


#


all:	subdirs $(PROGS)
.PHONY:	all

subdirs:	$(SUBDIRS)

$(SUBDIRS):
	$(MAKE) -C $@

.PHONY:	subdirs $(SUBDIRS)


docs:
	-rm ../docs/api/html/*
	doxygen ../docs/api/CamStream.dox

install:	all
	make -C icons install
	install --mode=0755 --directory $(BIN_DIR)
	install --strip camstream $(BIN_DIR)

# Default targets
clean:
	@for T in $(SUBDIRS); do make -C $$T $@; done
	rm -f DEADJOE $(PROGS) *.o *.a *~ *.moc.cc *.bak core 

distclean:	clean
	rm -f click*.*
	rm -rf .xvpics
	rm -f config.h config.cache config.log config.status
	rm -f Makefile 
	@for T in $(SUBDIRS); do make -C $$T $@; done
	rm -f icons/Makefile

dep:
	makedepend -- $(CXXFLAGS) *.cc
	@for T in $(SUBDIRS); do make -C $$T $@; done

# The programs
camstream:	$(STREAMOBJS) $(SUBS)
	$(CXX) -o $@ $(LDFLAGS) $(STREAMOBJS) $(SUBS) $(MLIBS) $(LIBS)

caminfo:	$(INFOOBJS) $(SUBS)
	$(CXX) -o $@ $(LDFLAGS) $(INFOOBJS) $(SUBS)  $(MLIBS) $(LIBS)

ftpput:		$(FTPOBJS) $(SUBS)
	$(CXX) -o $@ $(LDFLAGS) $(FTPOBJS) $(SUBS) $(MLIBS) $(LIBS)

