# Generated by configure — do not edit
# cgvR: compile Datoviz sources directly + cglm + glfw + Vulkan

DVZ_INC = ../@DVZ_INC_DIR@

PKG_CFLAGS = -I$(DVZ_INC) -I$(DVZ_INC)/datoviz -I. -Idatoviz -Idatoviz/scene -Idatoviz/imgui \
    -DHAS_GLFW=1 @OS_DEFINES@ @OS_EXTRA_CFLAGS@ @VULKAN_CFLAGS@ @GLFW_CFLAGS@ @CGLM_CFLAGS@ -include cgv_r_compat.h

PKG_CXXFLAGS = -I$(DVZ_INC) -I$(DVZ_INC)/datoviz -I. -Idatoviz -Idatoviz/scene -Idatoviz/imgui \
    -DHAS_GLFW=1 @OS_DEFINES@ @OS_EXTRA_CFLAGS@ @VULKAN_CFLAGS@ @GLFW_CFLAGS@ @CGLM_CFLAGS@ -include cgv_r_compat.h

PKG_LIBS = \
    @GLFW_LIBS@ \
    @VULKAN_LIBS@ \
    @OS_EXTRA_LIBS@

# cgvR objects
CGVR_OBJECTS = init.o cgv_viewer.o cgv_graph.o cgv_camera.o visibility.o cgv_r_io.o cgv_layout_bh.o cgv_record.o

# cgvR sources include R headers (R.h, Rinternals.h) which carry
# format(printf,...) attributes. Our macro redirections would mangle
# those attribute declarations, so strip -include cgv_r_compat.h for
# these files. They already use R APIs directly (Rprintf, Rf_error).
CGVR_NO_COMPAT_CFLAGS = -I$(DVZ_INC) -I$(DVZ_INC)/datoviz -I. -Idatoviz -Idatoviz/scene -Idatoviz/imgui -DHAS_GLFW=1 @OS_DEFINES@ @OS_EXTRA_CFLAGS@ @VULKAN_CFLAGS@ @GLFW_CFLAGS@ @CGLM_CFLAGS@
cgv_r_io.o:   PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)
init.o:       PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)
cgv_viewer.o: PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)
cgv_graph.o:  PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)
cgv_camera.o: PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)
visibility.o: PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)
cgv_layout_bh.o: PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)
cgv_record.o: PKG_CFLAGS = $(CGVR_NO_COMPAT_CFLAGS)

# ImGui (C++) defines its own format-attribute macros (IM_FMTARGS) that wrap
# 'printf'. Our -include cgv_r_compat.h rewrites 'printf' to 'cgv_printf' even
# inside those attributes, so GCC complains about an unknown format function.
# ImGui doesn't write to stdout/stderr at runtime, so it does not need the
# R-safe I/O redirection — strip the -include for these objects.
CGVR_NO_COMPAT_CXXFLAGS = -I$(DVZ_INC) -I$(DVZ_INC)/datoviz -I. -Idatoviz -Idatoviz/scene -Idatoviz/imgui -DHAS_GLFW=1 @OS_DEFINES@ @OS_EXTRA_CFLAGS@ @VULKAN_CFLAGS@ @GLFW_CFLAGS@ @CGLM_CFLAGS@ -DIMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS -DIMGUI_DISABLE_FILE_FUNCTIONS '-DIMGUI_DEBUG_PRINTF(...)=((void)0)' '-DIM_ASSERT(x)=((void)0)'

