#
# Simple Graphics Framework (SGF) - configuration file for GNU make
#
# Copyright 2023 Arnold Beiland
#
# Simple Graphics Framework 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 (look for a file named COPYING in the top directory). If not, see
# <https://www.gnu.org/licenses/>.
#

CXXFLAGS=-g -Wall -Wextra --std=c++17 --pedantic
# add -DWIN32 to CXXFLAGS for builds on Windows

FLTK_CXXFLAGS=`fltk-config --cxxflags`
LDFLAGS=`fltk-config --ldflags` -lm

EXAMPLES=$(patsubst %.cpp,%,$(wildcard examples/*.cpp))

.PHONY: all
all: $(EXAMPLES)

examples/%: examples/%.o main.o
	g++ main.o $< $(LDFLAGS) -o $@

examples/%.o: examples/%.c sgf.h
	g++ -c $< $(CXXFLAGS) -o $@

main.o: main.cpp sgf.h
	g++ -c main.cpp $(CXXFLAGS) $(FLTK_CXXFLAGS)

compile_commands:
	make clean
	bear -- make all

.PHONY: clean
clean:
	rm -f $(EXAMPLES) *.o examples/*.o
