Ȼ/11

Top / Ȼ / 11

make

make ȤϡMakefile ȸƤФ쥷ԥե˽񤫤줿쥷Ԥ˱äƺȤưŪˤƤġǤ*1 ħȤƤϡ



  • 쥷ԤʤΤǡñ㡥Ȥޤ路䤹
  • ֥Ρפΰ¸طȡζɽŪʼ񤱤ɤȤƤñ㡥
  • ɬפʺȼưŪȽǤƤ롥 ʹ֤ν֤򵤤ˤʤɤ
  • Ȥľݡɬפʺȡ֤פäƤ롥 륹ץȤꤳޤʤȡƬľˤʤ.Ӥ
  • Ȥǥ顼äƻߤޤäȤ롥βսȤб硤⤦ make ȡ³餭ȤäƤ롥
  • ñʵҤ򤹤뤿ι٤ʸˡ⤢ꡤϤФۤɴñ˽񤱤롥

ȤȤ󤲤롥 Ƥ狼褦ˡѤʤΤǤ롥 Ϥ make ˤĤƳؤܤ

ʤưŪʺȤ򤹤٤ΥġȤ¾˥륹ץȤʤɤ⤢뤬 ľȯ褦ʾ(ץ೫ȯʤ) make 餫Ǥ롥



Reference: make ͻ



  • JNorth_arrow-right-sm.png GNU Make 㤯Ҥۤ GNU Make. ޤεȤƤдְ㤤ʤǿС 3.82 ? ޤmake ʬǥ󥹥ȡ뤹ɬפˤʤ뤳ȤϤޤʤ





¾ˤ⡤web ˤ make ˤĤƽ񤤤Τ롥 ʬˤäΤõƤߤ褦



101 of make: make δ

Make salad: 㤨: Makefile

ޤ㤨 make ͤǡMakefile ϤΥ쥷Ԥȹͤơ쥷Ԥ񤯤Ȥͤ롥 ǽˡñʥ쥷ԤͤƤߤ褦 make ήǡǤ롥


ǽˡñʥ롤ȤȤ


  • ʡвʡȤä֥Ρפ¸ط
  • ȡвǤ

ˤ櫓ǫ˹ͤƤߤ褦 ޤϰ¸ط񤤤Ƥߤ롥



Ρ֥Ρפ¸ط

åΥåȤɬפ
Ŭ٤礭ڤ줿餫Ŀ
ɥå
ʴ
Ŭ٤礭ڤ줿
餫Ŀ
餫Ŀ
餫Ŀ
ɥå





ˡΰ¸طκΡ֥åʡפ뤿ˤֺȡפƤߤ褦



˺äѤꤹ֥Ρפ¸ط

åΥåȤɬפ
Ŭ٤礭ڤ줿餫Ŀ
ɥå
ʴ
ɬʤκǽǸ졤ܤդ꤫
Ŭ٤礭ڤ줿
餫Ŀ
餫Ŀ
ɬʤŬ˥å
餫Ŀ
ɬʤ
ɥå



ɬʤŬ̡Ŭ٤˺



ɽ˽äơֺǽΥåʤˤĤ åʤ⤷̵СֺȡפǺꡤλɬפʤʤФ줬åʤȤƽ񤫤ƤʬɤǰʲƱͤˡĤȤȤƵŪ˷֤Х뤳Ȥˤʤ롥 ǫ˹ͤή줬狼 äơ make ήΥ쥷ԤδǤ롥 ºݤκȤ make ȤͤäƤΤ顤λŻ ϤΥ쥷Ԥ񤯤ǽλʤΤ


ơ make ʸˡǤΥ쥷Ԥ񤯤Ȥͤ褦 ̾ Makefile Ȥ̾Υե˽񤭤ࡥ ƤȤϡ make ʸˡ˱褦ʤаʲΤ褦ˤʤ롥


Υ쥷Ԥ make ʸˡ˱ä Makefile Ȥƽ񤯤ȼΤ褦ˤʤ

ʡ␣Ŭ鿷␣ɥå␣ʴ

____␉____ɬʤκǽǸ졤ܤդ꤫


Ŭ鿷:␣鿷

____␉____ɬʤŬ˥å


