-- Command lines

cc: $ZIG cc $cflags_threads $cflags_common $cflags_windows $cflags $includes $includes_gc -c $c
link: $ZIG cc $lflags_threads $lflags_common $lflags_gui $lflags -o $exe $objs $libs
rc: $ZIG rc $rc_file $res_file

-- File extensions

#ifdef EIF_WINDOWS
obj: .obj
exe: .exe
#else
obj: .o
exe:
#endif

-- Variables

-- For `-fno-strict-aliasing`, this is recommended when using the Boehm GC.
-- 
-- For `-fno-sanitize=undefined`, see https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
-- We don't want an exception raised in case of integer overflow.
--
-- Note: The `-fsanitize=` argument must also be provided when linking, in order to link
-- to the appropriate runtime library. See https://clang.llvm.org/docs/UsersManual.html.
--
cflags_common: -Wno-unused-value -Wno-absolute-value -Wno-void-pointer-to-int-cast -Wno-deprecated-declarations -Wno-deprecated-non-prototype -Wno-unused-command-line-argument -fno-strict-aliasing -fno-sanitize=undefined
lflags_common: -fno-strict-aliasing -fno-sanitize=undefined -Wno-unused-command-line-argument -lm

#ifdef EIF_WINDOWS
cflags_windows: -municode -D_UNICODE -DUNICODE -DWIN32_LEAN_AND_MEAN -D_MT
#else
cflags_windows:
#endif

#ifdef EIF_WORKBENCH
cflags: -g -DDEBUG
lflags: -g -DDEBUG
#else
cflags: -O2 -DNDEBUG
lflags: -O2 -DNDEBUG
#endif

#ifdef EIF_CONSOLE
lflags_gui:
#else
#ifdef EIF_WINDOWS
lflags_gui: -Wl,--subsystem,windows
#else
lflags_gui:
#endif
#endif

#ifdef GE_USE_BOEHM_GC
includes_gc: -I$BOEHM_GC/include
#else
includes_gc:
#endif

#ifdef GE_USE_THREADS
cflags_threads: -pthread
lflags_threads: -pthread
#else
#ifdef GE_USE_BOEHM_GC
cflags_threads: -pthread
lflags_threads: -pthread
#else
cflags_threads:
lflags_threads:
#endif
#endif

