目标没有依赖项时,Makefile行为不一致

时间:2017-01-22 00:13:22

标签: makefile

这是一个快速而脏的Makefile,用于为两个文档执行Latex传递。

BOOKDIR=/tmp/book
SLIDESDIR=/tmp/slides

LATEX=pdflatex -shell-escape --halt-on-error

book:
    mkdir -p "${BOOKDIR}"
    ${LATEX} -output-directory="${BOOKDIR}" book.tex && \
        (cd "${BOOKDIR}" && makeindex book)

slides:
    mkdir -p "${SLIDESDIR}"
    ${LATEX} -output-directory="${SLIDESDIR}" slides/slides.tex

all: book slides

当我运行make book时,它会执行书籍的配方。当我运行make slides时,它总是说make: 'slides' is up to date.

这两个目标都没有任何依赖关系,为什么两种情况下的表现都不一样?

1 个答案:

答案 0 :(得分:0)

基于命令

public static void function1_grad(double[] x, ref double func, double[] grad, object obj)
{
    // this callback calculates f(x0,x1) = 100*(x0+3)^4 + (x1-3)^4
    // and its derivatives df/d0 and df/dx1
    func = 100*System.Math.Pow(x[0]+3,4) + System.Math.Pow(x[1]-3,4);
    grad[0] = 400*System.Math.Pow(x[0]+3,3);
    grad[1] = 4*System.Math.Pow(x[1]-3,3);
}
public static int Main(string[] args)
{
    //
    // This example demonstrates minimization of f(x,y) = 100*(x+3)^4+(y-3)^4
    // using LBFGS method.
    //
    // Several advanced techniques are demonstrated:
    // * upper limit on step size
    // * restart from new point
    //
    double[] x = new double[]{0,0};
    double epsg = 0.0000000001;
    double epsf = 0;
    double epsx = 0;
    double stpmax = 0.1;
    int maxits = 0;
    alglib.minlbfgsstate state;
    alglib.minlbfgsreport rep;

    // first run
    alglib.minlbfgscreate(1, x, out state);
    alglib.minlbfgssetcond(state, epsg, epsf, epsx, maxits);
    alglib.minlbfgssetstpmax(state, stpmax);
    alglib.minlbfgsoptimize(state, function1_grad, null, null);
    alglib.minlbfgsresults(state, out x, out rep);

    System.Console.WriteLine("{0}", alglib.ap.format(x,2)); // EXPECTED: [-3,3]

    // second run - algorithm is restarted
    x = new double[]{10,10};
    alglib.minlbfgsrestartfrom(state, x);
    alglib.minlbfgsoptimize(state, function1_grad, null, null);
    alglib.minlbfgsresults(state, out x, out rep);

    System.Console.WriteLine("{0}", rep.terminationtype); // EXPECTED: 4
    System.Console.WriteLine("{0}", alglib.ap.format(x,2)); // EXPECTED: [-3,3]
    System.Console.ReadLine();
    return 0;
}

您似乎在当前目录中有一个名为let function1_grad(x : float [], func : float, grad : float [], obj_ : obj) = func <- 100.*System.Math.Pow(x.[0]+3.,4.) + System.Math.Pow(x.[1]-3., 4.) grad.[0] <- 400.*System.Math.Pow(x.[0]+3,3.); grad.[1] <- 4.*System.Math.Pow(x.[1]-3.,3.); let runOptim() = let x = [|0.; 0.|] let epsg = 0.0000000001 let epsf = 0. let epsx = 0. let stpmax = 0.1 let maxits = 0 let state = alglib.minlbfgsstate let mutable rep = alglib.minlbfgsreport() // first run alglib.minlbfgscreate(1, x, state) alglib.minlbfgssetcond(state, epsg, epsf, epsx, maxits) alglib.minlbfgssetstpmax(state, stpmax) alglib.minlbfgsoptimize(state, function1_grad, null, null) alglib.minlbfgsresults(state, x, rep) printfn "{0}", alglib.ap.format(x,2) let x = [|10.; 10.|] alglib.minlbfgsrestartfrom(state, x) alglib.minlbfgsoptimize(state, function1_grad, null, null) alglib.minlbfgsresults(state, x, rep) printfn "%A" rep.terminationtype printfn "%A" (alglib.ap.format(x, 2)) System.Console.ReadLine() |> ignore 的目录。大概你没有一个叫${LATEX} -output-directory="${SLIDESDIR}" slides/slides.tex 的人。您可以更改目标名称或更改目录名称,或将目标声明为slides,具体取决于您所需的行为。