鿷:␣

____␉____ ɬʤ


ɥå:␣␣␣␣␣祦

____␉____ ɬʤŬ̡Ŭ٤˺

  * ____␉____ , (tab 󲡤ϤǤ)ΤȤǤ.



ɬפʸˡϤä2Ĥǡ

¸ط ֥å : ɬʡ Ƚ

ȤϼԤ ____␉____ȡ Ƚ



Ǥ롥 ñ

ơäƥ쥷Ԥʤ Makefile 顤Ȥϡ

make

ǤĤ(·äƤʤ)make ޥɤΥ쥷ԤˤäƺȤ򤷤ơȤ櫓Ǥ롥



What will happen if you change something and "make" again? 㤨: 椫ľȤ?

ơΥ쥷Ԥ񤭡ͤ˥äƤäǡ ݤŤäȤ˵ŤƿݤǥľȻפäȤ褦 ǤǤʤϽʬ;äƤȤƤ*2

Ȥξ硤ɬפʺȤ

  1. ɥå󥰤κ
  2. δ(Ŭ鿷ڤϤää;äƤΤȤΤ)

Ȥä2ɤ Ρ2ɤפȤŪʻ¤(make)ˤɤäƻؼФ褤? ¤Ϥλؼ϶ŪʤƤ褤Τ make ֥Ρפ¤֤ӤƾȽǤƤΤǤ롥

ĤޤꡤݤؤȤǤ⤦

make

ǤĤǡˤ2ľƤΤǤ롥 Τ褦ˡ



make ǤĤɬפʺȤľƤ!

ΤǤ. 줬 make ΤȤƤǤ롥



The simplest example: ñ

ǤϡץǼºݤˤäƤߤ褦 ǽϤñˡץ򥳥ѥ뤷ơ¹ԤȤñʳκȤ򤵤Ƥߤ褦



