# Hey Emacs, this is a -*- makefile -*-
#
#   Copyright (C) 2004-2012 Pascal Brisset, Antoine Drouin
#
# This file is part of paparazzi.
#
# paparazzi 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, or (at your option)
# any later version.
#
# paparazzi 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 paparazzi; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

# The default is to produce a quiet echo of compilation commands
# Launch with "make Q=''" to get full echo
Q=@

include ../Makefile.ocaml

INCLUDES= -I $(LIBPPRZDIR)
PKGCOMMON=unix,str,lablgtk2,ivy,xml-light

PAPARAZZICENTERCMO = gtk_pc.cmo gtk_process.cmo pc_common.cmo pc_aircraft.cmo pc_control_panel.cmo paparazzicenter.cmo

# default directory for temporary files
TMPDIR ?= /tmp

all: paparazzicenter

paparazzicenter : $(LIBPPRZCMA) $(XLIBPPRZCMA) $(PAPARAZZICENTERCMO)
	@echo OL $@
	$(Q)$(OCAMLFIND) $(OCAMLC) $(INCLUDES) -o $@ -package $(PKGCOMMON) -linkpkg lablglade.cma gtkInit.cmo lablgnomeui.cma $(OCAMLDLL) $(OCAMLXDLL) $^

gtk_pc.ml : paparazzicenter.glade
	@echo GLADE $@
	$(Q)grep -v invisible_char $< > $(TMPDIR)/$<
	$(Q)lablgladecc2 -hide-default -root window $(TMPDIR)/$< > $@
	$(Q)rm $(TMPDIR)/$<

gtk_process.ml : paparazzicenter.glade
	@echo GLADE $@
	$(Q)grep -v invisible_char $< > $(TMPDIR)/$<
	$(Q)lablgladecc2 -hide-default -root hbox_program $(TMPDIR)/$< | grep -B 1000000 "  end" > $@
	$(Q)rm $(TMPDIR)/$<

%.cmo : %.ml
	@echo OC $<
	$(Q)$(OCAMLFIND) $(OCAMLC) $(INCLUDES) -c -package $(PKGCOMMON) $<

%.cmi : %.mli
	@echo OC $<
	$(Q)$(OCAMLFIND) $(OCAMLC) $(INCLUDES) -package $(PKGCOMMON) $<

pc_common.cmo: gtk_process.cmo

paparazzicenter.cmo : gtk_pc.cmo

clean:
	$(Q)rm -f *.cm* gtk_pc.ml gtk_process.ml .depend paparazzicenter

.PHONY: all clean

#
# Dependencies
#

.depend: Makefile
	$(OCAMLDEP) -I $(LIBPPRZDIR) *.ml* > .depend

ifneq ($(MAKECMDGOALS),clean)
-include .depend
endif
