# -*- 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 = -std=c++0x -g -O2 -DHAVE_CONFIG_H -I. -I..  -DIN_GIAC -DWIN32 -D__MINGW_H -fno-strict-aliasing -DGIAC_GENERIC_CONSTANTS -DTIMEOUT -DHAVE_LIBMICROPYTHON -DQUICKJS -D_GNU_SOURCE -DQUICKJS -DCONFIG_BIGNUM -DCONFIG_VERSION=\"2020-11-08\" -fpermissive -I. -I.. 
CFLAGS = -g -D__MINGW_H -fno-strict-aliasing -DGIAC_GENERIC_CONSTANTS -DHAVE_LIBMICROPYTHON -DQUICKJS -D_GNU_SOURCE -DQUICKJS -DCONFIG_BIGNUM -DCONFIG_VERSION=\"2020-11-08\" -fpermissive -I. -I.. 
CXX=g++
OBJS = History.o Input.o Xcas1.o Equation.o Print.o Tableur.o Editeur.o Graph.o Graph3d.o Help1.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 gl2ps.o Python.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 = -L.. -L. -lmicropython -lntl -lpari -lpng -lfltk_images -ljpeg -lz -lfltk -lfltk_gl -lopengl32 -lgsl -lgslcblas -lintl -lpthread -lnauty -lcurl -lsamplerate -lglpk -lao -llapack -lblas -lgfortran -ldl -lpng16 /mingw64/lib/libecm.a -lpsapi /mingw64/lib/libmpfi.a -lmpfr -lgmp
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) xcas.o 
#	$(CXX) $(CXXFLAGS) $(OBJS) -o xcas $(DYNLIBS)
	$(CXX) $(CXXFLAGS)  xcas.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
libgiac.a: $(GIACOBJS)
	ar cru .libs/libgiac.a $(GIACOBJS)
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) xcas.o
icas:	$(OBJS) $(GIACOBJS) icas.o
	$(CXX) $(CXXFLAGS) $(GIACOBJS) $(OBJS) icas.o -o icas $(LIBS) -lreadline $(WLIBS) 
libgiacxcas.dll:   $(OBJS) $(GIACOBJS) first.o
	c++ $(CXXFLAGS) -shared $(GIACOBJS) $(OBJS) first.o -o giacxcas.dll $(LIBS) $(WLIBS)
icasdll:	libgiacxcas.dll icas.o
	$(CXX) -s $(CXXFLAGS) icas.o -o icas -lgiacxcas $(LIBS)  -lreadline
xcasdll:	xcas.o libgiacxcas.dll
	$(CXX) -s $(CXXFLAGS) xcas.o -o xcas -lgiacxcas $(LIBS)
nautywrapper.o:	nautywrapper.c
	$(CXX) $(CXXFLAGS) -c $<
.cc.o:
	$(CXX) $(CXXFLAGS) -c $<