notes.png ½: ʲμ˽Ŭʼ½ѥǥ쥯ȥ make ưƤߤ롥
warning.png ǤϤʤΤή򤷤ʤפǤϰ̣ʥ

  1. ޤf_sin.c Ȥ̾ΥեꡤȤ񤭹Ǥ
     #include <stdio.h>
     #include <math.h>
     main () {
       double x,dx;
       dx = 1.0/100;
       x = 0.0;
       for ( x = 0.0; x <= 0.5+dx; x += dx) {
         printf("%6.3f %6.3f\n", x, sin(x));
         }
       return 0;
     }
    warning.png 򤹤ץफ, ɲ򤷤Ƥ

  2. Ʊǥ쥯ȥ Makefile Ȥ̾ΥեꡤȤ񤭹Ǥ

    f_sin.dat:␣f_sin.exe

    ____␉____ \rm␣-f␣f_sin.dat

    ____␉____ ./f_sin.exe␣>␣f_sin.dat


    f_sin.exe:␣f_sin.c

    ____␉____ gcc␣-lm␣f_sin.c␣-o␣f_sin.exe

    warning.png 2, 3, 6ܤϡ֥֡+ֺȥޥɡפηǽ񤯤ȡηǤʤȤޤ*3
    warning.png ֤뤿ˡĤȾ㤦ɽ򤷤Ƥ. ԥڤǤʤΤǼϤϤ褦
    warning.png 򤹤쥷Ԥ, ɤdzǧƤ

  3. make Ƥߤ롥

    make



  4. ꤬ʤСf_sin.c Ȥץबѥ뤵졤¹Ԥ졤η̤ f_sin.dat Ȥǡե뤬ǤƤϤ Ƥ㤨мΤ褦ˤƤߤ褦

    less␣f_sin.dat



  5. ̤ΥǡեäƤߤ褦

    rm␣f_sin.dat



  6. Ƥ make Ƥߤ롥
    warning.png λɤκȤԤ뤫տƤȰۤʤϤ

    make



  7. ƤӼ¹Է̤ǤƤϤʤΤdzǧ褦

    less␣f_sin.dat



  8. ٤ϥץƤߤ褦 Ūˤϡf_sin.c for ιԤ
       for ( x = 0.0; x <= 1.0+dx; x += dx) {
    ȽƤߤ(0.5 äȤ 1.0 ˽)

  9. Ƥ make Ƥߤ롥

    make



  10. ٤μ¹Է̤ϰۤʤϤƤߤ褦

    less␣f_sin.dat


warning.png ѹ򤷤Ƥ⡤ĤǤ make ޥɤǺѤࡪ ʤȤ˵դ



Simple example: äʣˤʤä

ˡäȤơץ򥳥ѥ뤷ơ¹ԤơˤΥǡե뤫饰դȤʳκȤ򤵤Ƥߤ褦



notes.png ½: ³ηˤʤ롥³ȤơʲΤ褦ˤäƤߤ褦

  1. Ʊǥ쥯ȥ sin2eps.gpl Ȥ̾ΥեꡤȤ񤭹Ǥ
     set output "f_sin.eps"
     set term postscript
     plot "f_sin.dat" w l

    warning.png ǸιԤκǸʸ l(ʸΥ)
    warning.png ǸιԤ򤭤äԤƤȤ˺ʤ褦ˡ

  2. Makefile ȤʲΤ褦˽(Ƭ˻Ԥä)

    f_sin.eps:␣f_sin.dat

    ____␉____ gnuplot␣"sin2eps.gpl"


    f_sin.dat:␣f_sin.exe

    ____␉____ \rm␣-f␣f_sin.dat

    ____␉____ ./f_sin.exe␣>␣f_sin.dat


    f_sin.exe:␣f_sin.c

    ____␉____ gcc␣-lm␣f_sin.c␣-o␣f_sin.exe

    warning.png ֺȡפιԤϡ֥֡+ޥɤǤ뤳Ȥ˺줺ˡ
    warning.png ⡤֤뤿ˤĤȾ㤦ɽ򤷤Ƥ. ԥڤǤʤΤǼϤϤ褦
    warning.png 򤹤쥷Ԥˤʤä, ɤdzǧƤ

  3. make Ƥߤ롥

    make



  4. ꤬ʤСf_sin.eps Ȥե뤬ǤƤΤǡƤߤ褦. GUI ǤΥեޥǥ֥륯å褷ΥޥɤǤ⤤

    gv␣f_sin.eps␣&

warning.png Υޥ̾ϴĶˤäƤϡgv ǤϤʤggv ⤷ʤ gv ǤϥʤȤϻƤߤ褦


Τ褦ˡȤʳˤʤäƤƤ make ʤȤ롥



Something complicated: ⤦äȤ³󤸤

ơ٤ϡκȤ 3ĤΥץ򥳥ѥ뤷3Ĥμ¹ԥե ¹Ԥ3ĤΥǡե餻ơ礷եե 1ĺȤΤˤ褦 ʤˡ狼äƤдñ



notes.png ½: ³ηˤʤ롥³ȤơʲΤ褦ˤäƤߤ褦

  1. f_cos.c Ȥ̾ΥեꡤȤ񤭹Ǥ
     #include <stdio.h>
     #include <math.h>
     main () {
       double x,dx;
       dx = 1.0/100;
       x = 0.0;
       for ( x = 0.0; x <= 1.0+dx; x += dx) {
         printf("%6.3f %6.3f\n", x, cos(x));
         }
       return 0;
     }
    warning.png 򤹤ץफ, ɲ򤷤Ƥ

  2. f_sqr.c Ȥ̾ΥեꡤȤ񤭹Ǥ
     #include <stdio.h>
     #include <math.h>
     main () {
       double x,dx;
       dx = 1.0/100;
       x = 0.0;
       for ( x = 0.0; x <= 1.0+dx; x += dx) {
         printf("%6.3f %6.3f\n", x, x*x);
         }
       return 0;
     }
    warning.png ⲿ򤹤ץफ, ɲ򤷤Ƥ

  3. Makefile ȤʲΤ褦˽(ѤΤտȤ褦)

    all.eps:␣f_sin.dat␣f_cos.dat␣f_sqr.dat

    ____␉____ gnuplot␣"all2eps.gpl"


    f_sin.dat:␣f_sin.exe

    ____␉____ \rm␣-f␣f_sin.dat

    ____␉____ ./f_sin.exe␣>␣f_sin.dat


    f_cos.dat:␣f_cos.exe

    ____␉____ \rm␣-f␣f_cos.dat

    ____␉____ ./f_cos.exe␣>␣f_cos.dat


    f_sqr.dat:␣f_sqr.exe

    ____␉____ \rm␣-f␣f_sqr.dat

    ____␉____ ./f_sqr.exe␣>␣f_sqr.dat


    f_sin.exe:␣f_sin.c

    ____␉____ gcc␣-lm␣f_sin.c␣-o␣f_sin.exe


    f_cos.exe:␣f_cos.c

    ____␉____ gcc␣-lm␣f_cos.c␣-o␣f_cos.exe


    f_sqr.exe:␣f_sqr.c

    ____␉____ gcc␣-lm␣f_sqr.c␣-o␣f_sqr.exe

    warning.png ֺȡפιԤϡ֥֡+ޥɤǤ뤳Ȥ˺줺ˡ
    warning.png ⡤֤뤿ˤĤȾ㤦ɽ򤷤Ƥ. ԥڤǤʤΤǼϤϤ褦
    warning.png 򤹤쥷Ԥˤʤä, ɤdzǧƤ

  4. Ʊǥ쥯ȥ all2eps.gpl Ȥ̾ΥեꡤȤ񤭹Ǥ
     set output "all.eps"
     set term postscript
     plot "f_sin.dat" w l,"f_cos.dat" w l,"f_sqr.dat" w l

    warning.png ǸιԤνäݤʸ l(ʸΥ)
    warning.png ǸιԤ򤭤äԤƤȤ˺ʤ褦ˡ

  5. make Ƥߤ롥

    make



  6. ꤬ʤСall.eps Ȥե뤬ǤƤΤǡƤߤ褦. GUI ǤΥեޥǥ֥륯å褷ΥޥɤǤ⤤

    gv␣all.eps␣&



  7. ץΤ줫Ŭ˽Ƥߤ褦Ƥϥդʤʤ褦ʤΤʤʤǤɤ

  8. Ƥ make Ƥߤ롥

    make



  9. ٤μ¹Է̤ϰۤʤϤƤߤ褦

    gv␣all.eps␣&



Advanced syntax: make ʸˡ򤭤ȻȤȳڤǤ

Makefile 򸫤ȡ褦ʤȤ񤫤Ƥơݤʾ˴ְ㤨䤹 make ʸˡϤȤϹǤ褦ˤʤäƤ롥 㤨 Makefile Ʊư򤹤褦ʡץ Makefile ϼΤ褦ˤʤ롥

.SUFFIXES␣:␣.dat␣.exe

DATA␣=␣f_sin.dat␣f_cos.dat␣f_sqr.dat


.c.exe:

____␉____ gcc␣-lm␣$<␣-o␣$@


.exe.dat:

____␉____ \rm␣-f␣$@

____␉____ ./$<␣>␣$@


all.eps:␣$(DATA)

____␉____ gnuplot␣"all2eps.gpl"


$(DATA):


warning.png Makefile ˤϷ֤εҤ̵Ȥդ褦̵̤ХβʤʤäȤˤʤ롥
notes.png ½:(;͵ʤ) make ʸˡĴ١ Makefile 򤷤褦



Report: ݡ

ʲβˤĤǽ¤긭ĴȹͻԤ
AppliedMath7-Report-11
Ȥ̾Ĥ e-mail ˤƶ˥ݡȤȤФ. ʤݡȤ e-mail TeX Ǻ̤ˤФƤ褤.

Exercises:

  1. Makefile ơץե(.c ȤĤƤ)ΥС򤵤褦ˤƤߤ.

  2. Makefile ˤɲäơǤեե򰵽̤뵡ǽĤƤߤ补

  3. TeX ȤΤϡμ TeX ʤͤƤߤ补



about Icons, ClipArts

For details, see JNorth_arrow-right-sm.png this.


*1 make ͤȤȤ
*2 ԥ塼Ǥвե¸Ƥ
*3 ֤ǤʤʸȤȡmake ȤˡʬΥ礤Ƥޤ (8ĤζǤTAB ΤĤǤ?)פʤƸ줿ꤹ롥ڤʤ