##############################################################################
# Makefile definitions and common commands
#
# Setup of C definitions based on makeconfig options
#
# Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
# Note: the configurable options are in makeconfig.
#
# Copyright (C) 2009-2010 Francesco Abbate. See Copyright Notice in gsl-shell.c
##############################################################################

AR= ar rcu
RANLIB= ranlib
CP_REL = cp --parents

CC = gcc
CXX = g++

ifeq ($(HOST_SYS),Darwin)
  LINK_EXE = $(CXX) $(LDFLAGS)
  # Use rsync because the --parents option to cp doesn't exist in
  # Mac OS X
  CP_REL = rsync -R
else
  LINK_EXE = $(CC) $(LDFLAGS)
endif

ifeq ($(strip $(LUA_BUILD)), yes)
  PACKAGE_NAME = lua
  PACKAGE_VERSION = 5.1
else
  PACKAGE_NAME = gsl-shell
  PACKAGE_VERSION = 2.2
endif

ifeq ($(strip $(DEBUG)), yes)
  CFLAGS = -g -Wall
  CXXFLAGS = -g -Wall
else
  # on windows do not use -fomit-frame-pointer
  CFLAGS = -O3 -fno-stack-protector -fomit-frame-pointer -ffast-math -Wall
  CXXFLAGS = -Os -fno-exceptions -fno-stack-protector -ffast-math -fno-rtti -Wall
endif

DEFS += -D_REENTRANT

ifeq ($(HOST_SYS),Windows)
  DEFS += -DWIN32
  EXE_EXT = .exe
else
  EXE_EXT =
  DEFS += -pthread
  LIBS += -pthread
endif

ifeq ($(strip $(DEBUG)), yes)
  DEFS += -DGSL_SHELL_DEBUG
endif

ifeq ($(strip $(DISABLE_GAMMA_CORR)), yes)
  DEFS += -DDISABLE_GAMMA_CORR
endif

ifeq ($(strip $(DISABLE_SUBPIXEL_LCD)), yes)
  DEFS += -DDISABLE_SUBPIXEL_AA
endif

ifeq ($(strip $(USE_READLINE)),yes)
  ifneq ($(HOST_SYS),Windows)
    DEFS += -DUSE_READLINE
  else
    USE_READLINE = no
  endif
endif
