#############################################################
# friso chinese word segmentation makefile.		    		#
#		do not use it for commercial use.	    			#
# @author	chenxin 				    					#
# @email	chenxin619315@gmail.com   		    			#
#############################################################

#complie
CC = gcc
#include directory
INCLUDE = .
#complie flags for devolep
CFLAGS = -g -Wall
#complile flags for products
FFLAGS = -O2 -Wall
#extension libs for friso
ELIB = m
SH_FILE = friso.dll
LB_FILE = friso.lib


OBJS = friso.o friso_array.o friso_hash.o friso_lexicon.o friso_link.o friso_string.o friso_ctype.o friso_UTF8.o friso_GBK.o
SRCS = friso.c friso_array.c friso_hash.c friso_lexicon.c friso_link.c friso_string.c friso_ctype.c friso_UTF8.c friso_GBK.c

all: share friso

#$(CC) $(FFLAGS) -shared $(SOURCE) -l$(ELIB) --mno-cygwin -o $(SH_FILE)
share: $(OBJS)
	$(CC) $(FFLAGS) -shared $(SRCS) --mno-cygwin -o $(SH_FILE) -Wl,--output-def,friso.def,--out-implib,$(LB_FILE)

#--mno-cygwin
friso: tst-friso.o
	$(CC) tst-friso.o -o ./friso -L. -lfriso

tst-friso.o: friso_API.h friso.h tst-friso.c
	$(CC) $(FFLAGS) -c tst-friso.c

friso.o: friso.c friso.h friso_API.h
	$(CC) $(FFLAGS) -c friso.c -l$(ELIB)

friso_array.o: friso_array.c friso_API.h
	$(CC) $(FFLAGS) -c friso_array.c

friso_hash.o: friso_hash.c friso_API.h
	$(CC) $(FFLAGS) -c friso_hash.c

friso_lexicon.o: friso_hash.o friso_lexicon.c friso_API.h
	$(CC) $(FFLAGS) -c friso_lexicon.c

friso_link.o: friso_link.c friso_API.h
	$(CC) $(FFLAGS) -c friso_link.c

friso_string.o: friso_string.c friso_API.h
	$(CC) $(FFLAGS) -c friso_string.c

friso_split.o: friso_split.c friso_API.h
	$(CC) $(FFLAGS) -c friso_split.c

#clean all the object files.
.PHONY: clean
clean:
	find . -name \*.dll | xargs rm -f
	find . -name \*.lib | xargs rm -f
	find . -name \*.o  | xargs rm -f
	@if [ -f friso ];\
	    then\
	    rm -f friso;\
	fi
