################################################################################
#
# Makefile for GSEGrafix plotting program
#
# Copyright © 2008-2009 Spencer A. Buckner
# http://savannah.gnu.org/projects/gsegrafix
#
# This file is part of GSEGrafix, a scientific and engineering plotting program.
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#
################################################################################

all: gsegrafix gsegraf

################################################################################

CC = gcc -g -Wall -W

PREFIX     = /usr
BINDIR     = $(PREFIX)/bin
DATADIR    = $(PREFIX)/share
DOCDIR     = $(DATADIR)/doc
HELPDIR    = $(DATADIR)/gnome/help
PIXMAPSDIR = $(DATADIR)/pixmaps
VERSION    = 1.0.4

CFLAGS = \
   `pkg-config --cflags libgnomeui-2.0` \
   `pkg-config --cflags libgnomeprintui-2.2` \
   -DPREFIX=\""$(PREFIX)"\" \
   -DDATADIR=\""$(PREFIX)/share"\" \
   -DSYSCONFDIR=\""$(PREFIX)/etc"\" \
   -DLIBDIR=\""$(PREFIX)/lib"\"

LDFLAGS = \
   `pkg-config --libs libgnomeui-2.0` \
   `pkg-config --libs libgnomeprintui-2.2`

################################################################################

OBJECT_FILES_1 = Dialogs.o GSEGrafix.o HelpMenu.o

gsegrafix: $(OBJECT_FILES_1)
	$(LINK.c) $(OBJECT_FILES_1) -o gsegrafix

################################################################################

OBJECT_FILES_2 = \
   AutoScale.o AxesEqual.o AxisLimits.o CheckParamData.o Clip.o ColorPlot2d.o \
   ColorPlot3d.o ContourPlot2d.o ContourPlot3d.o CreateMenuBar.o DataMinMax.o \
   DataMinMax3d.o Dialogs.o DrawAxisLabels.o DrawContours3d.o DrawDateTime.o \
   DrawGraph.o DrawGrid.o DrawGrid2d.o DrawGridLog.o DrawGrid3d.o DrawImage.o \
   DrawLabels3d.o DrawLegend.o DrawLines.o DrawSymbols.o DrawText.o \
   DrawTickLabels.o DrawTickLabels2d.o DrawTickLabelsLog.o DrawTickMarks.o \
   DrawTickMarks3d.o EditMenu.o EventHandler.o FileMenu.o FileRead.o \
   FileRead3d.o GetAxisLabelPixbufs.o GetWindowCoords.o GSEGraf.o HelpMenu.o \
   Histogram.o InitializePlot.o InitializeVariables.o Initialize3d.o \
   MeshPlot3d.o Misc.o PlotData2d.o PlotData3d.o PlotEllipses.o PlotInterp3d.o \
   PlotLines.o PlotNormal3d.o PlotPoints3d.o PlotRectangles.o PlotSymbols.o \
   PolarPlot.o ReadParamFile.o ViewMenu.o ZoomIn.o ZoomOut.o

gsegraf: $(OBJECT_FILES_2)
	$(LINK.c) $(OBJECT_FILES_2) -o gsegraf

################################################################################

