#*************************************************************************
# Copyright (c) 2002 The University of Chicago, as Operator of Argonne
#     National Laboratory.
# Copyright (c) 2002 The Regents of the University of California, as
#     Operator of Los Alamos National Laboratory.
# EPICS Base is distributed subject to a Software License Agreement found
# in file LICENSE that is included with this distribution. 
#*************************************************************************

# GNU compiler defaults

GNU = YES

CMPLR_CLASS = gcc

GNU_BIN = $(GNU_DIR)/bin
GNU_LIB = $(GNU_DIR)/lib

CC = $(GNU_BIN)/$(CMPLR_PREFIX)gcc$(CMPLR_SUFFIX)
CCC = $(GNU_BIN)/$(CMPLR_PREFIX)g++$(CMPLR_SUFFIX)
AR = $(GNU_BIN)/$(CMPLR_PREFIX)ar$(CMPLR_SUFFIX) -rc
LD = $(GNU_BIN)/$(CMPLR_PREFIX)ld$(CMPLR_SUFFIX) -r
CPP = $(CC) -x c -E
RANLIB = $(GNU_BIN)/$(CMPLR_PREFIX)ranlib$(CMPLR_SUFFIX)

# Requires at least GCC 4.8 or LLVM (clang) 3.1
ASAN_FLAGS_YES = -fsanitize=address
ASAN_LDFLAGS_YES = $(ASAN_FLAGS_YES)

PROF_CFLAGS_YES = -p
GPROF_CFLAGS_YES = -pg
CODE_CFLAGS = $(PROF_CFLAGS_$(PROFILE)) $(GPROF_CFLAGS_$(GPROF))
CODE_CFLAGS += $(ASAN_FLAGS_$(ENABLE_ASAN))
WARN_CFLAGS_YES = -Wall -Werror-implicit-function-declaration
WARN_CFLAGS_NO = -w
# It makes sense to include debugging symbols even in optimized builds
# in case you want to attach gdb to the process or examine a core-dump.
# This does cost disk space, but not memory as debug symbols are not
# loaded into RAM when the binary is loaded.
OPT_CFLAGS_YES = -O3 -g
OPT_CFLAGS_NO = -g

PROF_CXXFLAGS_YES = -p
GPROF_CXXFLAGS_YES = -pg
CODE_CXXFLAGS = $(PROF_CXXFLAGS_$(PROFILE)) $(GPROF_CXXFLAGS_$(GPROF))
CODE_CXXFLAGS += $(ASAN_FLAGS_$(ENABLE_ASAN))
WARN_CXXFLAGS_YES = -Wall
WARN_CXXFLAGS_NO = -w
OPT_CXXFLAGS_YES = -O3 -g
OPT_CXXFLAGS_NO = -g

CODE_LDFLAGS = $(PROF_CXXFLAGS_$(PROFILE)) $(GPROF_CXXFLAGS_$(GPROF))
CODE_LDFLAGS += $(ASAN_LDFLAGS_$(ENABLE_ASAN))
OPT_LDFLAGS_NO = -g

PIPE_CFLAGS_YES_YES = -pipe
PIPE_CFLAGS = $(PIPE_CFLAGS_$(GCC_PIPE)_$(GNU))

STATIC_LDFLAGS_YES = -static
STATIC_LDFLAGS_NO =

SHRLIB_CFLAGS = -fPIC
SHRLIB_LDFLAGS = -shared -fPIC -Wl,-h$@
LOADABLE_SHRLIB_LDFLAGS = -shared -fPIC -Wl,-h$@

GNU_LDLIBS_YES = -lgcc

# Use compiler flags to generate header dependancies files
HDEPENDS_METHOD = COMP
HDEPENDS_COMPFLAGS = -MM -MF $@

