# -*- mode:Makefile -*-
# Building xcas/icas with giac.dll
# run ./configure
# with export CXXFLAGS="-L/usr/X11R6/lib -L/usr/local/lib -I/usr/local/include"
# then make -f Makefilenew.win xcasdll / icasdll
CXXFLAGS = -O2 -g -I. -I.. -DWIN32 -DHAVE_CONFIG_H -DIN_GIAC -DUSE_OPENGL32 -fno-strict-aliasing -DGIAC_GENERIC_CONSTANTS -DHAVE_LIBMICROPYTHON -DQUICKJS -D_GNU_SOURCE -DQUICKJS -DCONFIG_BIGNUM -DCONFIG_VERSION=\"2020-11-08\" # -DDOUBLEVAL
CFLAGS = -O2 -g -I. -I.. -DQUICKJS -DWIN32 -DUSE_OPENGL32  -DHAVE_LIBGL -D_GNU_SOURCE -DQUICKJS -DCONFIG_BIGNUM -DCONFIG_VERSION=\"2020-11-08\" # -pg
CXX=g++
OBJS =  Python.o History.o Input.o Xcas1.o Equation.o Print.o Tableur.o Cfg.o Flv_CStyle.o Flve_Check_Button.o Flve_Input.o Flv_Style.o Flv_Data_Source.o Flve_Combo.o Flv_List.o Flv_Table.o Editeur.o Graph.o Graph3d.o Help1.o gl2ps.o
GIACOBJS = input_lexer.o sym2poly.o gausspol.o threaded.o maple.o ti89.o mathml.o moyal.o misc.o permu.o quater.o desolve.o input_parser.o symbolic.o index.o modpoly.o modfactor.o ezgcd.o derive.o solve.o intg.o intgab.o risch.o lin.o series.o subst.o vecteur.o sparse.o csturm.o tex.o ifactor.o alg_ext.o gauss.o isom.o help.o plot.o plot3d.o rpn.o prog.o pari.o cocoa.o optimization.o signalprocessing.o lpsolve.o graphe.o nautywrapper.o graphtheory.o markup.o TmpLESystemSolver.o TmpFGLM.o unary.o usual.o identificateur.o gen.o tinymt32.o global.o caseval.o cutils.o graphic.o libbf.o libregexp.o libunicode.o qjsgiac.o quickjs.o quickjs-libc.o js.o
LIBS = -mwindows -L/usr/local/lib -lintl.dll -lfltk_images -ljpeg -lfltk -lfltk_gl -lpng -lfltk_forms /usr/lib/libreadline.a /usr/lib/libhistory.a /usr/lib/libncurses.a /usr/local/lib/libnauty.a /usr/local/lib/libpari.a -lole32 -luuid -lcomctl32 -lwsock32 -lglu32 -lopengl32 -ldmoguids -lgsl -lgslcblas -lintl -lrt -lpthread -llapack -lblas -ldl -lmpfr -lecm -lgmp -lsamplerate -lintl -lz -lglpk -lmicropython
WLIBS = 
# For windows: remove -ldl in LIBS above and uncomment WLIBS below, + -DWIN32
# For linux: add -ldl in LIBS and comment WLIBS
xcas:	$(OBJS) $(GIACOBJS) hist.o 
#	$(CXX) $(CXXFLAGS) $(OBJS) -o xcas $(DYNLIBS)
	$(CXX) mkjs.cc -o mkjs && ./mkjs
	$(CXX) $(CXXFLAGS) hist.o $(GIACOBJS) $(OBJS) -o xcas $(LIBS) $(WLIBS)
# giacpy target is not functionnal, but the commandlines should work from giacpy source directory if Xcas is installed in c:\xcas
giacpy:	giac.dll
	python setup.py build_ext -I/cygdrive/c/xcas/include -DWIN32 -DHAVE_CONFIG_H -DIN_GIAC -DDOUBLEVAL -DUSE_OPENGL32 -DGIAC_GENERIC_CONSTANTS -L/cygdrive/c/xcas
	python setup.py install
clean:
	rm -f $(OBJS) hist.o
icas:	$(OBJS) $(GIACOBJS) icas.o
	$(CXX) $(CXXFLAGS) $(GIACOBJS) $(OBJS) icas.o -o icas $(LIBS) $(WLIBS) 
giac.dll:   $(GIACOBJS) first.o
	c++ $(CXXFLAGS) -shared $(GIACOBJS) first.o -o giac.dll $(LIBS) $(WLIBS)
icasdll:	$(OBJS) giac.dll icas.o
	$(CXX) -s $(CXXFLAGS) $(OBJS) icas.o -o icas giac.dll $(LIBS) $(WLIBS)
xcasdll:	$(OBJS) hist.o giac.dll
	$(CXX) -s $(CXXFLAGS) hist.o $(OBJS) -o xcas giac.dll $(LIBS) $(WLIBS)
hist.o: 	hist.cxx
	$(CXX) $(CXXFLAGS) -c hist.cxx
nautywrapper.o:	nautywrapper.c
	$(CXX) $(CXXFLAGS) -c $<
hist.cxx:	hist.fl
	fluid -c hist.fl
.cc.o:
	$(CXX) $(CXXFLAGS) -c $<
clean:
	rm -f $(OBJS)