# Datoviz core objects
DVZ_CORE_OBJECTS = \
    datoviz/alloc.o datoviz/app.o datoviz/_atomic.o datoviz/board.o \
    datoviz/canvas.o datoviz/client.o datoviz/client_input.o \
    datoviz/context.o datoviz/datalloc.o datoviz/_error.o \
    datoviz/external.o datoviz/fifo.o datoviz/fileio.o datoviz/fps.o \
    datoviz/gui.o datoviz/host.o datoviz/input.o datoviz/keyboard.o \
    datoviz/_list.o datoviz/log.o datoviz/loop.o datoviz/_map.o \
    datoviz/_math.o datoviz/mouse.o datoviz/_mutex.o datoviz/pipe.o \
    datoviz/pipelib.o datoviz/presenter.o datoviz/_prng.o \
    datoviz/recorder.o datoviz/renderer.o datoviz/request.o \
    datoviz/resources.o datoviz/server.o datoviz/shader.o \
    datoviz/surface.o datoviz/_thread.o datoviz/timer.o \
    datoviz/transfers.o datoviz/_version.o datoviz/vklite.o \
    datoviz/window.o datoviz/workspace.o datoviz/wrap.o

# Datoviz scene objects
DVZ_SCENE_OBJECTS = \
    datoviz/scene/animation.o datoviz/scene/arcball.o \
    datoviz/scene/array.o datoviz/scene/axes.o datoviz/scene/axis.o \
    datoviz/scene/baker.o datoviz/scene/box.o datoviz/scene/camera.o \
    datoviz/scene/colorbar.o datoviz/scene/colormaps.o \
    datoviz/scene/dual.o datoviz/scene/fly.o datoviz/scene/graphics.o \
    datoviz/scene/grid.o datoviz/scene/mvp.o datoviz/scene/ortho.o \
    datoviz/scene/panzoom.o datoviz/scene/params.o datoviz/scene/ref.o \
    datoviz/scene/scene.o datoviz/scene/texture.o datoviz/scene/ticks.o \
    datoviz/scene/transform.o datoviz/scene/viewport.o \
    datoviz/scene/viewset.o datoviz/scene/visual.o \
    datoviz/scene/font.o datoviz/scene/atlas.o datoviz/scene/sdf.o \
    datoviz/scene/visuals/point.o datoviz/scene/visuals/segment.o \
    datoviz/scene/visuals/glyph.o datoviz/scene/visuals/basic.o \
    datoviz/scene/visuals/image.o \
    datoviz/vk_mem_alloc.o datoviz/fpng.o \
    datoviz/_textures.o datoviz/_shaders.o datoviz/_fonts.o

# ImGui objects
DVZ_IMGUI_OBJECTS = \
    datoviz/imgui/imgui.o \
    datoviz/imgui/imgui_draw.o \
    datoviz/imgui/imgui_tables.o datoviz/imgui/imgui_widgets.o \
    datoviz/imgui/backends/imgui_impl_glfw.o \
    datoviz/imgui/backends/imgui_impl_vulkan.o

B64_OBJECTS = b64/encode.o b64/buffer.o

OBJECTS = $(CGVR_OBJECTS) $(DVZ_CORE_OBJECTS) $(DVZ_SCENE_OBJECTS) $(DVZ_IMGUI_OBJECTS) $(B64_OBJECTS)

$(SHLIB): $(OBJECTS)

datoviz/fpng.o: PKG_CXXFLAGS += @FPNG_CFLAGS@
b64/encode.o:   PKG_CFLAGS += -I$(DVZ_INC)/b64
b64/buffer.o:   PKG_CFLAGS += -I$(DVZ_INC)/b64

datoviz/imgui/imgui.o:                       PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)
datoviz/imgui/imgui_draw.o:                  PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)
datoviz/imgui/imgui_tables.o:                PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)
datoviz/imgui/imgui_widgets.o:               PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)
datoviz/imgui/backends/imgui_impl_glfw.o:    PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)
datoviz/imgui/backends/imgui_impl_vulkan.o:  PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)

# These C++ files include imgui.h, which has IM_FMTARGS(printf) format
# attributes. Our cgv_r_compat.h rewrites 'printf' even inside attributes,
# triggering 'unrecognized format function' warnings. They have no direct
# printf/fprintf calls themselves, so the redirection is unneeded here.
datoviz/fps.o:                               PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)
datoviz/gui.o:                               PKG_CXXFLAGS = $(CGVR_NO_COMPAT_CXXFLAGS)
