File: Makefile.in

package info (click to toggle)
octave-optim 1.5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,368 kB
  • sloc: cpp: 1,437; makefile: 185; perl: 169; xml: 29; sh: 3
file content (120 lines) | stat: -rw-r--r-- 5,362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Makefile for optim package for Octave
#
# Copyright (C) 2016 Olaf Till <i7tiol@t-online.de>
#
# 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 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.


# before cross building, pre-build at least $(TEXIFILE) natively,
# e.g. with targets 'doc', 'html', or 'prebuild'


CXXCPP = @CXXCPP@

MKOCTFILE ?= @MKOCTFILE@
ifndef CXXFLAGS
CXXFLAGS := $(shell $(MKOCTFILE) -p CXXFLAGS)
endif

# intentionally doesn't consider environment variables
OCTAVE_LAPACK_LIBS := $(shell $(MKOCTFILE) -p LAPACK_LIBS)
# reported necessary for Apple's VecLib framework by Carlo de Falco
# <carlo.defalco@gmail.com>
OCTAVE_BLAS_LIBS := $(shell $(MKOCTFILE) -p BLAS_LIBS)

# Passing LFLAGS, supplemented with LAPACK_LIBS and BLAS_LIBS, in the
# environment to mkoctfile is prefered over passing LAPACK_LIBS and
# BLAS_LIBS in mkoctfiles commandline due to mkoctfiles difficulties
# with non-standard flags on some systems (e.g. -framework ... on
# Apple)
OCTAVE_LFLAGS := $(shell $(MKOCTFILE) -p LFLAGS)
OCTAVE_LFLAGS += $(OCTAVE_LAPACK_LIBS)
OCTAVE_LFLAGS += $(OCTAVE_BLAS_LIBS)

INFOFILE := ../doc/optim.info
TEXIFILE := $(addsuffix .texi,$(basename $(INFOFILE)))
TXIFILE := $(addsuffix .txi,$(basename $(INFOFILE)))
HTMLDIR := ../doc/html/
OCTFILES := __bfgsmin.oct numgradient.oct numhessian.oct samin.oct __disna_optim__.oct

OCTSOURCEFILES := $(addsuffix .cc,$(basename $(OCTFILES)))
DSFILES := $(addsuffix .docstrings,$(OCTSOURCEFILES))
MFILES := $(wildcard *.m) $(wildcard ../inst/*.m)

.PHONY: all clean distclean doc prebuild html

.INTERMEDIATE: MFDOCSTRINGS $(DSFILES)

all: doc $(OCTFILES)

prebuild: doc html

error-helpers.o: error-helpers.cc error-helpers.h
	CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) -c error-helpers.cc

# __disna_optim__ should be linked to the same Lapack library as used by Octave
__disna_optim__.oct: __disna_optim__.cc error-helpers.h config.h error-helpers.o
	CXXFLAGS="$(CXXFLAGS)" LFLAGS="$(OCTAVE_LFLAGS)" $(MKOCTFILE) __disna_optim__.cc error-helpers.o

%.oct: %.cc error-helpers.h config.h error-helpers.o
	CXXFLAGS="$(CXXFLAGS)" $(MKOCTFILE) $< error-helpers.o

doc: $(INFOFILE)

$(INFOFILE): $(TEXIFILE)
	makeinfo $(TEXIFILE) -o $(INFOFILE)

html: $(TEXIFILE)
	makeinfo --html -o $(HTMLDIR) $(TEXIFILE)

$(TEXIFILE): $(TXIFILE) MFDOCSTRINGS $(DSFILES) munge-texi.pl
	./munge-texi.pl MFDOCSTRINGS $(DSFILES) < $(TXIFILE) > $(TEXIFILE)

MFDOCSTRINGS: $(MFILES) mkdoc.pl
	./mkdoc.pl $(MFILES) > MFDOCSTRINGS

# take long CPP macro names, unlikely to be present in package code
# (which is checked) or to be defined by Octave (which can't be
# checked)
RDEFUN_DLD := DEFUN_DLD_REPLACEMENT_FOR_PACKAGE_DOCS
RDEFUNX_DLD := DEFUNX_DLD_REPLACEMENT_FOR_PACKAGE_DOCS
# Docstrings defined as C strings are obtained from a compiled C
# program. This should be the cleanest way to correctly get all
# special characters defined in these strings.
%.cc.docstrings: %.bin
	(echo "### This file is generated automatically from the"; echo "### corresponding .cc file by a Makefile rule."; echo ""; ./$<) > $@
# Explanation of the command after the checks: Macro names are changed
# by `sed' so that a different definition can be given to them on the
# `cpp' commandline. After running the `cpp' command, one can be sure
# that there are not more than one `$(RDEFUN_DLD)' resulting from a
# DEFUN(X)_DLD invocation in the original code at one line, that every
# occurance of `$(RDEFUN_DLD)' indeed corresponds to an original macro
# invocation, and not to `DEFUN(X)_DLD' within a comment or a string,
# and that we have all necessary information within one line of
# text. The package code is expected to give the function
# documentation as a string constant directly in the macro invocation,
# as is normally done.
%.bin: %.cc
	if grep -q $(RDEFUN_DLD) $<; then echo "The string '$(RDEFUN_DLD)' must not be present in source code, but is in $<."; exit 1; fi
	if grep -q $(RDEFUNX_DLD) $<; then echo "The string '$(RDEFUNX_DLD)' must not be present in source code, but is in $<."; exit 1; fi
	(echo "#include <stdio.h>"; echo "int main () {"; sed -e s/DEFUN_DLD/$(RDEFUN_DLD)/g -e s/DEFUNX_DLD/$(RDEFUNX_DLD)/g $< | $(CXXCPP) `$(MKOCTFILE) -p INCFLAGS` -x c++ -iquote '.' -D'$(RDEFUN_DLD)(name,args,nargout,doc)=$(RDEFUN_DLD)(name,doc)' -D'$(RDEFUNX_DLD)(name,fname,gname,args,nargout,doc)=$(RDEFUN_DLD)(name,doc)' - | sed -e '/.*$(RDEFUN_DLD)/!D'; echo "}";) | $(CXX) -x c++ -D'$(RDEFUN_DLD)(name,doc)=printf("%c" #name "\n@c " #name " $<\n" doc "\n\n", 0x1D);' -o $@ -

clean:
	$(RM) *.o octave-core *.oct *.cc.docstrings MFDOCSTRINGS *~

distclean:
	$(RM) *.o octave-core *.oct *.cc.docstrings config.h config.log config.status MFDOCSTRINGS *~

maintainer-clean:
	$(RM) *.o *.oct octave-core *.cc.docstrings config.h config.log config.status MFDOCSTRINGS *~ $(INFOFILE) $(TEXIFILE)