# builds scilab fispro basic library (shared library to be from the scilab environment)

# uncomment next line for debug mode
#DEBUG=true

# OS-default=LINUX
# for win32 run OS=WIN32;make
ifndef OS
OS=LINUX
endif

# the arch command is only valid under Linux/UNIX
#ARCH=$(shell arch)
ARCH=$(shell uname -m)
export ARCH

# flag DEBUG
ifdef DEBUG
OPT=-g -DDEBUG -O0
else
OPT=-O3 -DNDEBUG
endif

ifeq ($(OS),LINUX)
ifeq ($(ARCH),x86_64)
OPT+=-fPIC
endif
endif

ifdef OPENMP
ifeq ($(CXX),g++)
OPT+=-fopenmp
LIBOMP=-lgomp
endif
endif

INCLUDE = -I.
CCFLAGS=$(INCLUDE) -Wall $(OPT)

COMPILER= g++

ifeq ($(OS),WIN32)
NAME = scilab_fispro.dll
ARCHIVER=  g++ -shared -o
endif

ifeq ($(OS),LINUX)
NAME = scilab_fispro.so
ARCHIVER= g++ -shared -o
endif

BIN= ../../bin
OBJECTS= $(BIN)/fis.o $(BIN)/out.o $(BIN)/in.o $(BIN)/mf.o $(BIN)/rule.o $(BIN)/defuz.o $(BIN)/common.o $(BIN)/aggreg.o $(BIN)/mfdposs.o $(BIN)/pt.o

$(BIN)/$(NAME) : $(OBJECTS)  
	$(ARCHIVER) $(NAME) $(OBJECTS) fispro.o

$(BIN)/fispro.o : fispro.cpp
	$(COMPILER) -c $(CCFLAGS) fispro.cpp


clean :
	rm   fispro.o $(NAME)

