# makefile.in -- makefile for gwaves source directory.
# Copyright (C) 2025 Gerardo Ballabio
#
# 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/>.

prefix = ${DESTDIR}@prefix@

CXX = @CXX@
CXXFLAGS += @CXXFLAGS@
CPPFLAGS += @CPPFLAGS@
LDFLAGS += @LDFLAGS@
PKG_CONFIG = @PKG_CONFIG@
GTKMM_INCL = `${PKG_CONFIG} --cflags gtkmm-3.0 epoxy`
GTKMM_LIB = `${PKG_CONFIG} --libs gtkmm-3.0 epoxy`

AC = makefile
BAK = *~

EXE = gwaves gplot
OBJS = area.o frame.o grid.o main.o orbital.o sidebar.o wavefunction.o
OBJS_P = area.o frame.o grid.o plot.o sidebar.o

.SUFFIXES : .cc .o

.cc.o :
	${CXX} ${CXXFLAGS} -c $< ${GTKMM_INCL}

default: all
all: ${EXE}
gwaves : ${OBJS}
	${CXX} ${CXXFLAGS} ${OBJS} -o $@ ${GTKMM_LIB}
gplot : ${OBJS_P}
	${CXX} ${CXXFLAGS} ${OBJS_P} -o $@ ${GTKMM_LIB}

# other targets
clean :
	- rm -f ${OBJS} ${OBJS_P} ${EXE} ${BAK}
distclean : clean
	- rm -rf ${AC}

install : ${EXE}
	mkdir -p ${prefix}/bin
	cp ${EXE} ${prefix}/bin
uninstall :
	- cd ${prefix}/bin && rm -f ${EXE}

# dependencies
area.o : area.h frame.h grid.h
frame.o : frame.h
grid.o : grid.h
main.o : area.h frame.h grid.h main.h orbital.h sidebar.h wavefunction.h
orbital.o : area.h frame.h grid.h orbital.h wavefunction.h
plot.o : area.h frame.h grid.h plot.h sidebar.h
sidebar.o : sidebar.h
wavefunction.o : wavefunction.h
