# Makefile for GUI elements, mostly dialogs

CC=@CC@
CXX=@CXX@
MOC=@MOC@
UIC=@UIC@

AFLAGS=-g
CFLAGS=@CFLAGS@ -I. -I.. -I../devices -I../video @DEFS@
CXXFLAGS=$(CFLAGS)

# Static and generated object files
OBJS   := $(patsubst %.ui, %.o,     $(wildcard *.ui))
MOBJS  := $(patsubst %.ui, %.moc.o, $(wildcard *.ui))
HFILES := $(patsubst %.ui, %.h,     $(wildcard *.ui))
GENCC  := $(patsubst %.ui, %.cc,    $(wildcard *.ui))
# Non-generated source-code
NONGEN := $(patsubst %.cc, %.o,     $(wildcard *.cc))
MOBJS  += $(patsubst %.h,  %.moc.o, $(wildcard *.h))

	
# Target:
all:	gui.a

# Rule for C++ files
.cc.o:
	$(CXX) $(CXXFLAGS) -c -o $@ $<

# The following rules will perform these transformations:
#  .ui      -> .h
#  .ui + .h -> .cc
#  .h       -> .moc.cc
# 
# The .cc and .moc.cc files are then compiled as normal C++ files.

# Make normalle removes all intermediate generated files, however,
# we do like to preserver the .h files, hence this rule.
.SECONDARY:	$(HFILES)

%.h:	%.ui
	$(UIC) -o $@ $<

%.cc:	%.ui %.h
	$(UIC) -o $@ -i $(subst .cc,.h,$@) $<

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



gui.a:	$(OBJS) $(MOBJS) $(NONGEN)
	ar rcs $@ $(OBJS) $(MOBJS) $(NONGEN)

# Default targets
clean:
	rm -f *.o *.a *.moc.cc *.bak *~ core $(HFILES) $(GENCC)

distclean:	clean
	rm -f config.h config.cache config.log config.status
	rm -f DEADJOE Makefile

dep:
	makedepend -- $(CXXFLAGS) *.cc



