TOPDIR = ../..
COMMAND = pmchart
PROJECT = $(COMMAND).pro
include $(TOPDIR)/src/include/builddefs

WRAPPER = $(COMMAND).sh
QRCFILE = $(COMMAND).qrc
RCFILE  = $(COMMAND).rc
ICOFILE = $(COMMAND).ico
ICNFILE = $(COMMAND).icns
XMLFILE = $(COMMAND).info
DESKTOP = $(COMMAND).desktop
UIFILES = $(shell echo *.ui)
HEADERS = aboutdialog.h chartdialog.h exportdialog.h hostdialog.h \
	  infodialog.h pmchart.h openviewdialog.h saveviewdialog.h \
	  recorddialog.h seealsodialog.h searchdialog.h settingsdialog.h \
	  samplesdialog.h tabdialog.h tab.h tabwidget.h \
	  chart.h console.h main.h namespace.h \
	  colorbutton.h colorscheme.h qcolorpicker.h \
	  fileiconprovider.h statusbar.h \
	  timeaxis.h timebutton.h timecontrol.h \
	  groupcontrol.h gadget.h sampling.h tracing.h
SOURCES = $(HEADERS:.h=.cpp) view.cpp
CONFFILES = $(PROJECT)
LSRCFILES = $(PROJECT).in $(QRCFILE) $(RCFILE) $(UIFILES) $(HEADERS) $(SOURCES) \
	  $(DESKTOP) $(WRAPPER).IN $(XMLFILE).in
LDIRT = $(COMMAND) $(ICONLINKS) $(WRAPPER) $(XMLFILE)

ICONLINKS = aboutpcp.png aboutpmchart.png pmchart.png pmtime.png \
	    document-close.png document-new.png document-open.png \
	    document-print.png document-export.png document-properties.png \
	    document-save.png emblem-system.png pmtime-close.png \
	    edit-clear.png settings.png camera-video-close.png \
	    archive.png computer.png camera-video.png system-search.png \
	    process-stop.png go-jump.png go-previous.png toolusers.png \
	    tab-close.png tab-new.png tab-edit.png zoom-in.png zoom-out.png \
	    help-contents.png help-browser.png whatsthis.png \
	    filearchive.png filefolder.png filegeneric.png filehtml.png \
	    fileimage.png filepackage.png filespreadsheet.png fileview.png \
	    filewordprocessor.png filefolio.png folio.png view.png logfile.png \
	    play_live.png stop_live.png play_record.png stop_record.png \
	    play_archive.png stop_archive.png back_archive.png \
	    stepfwd_archive.png stepback_archive.png fastfwd_archive.png \
	    fastback_archive.png \
	    $(ICNFILE) $(ICOFILE)

SUBDIRS = views

default: iconlinks wrappers
	$(SUBDIRS_MAKERULE)
	$(QTMAKE)
	$(LNMAKE)

include $(BUILDRULES)

ifeq ($(WINDOW),mac)
PKG_MAC_DIR = /Applications/$(COMMAND).app/Contents
wrappers: $(WRAPPER)
else
wrappers:
endif

$(WRAPPER): $(WRAPPER).IN
	$(SED) -e '/\# .*/b' -e 's;PKG_MAC_DIR;$(PKG_MAC_DIR);g' < $< > $@

install: default
	$(SUBDIRS_MAKERULE)
ifeq ($(WINDOW),win)
	$(INSTALL) -m 755 $(BINARY) $(PKG_BIN_DIR)/$(COMMAND)
endif
ifeq ($(WINDOW),x11)
	$(INSTALL) -m 755 $(BINARY) $(PKG_BIN_DIR)/$(COMMAND)
	$(INSTALL) -m 755 -d $(PKG_DESKTOP_DIR)
	$(INSTALL) -m 644 $(DESKTOP) $(PKG_DESKTOP_DIR)/$(DESKTOP)
endif
ifeq ($(WINDOW),mac)
	$(INSTALL) -m 755 $(WRAPPER) $(PKG_BIN_DIR)/$(COMMAND)
	$(call INSTALL_DIRECTORY_HIERARCHY,$(PKG_MAC_DIR),/Applications)
	$(INSTALL) -m 644 $(MACBUILD)/PkgInfo $(PKG_MAC_DIR)/PkgInfo
	$(INSTALL) -m 644 $(XMLFILE) $(PKG_MAC_DIR)/Info.plist
	$(INSTALL) -m 755 -d $(PKG_MAC_DIR)/MacOS
	$(call INSTALL_QT_FRAMEWORKS,$(BINARY))
	$(INSTALL) -m 755 $(BINARY) $(PKG_MAC_DIR)/MacOS/$(COMMAND)
	rm $(BINARY)
	$(INSTALL) -m 755 -d $(PKG_MAC_DIR)/Resources
	$(INSTALL) -m 644 $(ICNFILE) $(PKG_MAC_DIR)/Resources/$(ICNFILE)
	$(call INSTALL_QT_RESOURCES,$(PKG_MAC_DIR)/Resources)
endif
