ver=debug
SRC=comm_src
CXX=g++

OS_NAME = $(shell uname -s)
ifeq ($(OS_NAME), Darwin)
OS_VERSION = $(shell uname -r)
ifneq ($(findstring 12,$(OS_VERSION)), 12)
CXX+= -stdlib=libstdc++
endif
endif

# Foxit GSDK lib and head files include
INCLUDE_PATH=-I../../include
FXLIB_PATH=../../lib
LDFLAGS=-L$(FXLIB_PATH)

# debug or release mode
ifeq ($(ver), debug)
  DEST_PATH=./bin/dbg_gcc
  OBJ_PATH=./obj/dbg
  CCFLAGS=-g -c
else
  DEST_PATH=./bin/rel_gcc
  OBJ_PATH=./obj/rel
  CCFLAGS=-c
endif

# choose mac or linux platform to include
ifeq ($(OS_NAME), Darwin)
  FXLIB=-lfsdk_mac64
else
  ifeq ($(shell getconf LONG_BIT), 32)
    FXLIB=-lfsdk_linux32
    LIBNAME=libfsdk_linux32.so
  else
    FXLIB=-lfsdk_linux64
    LIBNAME=libfsdk_linux64.so
  endif
    LDFLAGS=-L $(FXLIB_PATH) -Wl,--rpath=../../../../lib
endif

ifeq ($(OS_NAME), Darwin)
    LIBS=$(FXLIB) -lpthread -framework Carbon
else
    LIBS=$(FXLIB) -lpthread
endif

DEST=-o $(DEST_PATH)/$@
OBJ_DEST=-o $(OBJ_PATH)/$@
