1-include ./Makefile.conf
2
3MKOCTFILE ?= mkoctfile
4
5ifndef LAPACK_LIBS
6LAPACK_LIBS := $(shell $(MKOCTFILE) -p LAPACK_LIBS)
7endif
8ifndef BLAS_LIBS
9BLAS_LIBS := $(shell $(MKOCTFILE) -p BLAS_LIBS)
10endif
11ifndef FLIBS
12FLIBS := $(shell $(MKOCTFILE) -p FLIBS)
13endif
14LDFLAGS := $(shell $(MKOCTFILE) -p LDFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
15
16AR := $(shell $(MKOCTFILE) -p AR)
17
18PKG_CXXFLAGS := -Wall -Wno-deprecated-declarations $(PKG_CXXFLAGS_APPEND)
19
20all: __control_slicot_functions__.oct \
21     __control_helper_functions__.oct
22
23# TODO: Private oct-files for control package.
24
25# unpack and compile SLICOT library
26# Note that TG04BX is a custom routine.
27# It has the extension .fortran such that
28# it is not deleted by rm *.f when using
29# the developer makefile makefile_control.m
30# The other rotuines *.fortan are modified versions
31# of the original slicot routines.
32#
33# MA02ID.f use in its original version is compiled by an
34# extra command suppressing warnings on indexing errors
35#
36slicotlibrary.a: slicot.tar.gz
37	tar -xzf slicot.tar.gz
38	mkdir sltmp
39	mv slicot/src/*.f ./sltmp
40	mv slicot/src_aux/*.f ./sltmp
41	if [ "$(HAVE_DGGES)" = "1" ]; then \
42		echo "copy routines using DGGES"; \
43		cp SB04OD.fortran ./sltmp/SB04OD.f; \
44		cp SG03AD.fortran ./sltmp/SG03AD.f; \
45		cp SG03BD.fortran ./sltmp/SG03BD.f; \
46	fi;
47	cp AB08NX.fortran ./sltmp/AB08NX.f
48	cp AG08BY.fortran ./sltmp/AG08BY.f
49	cp SB01BY.fortran ./sltmp/SB01BY.f
50	cp SB01FY.fortran ./sltmp/SB01FY.f
51	cp SB06ND.fortran ./sltmp/SB06ND.f
52	cp TB01MD.fortran ./sltmp/TB01MD.f
53	cp TB01ND.fortran ./sltmp/TB01ND.f
54	cp TB01ZD.fortran ./sltmp/TB01ZD.f
55	cp TG04BX.fortran ./sltmp/TG04BX.f
56	cp ODLTZM.fortran ./sltmp/ODLTZM.f
57	cp makefile.slicot ./sltmp/makefile
58	cd sltmp; $(MKOCTFILE) -w -c MA02ID.f; rm MA02ID.f; $(MKOCTFILE) -c *.f;
59	$(AR) -rc slicotlibrary.a ./sltmp/*.o
60	rm -rf sltmp slicot
61
62# slicot functions
63__control_slicot_functions__.oct: __control_slicot_functions__.cc common.cc slicotlibrary.a
64	LDFLAGS="$(LDFLAGS)" \
65    $(MKOCTFILE) $(PKG_CXXFLAGS) __control_slicot_functions__.cc common.cc slicotlibrary.a
66
67# helper functions
68__control_helper_functions__.oct: __control_helper_functions__.cc
69	$(MKOCTFILE) $(PKG_CXXFLAGS) __control_helper_functions__.cc
70
71clean:
72	$(RM) -r *.o core octave-core *.oct *~ *.f slicot sltmp
73
74realclean: clean
75	$(RM) -r *.a
76
77## This should also remove any configure cache which clean should not
78## remove according to GNU guidelines.
79## https://www.gnu.org/prep/standards/html_node/Standard-Targets.html
80distclean: clean realclean
81