# ------------------------------------------------------------------------
# This file is part of sciFLT ( Scilab Fuzzy Logic Toolbox )
# Copyright (C) @YEARS@ Jaime Urzua Grez
# mailto:jaime_urzua@yahoo.com
# Toolbox Revision @REV@ -- @DATE@
# ------------------------------------------------------------------------
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# -------------------------------------------------------------------------------------
# This is an standalone makefile to be used with minwin distribution
# Instruction:
# 1) Change the path of scilab distro in the next line

SCIDIR =C:/scilab-4.1

# 2) Open a cmd windows and go to this folder and type mingw32-make -f makefile_mingw32

# -------------------------------------------------------------------------------------

# Library name -- USER ENTRY
LIBRARY = libsciFLT
# Object to compile -- USER ENTRY
OBJS = optfls.o complement.o defuzzm.o flsencode.o flsengine.o inter_sciFLT.o mfs.o snorm.o tnorm.o util1.o util2.o sfls.o libsciFLT.o

# ---- DO NOT CHANGE BELLOW THIS LINE ----

LIBS = $(SCIDIR)/bin/libscilab.lib $(SCIDIR)/bin/atlas.lib $(SCIDIR)/bin/arpack.lib -lg2c -mwindows -lwsock32 -lshell32 -lcomctl32  -lwinspool -lm -lwinmm
OS_CFLAGS =
OS_FFLAGS =
CFLAGS = -O $(OS_CFLAGS) $(CC_OPTIONS) -DFORDLL -I"$(SCIDIR)/routines" -I"$(SCIDIR)/routines/os_specific" -Dmexfunction_=mex$*_  -DmexFunction=mex_$*  
FFLAGS = -O $(OS_FFLAGS) $(FC_OPTIONS) -DFORDLL -I"$(SCIDIR)/routines" -I"$(SCIDIR)/routines/os_specific" -Dmexfunction=mex$* 

# Build ALL!
all: $(LIBRARY).dll
	@echo All done!

# Build the .dll
$(LIBRARY).dll: $(OBJS) $(LIBRARY).def
	@echo Building $(LIBRARY)
	@gcc --shared -s -o $(LIBRARY).dll $(LIBRARY).def $(OBJS) $(LIBS)

# Create definition file
$(LIBRARY).def: $(OBJS)
	@echo Building $@
	@dlltool --export-all-symbols -D $(LIBRARY).dll -z $(LIBRARY).def $(OBJS)

# Build C objects
.c.o:
	@echo Building $<
	@gcc $(CFLAGS) -c -o $*.o $<

# Build F Objects
.f.o:
	@echo Building $<
	@g77 $(FFLAGS) -c -o $*.o $<

# Clean
clean:
	@del *.o
	@del $(LIBRARY).dll
	@del $(LIBRARY).def

