# nmake Makefile for MSVC (Windows)
# Builds src/main.cpp against installed OSRM, Boost.
# Output executable goes into bin/

# Compiler
CXX = cl

# Include directories (adjust if your paths differ)
INCLUDES = /I"C:\Users\TRIZ\clones\osrm-backend\include" ^
           /I"C:\OSRM\include" ^
           /I"C:\Users\TRIZ\clones\osrm-backend\vcpkg_installed\x64-windows\include" ^
           /I"C:\Users\TRIZ\clones\osrm-backend\third_party\fmt\include"

# Libraries (full paths to .lib files)
LIBS = "C:\OSRM\lib\osrm.lib" "C:\Users\TRIZ\clones\osrm-backend\vcpkg_installed\x64-windows\lib\*.lib" AdvAPI32.lib

# Compiler flags
CXXFLAGS = /EHsc /MD /O3 /nologo /utf-8 /std:c++17 /DFMT_HEADER_ONLY

LFLAGS = /nologo

# Source files
SRCS = src\main.cpp kdtree\kdtree.c tomlcpp\tomlcpp.cpp tomlcpp\toml.c
OBJS = $(SRCS:.cpp=.obj)

# Output directory and target
OUTDIR = bin
TARGET = $(OUTDIR)\trackengine.exe

# Default target
all: $(TARGET) run

# Link object files into executable
$(TARGET): $(OBJS)
    if not exist $(OUTDIR) mkdir $(OUTDIR)
    $(CXX) $(OBJS) $(LIBS) $(LFLAGS) /Fe$(TARGET)

# Compile .cpp into .obj
.cpp.obj:
    $(CXX) $(CXXFLAGS) $(INCLUDES) /c $< /Fo$@

run:
	@echo Running $(TARGET)...
	type C:\Users\TRIZ\clones\tracluster\gps_260205_070000.csv | $(TARGET)

# Clean
clean:
    del /Q $(OBJS) 2>nul
    del /Q $(TARGET) 2>nul