AutoScale.o:           AutoScale.c gsegraf.h
AxesEqual.o:           AxesEqual.c gsegraf.h
AxisLimits.o:          AxisLimits.c gsegraf.h
CheckParamData.o:      CheckParamData.c gsegraf.h
Clip.o:                Clip.c gsegraf.h
ColorPlot2d.o:         ColorPlot2d.c gsegraf.h
ColorPlot3d.o:         ColorPlot3d.c gsegraf.h
ContourPlot2d.o:       ContourPlot2d.c gsegraf.h
ContourPlot3d.o:       ContourPlot3d.c gsegraf.h
CreateMenuBar.o:       CreateMenuBar.c gsegraf.h
DataMinMax.o:          DataMinMax.c gsegraf.h
DataMinMax3d.o:        DataMinMax3d.c gsegraf.h
Dialogs.o:             Dialogs.c
DrawAxisLabels.o:      DrawAxisLabels.c gsegraf.h
DrawContours3d.o:      DrawContours3d.c gsegraf.h
DrawDateTime.o:        DrawDateTime.c gsegraf.h
DrawGraph.o:           DrawGraph.c gsegraf.h
DrawGrid.o:            DrawGrid.c gsegraf.h
DrawGrid2d.o:          DrawGrid2d.c gsegraf.h
DrawGridLog.o:         DrawGridLog.c gsegraf.h
DrawGrid3d.o:          DrawGrid3d.c gsegraf.h
DrawImage.o:           DrawImage.c gsegraf.h
DrawLabels3d.o:        DrawLabels3d.c gsegraf.h
DrawLegend.o:          DrawLegend.c gsegraf.h
DrawLines.o:           DrawLines.c gsegraf.h
DrawSymbols.o:         DrawSymbols.c gsegraf.h
DrawText.o:            DrawText.c gsegraf.h
DrawTickLabels.o:      DrawTickLabels.c gsegraf.h
DrawTickLabels2d.o:    DrawTickLabels2d.c gsegraf.h
DrawTickLabelsLog.o:   DrawTickLabelsLog.c gsegraf.h
DrawTickMarks.o:       DrawTickMarks.c gsegraf.h
DrawTickMarks3d.o:     DrawTickMarks3d.c gsegraf.h
EditMenu.o:            EditMenu.c gsegraf.h
EventHandler.o:        EventHandler.c gsegraf.h
FileMenu.o:            FileMenu.c gsegraf.h
FileRead.o:            FileRead.c gsegraf.h
FileRead3d.o:          FileRead3d.c gsegraf.h
GetAxisLabelPixbufs.o: GetAxisLabelPixbufs.c gsegraf.h
GetWindowCoords.o:     GetWindowCoords.c gsegraf.h
GSEGraf.o:             GSEGraf.c gsegraf.h
GSEGrafix.o:           GSEGrafix.c
HelpMenu.o:            HelpMenu.c
Histogram.o:           Histogram.c gsegraf.h
InitializePlot.o:      InitializePlot.c gsegraf.h
InitializeVariables.o: InitializeVariables.c gsegraf.h
Initialize3d.o:        Initialize3d.c gsegraf.h
MeshPlot3d.o:          MeshPlot3d.c gsegraf.h
Misc.o:                Misc.c
PlotData2d.o:          PlotData2d.c gsegraf.h
PlotData3d.o:          PlotData3d.c gsegraf.h
PlotEllipses.o:        PlotEllipses.c gsegraf.h
PlotInterp3d.o:        PlotInterp3d.c gsegraf.h
PlotLines.o:           PlotLines.c gsegraf.h
PlotNormal3d.o:        PlotNormal3d.c gsegraf.h
PlotPoints3d.o:        PlotPoints3d.c gsegraf.h
PlotRectangles.o:      PlotRectangles.c gsegraf.h
PlotSymbols.o:         PlotSymbols.c gsegraf.h
PolarPlot.o:           PolarPlot.c gsegraf.h
ReadParamFile.o:       ReadParamFile.c gsegraf.h
ViewMenu.o:            ViewMenu.c gsegraf.h
ZoomIn.o:              ZoomIn.c gsegraf.h
ZoomOut.o:             ZoomOut.c gsegraf.h

################################################################################

SOURCE_FILES = \
   AutoScale.c AxesEqual.c AxisLimits.c CheckParamData.c Clip.c ColorPlot2d.c \
   ColorPlot3d.c ContourPlot2d.c ContourPlot3d.c CreateMenuBar.c DataMinMax.c \
   DataMinMax3d.c Dialogs.c DrawAxisLabels.c DrawContours3d.c DrawDateTime.c \
   DrawGraph.c DrawGrid.c DrawGrid2d.c DrawGridLog.c DrawGrid3d.c DrawImage.c \
   DrawLabels3d.c DrawLegend.c DrawLines.c DrawSymbols.c DrawText.c \
   DrawTickLabels.c DrawTickLabels2d.c DrawTickLabelsLog.c DrawTickMarks.c \
   DrawTickMarks3d.c EditMenu.c EventHandler.c FileMenu.c FileRead.c \
   FileRead3d.c GetAxisLabelPixbufs.c GetWindowCoords.c GSEGraf.c GSEGrafix.c \
   HelpMenu.c Histogram.c InitializePlot.c InitializeVariables.c \
   Initialize3d.c MeshPlot3d.c Misc.c PlotData2d.c PlotData3d.c PlotEllipses.c \
   PlotInterp3d.c PlotLines.c PlotNormal3d.c PlotPoints3d.c PlotRectangles.c \
   PlotSymbols.c PolarPlot.c ReadParamFile.c ViewMenu.c ZoomIn.c ZoomOut.c

