# These are ALL the variables/macros used by the KerGIS build tree
# These default to POSIX compliant ones
# $Id: C_clang,v 1.6 2020/11/18 18:03:42 tlaronde Exp $
#
# Copyright 2016 Thierry LARONDE <tlaronde@polynum.com>
# Public Domain. NO GUARANTEES!

# overwrite the defaults
include C_posix

RK_COMPILE_ENV=clang

#----- POSIX known (or definable)
#
CC=$(rk_which_cmd_of clang cc)

# To customize, one must create a specific parameter file.
#
CFLAGS="$CFLAGS -O -fno-builtin -Wall -Wstrict-prototypes -Wmissing-prototypes"

#----- ABI dependencies. 

LDFLAGS=

# a directive for cc interface needed to be sure what the things
# we do not explicitely state are also statically linked.
#
LDFLAGS_STATIC="-static"

# shared stuff is highly ABI dependent and is not defined by POSIX
# LIBPATH, RPATH and SONAME are generated by `rkbuild'
#
AR_DSHARED="$CC -shared"
CFLAGS_DSHARED="-fPIC"
LDFLAGS_DSHARED=

# ELF object link specific
# How to define the SONAME of a created ELF shared lib
LDFLAGS_ELF_SONAME='-Wl,-soname,##SONAME##'

# How to set a rpath in a ELF object
LDFLAGS_ELF_RPATH='-Wl,-R##RPATH##'

# How to specify link time dir path to search for included dshared libes
# (not used for now).
#
LDFLAGS_ELF_RPATH_LINK='-Wl,-rpath-link,##LIBPATH##'

#----- SUB_ENV customizations

case $RK_COMPILE_SUB_ENV in
	debug)
		;;
	distrib) case $TARGET_ARCH in
  		i?86|ia32|x86) CFLAGS="$CFLAGS -s -march=i486 -mtune=i686 -O2"
			;;
			*) CFLAGS="$CFLAGS -s -O2"
			;;
		esac
		;;
	pie) CFLAGS="$CFLAGS -fPIC"
		;;
	*) RK_COMPILE_SUB_ENV=default
		;;
esac

