# SPDX-FileCopyrightText: 2024 Petros Koutsolampros
#
# SPDX-License-Identifier: GPL-3.0-only

# Set the C++ standard to C++17
CXX_STD = CXX17

BLDDIR = build-Release

# Make sure libraries are included so that they can refer to each other
PKG_CPPFLAGS = -I../src/libs -I../../inst/include/ -I..
PKG_LIBS = $(BLDDIR)/libalcyon_gensala.a

SOURCES = main.cpp \
          communicator.cpp \
          ShapeMap.cpp \
          ShapeGraph.cpp \
          AllLineMap.cpp \
          PointMap.cpp \
          convertInternal.cpp \
          convertExternal.cpp \
          axialAnalysis.cpp \
          segmentAnalysis.cpp \
          metagraphdata.cpp \
          isovist.cpp \
          allFewest.cpp \
          vga.cpp \
          agentAnalysis.cpp \
          link.cpp \
          RcppExports.cpp

# Obtain the object files in the build directory
OBJECTS=$(addprefix $(BLDDIR)/,$(SOURCES:.cpp=.o))

# Make the shared object
all: $(SHLIB)

# Make sure the build directory exists
$(BLDDIR):
	mkdir -p $@

# Build each object. This is necessary to override
# becasue otherwise .o files would end up in src/
$(BLDDIR)/%.o: %.cpp | $(BLDDIR)
	$(CXX) $(ALL_CPPFLAGS) $(ALL_OBJCXXFLAGS) -c $< -o $@

# Provide recipe to remove all objects
clean:
	@rm -f $(OBJECTS)
