Compiler = clang++
DisabledWarnings = -Wno-unused-parameter -Wno-c++98-compat                    $
                   -Wno-c++98-compat-pedantic                                 $
                   -Wno-gnu-anonymous-struct                                  $
                   -Wno-old-style-cast                                        $
                   -Wno-unused-function

NonErrorWarnings = -Wno-error=unused-variable                                 $
                   -Wno-error=missing-prototypes                              $
                   -Wno-error=deprecated-declarations                         $

Optimisation = -O3 -fwrapv
#Optimisation = -fsanitize=address,undefined,integer -g -gcodeview

Features = -fno-omit-frame-pointer                                            $
           -fno-exceptions                                                    $
           -fno-rtti                                                          $
           -fno-strict-aliasing

CompilerFlags = -isystem include                                              $
                -Wall -Wextra -Wmove -pedantic -Weverything -Wpadded  $
                 $NonErrorWarnings                                            $
                 -std=c++14                                                   $
                 -mavx $Optimisation                                          $
                 -fdeclspec -ffast-math                                       $
                 $Features                                                    $
                 $DisabledWarnings

Linker = clang++
Libs = -lGL -lGLU -lglfw -lrt -lm -ldl -lwayland-client -pthread -L/usr/lib/../lib -lffi

CommonLinkerFlags = --for-linker=-nodefaultlib:libcmt
LinkerFlags =   $Libs
#LinkerFlags = $CommonLinkerFlags $Libs --for-linker=-opt:ref

rule compile
  command = $Compiler $CompilerFlags -c $in -o $out
  description = Compile $out
  pool = console

rule link
  command = $Linker $LinkerFlags $in -o$out
  description = Link $out
  pool = console

rule run_this
  command = $in
  description = Run $in

rule make_tags
  command = ctags -R $in
  description = CTags


build tags: make_tags ./code
build sabre.o: compile code/sabre_linux.cc
build svo.o: compile code/svo.cc
build import.o: compile code/import.cc
build render.o: compile code/render.cc
build noise_gen.o: compile code/noise_gen.cc

build sabre: link glad.o sabre.o svo.o import.o render.o noise_gen.o | tags

build run phony: run_this sabre

default sabre