################################################################################
#
# Makefile for GSEGrafix plotting program
#
# Copyright © 2008 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

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 ColorPlot.o \
   ContourPlot.o CreateMenuBar.o DataMinMax.o DataMinMax3d.o Dialogs.o \
   DrawAxisLabels.o DrawContours3d.o DrawDateTime.o DrawGraph.o DrawGrid.o \
   DrawGridLog.o DrawGrid3d.o DrawImage.o DrawLabels3d.o DrawLegend.o \
   DrawLines.o DrawSymbols.o DrawText.o DrawTickLabels.o DrawTickLabelsLog.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 Misc.o \
   PlotContours3d.o PlotData.o PlotData3d.o PlotInterp3d.o PlotLines.o \
   PlotMesh3d.o PlotNormal3d.o PlotPoints3d.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
ColorPlot.o:           ColorPlot.c gsegraf.h
ContourPlot.o:         ContourPlot.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
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
DrawTickLabelsLog.o:   DrawTickLabelsLog.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
Misc.o:                Misc.c
PlotContours3d.o:      PlotContours3d.c gsegraf.h
PlotData.o:            PlotData.c gsegraf.h
PlotData3d.o:          PlotData3d.c gsegraf.h
PlotInterp3d.o:        PlotInterp3d.c gsegraf.h
PlotLines.o:           PlotLines.c gsegraf.h
PlotMesh3d.o:          PlotMesh3d.c gsegraf.h
PlotNormal3d.o:        PlotNormal3d.c gsegraf.h
PlotPoints3d.o:        PlotPoints3d.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 ColorPlot.c \
   ContourPlot.c CreateMenuBar.c DataMinMax.c DataMinMax3d.c Dialogs.c \
   DrawAxisLabels.c DrawContours3d.c DrawDateTime.c DrawGraph.c DrawGrid.c \
   DrawGridLog.c DrawGrid3d.c DrawImage.c DrawLabels3d.c DrawLegend.c \
   DrawLines.c DrawSymbols.c DrawText.c DrawTickLabels.c DrawTickLabelsLog.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 Misc.c PlotContours3d.c PlotData.c PlotData3d.c \
   PlotInterp3d.c PlotLines.c PlotMesh3d.c PlotNormal3d.c PlotPoints3d.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 ColorPlot.o \
   ContourPlot.o CreateMenuBar.o DataMinMax.o DataMinMax3d.o Dialogs.o \
   DrawAxisLabels.o DrawContours3d.o DrawDateTime.o DrawGraph.o DrawGrid.o \
   DrawGridLog.o DrawGrid3d.o DrawImage.o DrawLabels3d.o DrawLegend.o \
   DrawLines.o DrawSymbols.o DrawText.o DrawTickLabels.o DrawTickLabelsLog.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 Misc.o PlotContours3d.o PlotData.o PlotData3d.o \
   PlotInterp3d.o PlotLines.o PlotMesh3d.o PlotNormal3d.o PlotPoints3d.o \
   PlotSymbols.o PolarPlot.o ReadParamFile.o ViewMenu.o ZoomIn.o ZoomOut.o

HEADER_FILES = gsegraf.h

DOC_FILES = \
   help_files/README \
   help_files/INSTALL

HELP_FILES = \
   help_files/gsegrafix.xhtml \
   help_files/gsegrafix.css \
   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 = \
   help_files/figures/dipole.png \
   help_files/figures/gauss.png \
   help_files/figures/gsegrafix.png \
   help_files/figures/loghelix.png \
   help_files/figures/loglog.png \
   help_files/figures/logz.png \
   help_files/figures/logzcolor.png \
   help_files/figures/logzcontour.png \
   help_files/figures/mandelbrot.png \
   help_files/figures/orbit.png \
   help_files/figures/sinc3d.png \
   help_files/figures/sinc.png \
   help_files/figures/window.png

LICENSE_FILES = \
   help_files/COPYING \
   help_files/COPYING-DOCS

LOGO_FILES = help_files/figures/gsegrafix-logo.png

DESKTOP_FILES = gsegrafix.desktop

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

.PHONY: dist
dist:
	-mkdir -p gsegrafix-1.0.1/help_files/figures
	cp -p $(SOURCE_FILES) $(HEADER_FILES) $(LICENSE_FILES) $(DESKTOP_FILES) Makefile gsegrafix-1.0.1
	cp -p $(DOC_FILES) gsegrafix-1.0.1/help_files
	cp -p $(HELP_FILES) gsegrafix-1.0.1/help_files
	cp -p $(HELP_FIGURE_FILES) $(LOGO_FILES) gsegrafix-1.0.1/help_files/figures
	tar cvzf gsegrafix-1.0.1.tar.gz gsegrafix-1.0.1
	touch dist

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

.PHONY: install
install:
	-mkdir -p $(BINDIR)
	-mkdir -p $(DOCDIR)/gsegrafix-1.0.1
	-mkdir -p $(HELPDIR)/gsegrafix/C/figures
	-mkdir -p $(PIXMAPSDIR)
	cp -p gsegrafix gsegraf $(BINDIR)
	cp -p $(DOC_FILES) $(DOCDIR)/gsegrafix-1.0.1
	cp -p $(HELP_FILES) $(LICENSE_FILES) $(HELPDIR)/gsegrafix/C
	cp -p $(HELP_FIGURE_FILES) $(HELPDIR)/gsegrafix/C/figures
	cp -p $(LOGO_FILES) $(PIXMAPSDIR)
	cp -p gsegrafix.desktop $(DATADIR)/applications

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

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

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

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

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

