
# VTK 6 minimal build with Tcl wrapper, packaged July 2022 by Albert Graef
# <aggraef@gmail.com>. Pre-patched source, so that it compiles on current
# Linux systems, based on patches and build process from the vtk6 Arch
# PKGBUILD found in the attic of the AUR. Added this toplevel Makefile to
# facilitate the packaging process.

# XXXTODO: Make better use of installed libraries. Currently, lots of stuff
# gets built from bundled sources, which simplifies the build process.

all:
	mkdir build && cd build && \
	cmake \
	-Wno-dev \
	-DCMAKE_SKIP_RPATH=ON \
	-DBUILD_SHARED_LIBS:BOOL=ON \
	-DCMAKE_INSTALL_PREFIX:FILEPATH=/opt/vtk6 \
	-DBUILD_DOCUMENTATION:BOOL=OFF \
	-DBUILD_EXAMPLES:BOOL=OFF \
	-DVTK_USE_TK:BOOL=ON \
	-DVTK_WRAP_JAVA:BOOL=OFF \
	-DVTK_WRAP_PYTHON:BOOL=OFF \
	-DVTK_WRAP_TCL:BOOL=ON \
	-DVTK_Group_Tk=ON \
	-DCMAKE_CXX_FLAGS="-std=c++14 -D__STDC_CONSTANT_MACROS" \
	-DCMAKE_BUILD_TYPE=Release \
	-DModule_vtkRenderingExternal=ON \
	".." \
	-GNinja && \
	ninja

clean:
	rm -rf build

install:
	cd build && ninja install
	mkdir -p "$(DESTDIR)/etc/ld.so.conf.d/"
	printf "%s\n" "/opt/vtk6/lib" > "$(DESTDIR)/etc/ld.so.conf.d/vtk6.conf"
	install -dv "$(DESTDIR)/opt/vtk6/share/licenses/vtk"
	install -m644 "Copyright.txt" "$(DESTDIR)/opt/vtk6/share/licenses/vtk"

uninstall:
	rm -rf "$(DESTDIR)/opt/vtk6" "$(DESTDIR)/etc/ld.so.conf.d/vtk6.conf"