OBJECT_FILES = \
   AutoScale.o AxesEqual.o AxisLimits.o CheckParamData.o Clip.o ColorPlot2d.o \
   ColorPlot3d.o ContourPlot2d.o ContourPlot3d.o CreateMenuBar.o DataMinMax.o \
   DataMinMax3d.o Dialogs.o DrawAxisLabels.o DrawContours3d.o DrawDateTime.o \
   DrawGraph.o DrawGrid.o DrawGrid2d.o DrawGridLog.o DrawGrid3d.o DrawImage.o \
   DrawLabels3d.o DrawLegend.o DrawLines.o DrawSymbols.o DrawText.o \
   DrawTickLabels.o DrawTickLabels2d.o DrawTickLabelsLog.o DrawTickMarks.o \
   DrawTickMarks3d.o EditMenu.o EventHandler.o FileMenu.o FileRead.o \
   FileRead3d.o GetAxisLabelPixbufs.o GetWindowCoords.o GSEGraf.o GSEGrafix.o \
   HelpMenu.o Histogram.o InitializePlot.o InitializeVariables.o \
   Initialize3d.o MeshPlot3d.o Misc.o PlotData2d.o PlotData3d.o PlotEllipses.o \
   PlotInterp3d.o PlotLines.o PlotNormal3d.o PlotPoints3d.o PlotRectangles.o \
   PlotSymbols.o PolarPlot.o ReadParamFile.o ViewMenu.o ZoomIn.o ZoomOut.o

HEADER_FILES = gsegraf.h

################################################################################

DESKTOP_FILES = gsegrafix.desktop

DOC_FILES = \
   README \
   INSTALL

HELP_FILES_1 = \
   gsegrafix.xhtml \
   gsegrafix.css

HELP_FILES_2 = \
   help_files/keyword_summary.pdf \
   help_files/gsegraf_plot.txt \
   help_files/gsegraf_C_plot.txt \
   help_files/data_save.txt \
   help_files/data_C_save.txt

HELP_FIGURE_FILES = \
   figures/dipole.png \
   figures/gauss.png \
   figures/gsegrafix.png \
   figures/gsegrafix-logo.png \
   figures/loghelix.png \
   figures/loglog.png \
   figures/logzcolor2d.png \
   figures/logzcontour2d.png \
   figures/logzcontour3d.png \
   figures/mandelbrot.png \
   figures/orbit.png \
   figures/sinc.png \
   figures/sinc3d.png \
   figures/symbols.png \
   figures/window.png

LICENSE_FILES = \
   COPYING \
   COPYING-DOCS

LOGO_FILES = figures/gsegrafix-logo.png

################################################################################

.PHONY: install
install:
	-mkdir -p $(BINDIR)
	-mkdir -p $(DOCDIR)/gsegrafix-$(VERSION)
	-mkdir -p $(HELPDIR)/gsegrafix/C/help_files
	-mkdir -p $(HELPDIR)/gsegrafix/C/figures
	-mkdir -p $(PIXMAPSDIR)
	cp -p gsegrafix gsegraf $(BINDIR)
	cp -p $(DOC_FILES) $(DOCDIR)/gsegrafix-$(VERSION)
	cp -p $(HELP_FILES_1) $(LICENSE_FILES) $(HELPDIR)/gsegrafix/C
	cp -p $(HELP_FILES_2) $(HELPDIR)/gsegrafix/C/help_files
	cp -p $(HELP_FIGURE_FILES) $(HELPDIR)/gsegrafix/C/figures
	cp -p $(LOGO_FILES) $(PIXMAPSDIR)
	cp -p $(DESKTOP_FILES) $(DATADIR)/applications

################################################################################

.PHONY: uninstall
uninstall:
	-rm $(BINDIR)/gsegrafix $(BINDIR)/gsegraf
	-rm -r $(DOCDIR)/gsegrafix-$(VERSION)
	-rm -r $(HELPDIR)/gsegrafix
	-rm $(PIXMAPSDIR)/gsegrafix-logo.png
	-rm $(DATADIR)/applications/gsegrafix.desktop

################################################################################

.PHONY: clean
clean:
	-rm gsegrafix gsegraf $(OBJECT_FILES)

################################################################################

