:









          - 

                    "        "













                  

                     

                        /P 2.1










                       

                            make














                           

                            1988















                        

         make,      
 ,    .






























































1.  

      make  [1],      
  ,    
          .
,       -
      (),  make  
  .    -
 ,      
  .       -
       ,  
 .     -
     : ,  -
, , ,   
 ..          
Make-,     -
   .    
       shell.  -
 Make-  make   -
               
 shell  ,       
         .
 ,  make   
        ,    
        
.         ,   Make- 
    ,  -
       .  -
,     make,  
         ,
   :

     -> make ->  -> 

       -
   ,     
 ,    - make "" 
,        
"  ,    ".

      ,  make   -
    . , 
 cat    :

   -    /bin/cat
   -   ./src/cmd/cat/cat.c
     -   ./man/man1/cat.1
  -   ./src/cmd/cat/Makefile

 ./src/cmd/cat/Makefile        
       cat -
.     make        
           (  200  )


                           - 3 -










.

2.    Make-

      make  ,    
 Make-.  Make-  
     ,    
 .       -
 . ,  

    a  b  c  d  e  f

        E.
  ,     -
       ,    
       A, B, C  D.  -
 ,   -  .    -
   ,    -
     ,   
.

      Make-    (x,y)    
       , -
     x.     x  -
,      ,     -
,   y  ()     ,
  x.        
  t(x,y).  t(x,y)  
 




                                        /\
                       E           /  \
                           |          /----\
                           |            ||
                 t(E,D )   |    t(E,C)  ||
                ----------------------- ||
               |                      | ||
           D                  C ||
        t(D,A) | t(D,B)               | ||
       ----------------               | ||
       |              |               | ||
   A          B               | ||
       |              |         t(C,e)| ||
 t(A,a)| t(A,b) t(B,c)| t(B,d)  t(C,d)| ||
  ------------   ------------   ------- ||
 |            | |            | |      | ||
 |            | |            | |      | ||
 a            b c            d e      f ||




                           - 4 -











    x  y -    ;

    x  y -   .


   t(x,y)   -
  (  )   .  
    make           Make-
,    .

      ,     -   .
        Make-e  
,         .
        .
       .  -
  E - ,  D  C  -   E. 
 D - ,  A  B -   D. ,   A
- ,  a  b -   A.    
-      
.

        -.  -
  ""  ,   ,  
  , ,  -    
"" - ,   ,  -
 ( ).

       Make-,   -
    .        
:

     E : D C              # E   D  C
             cat D C > E  #   1

     D : A B              # D   A  B
             cat A B > D  #   2

     A : a b              # A   a, b
             cat a b > A  #   3

     B : c d              # B   c, d
             cat c d > B  #   4

     C : e f              # C   e, f
             cat e f > C  #   5

     clean clear:
             -rm -f A B C D E

  6 .       
         .  
 :     ,  


                           - 5 -










  (),  ,   -
,        (),  
  .          
.        :
       .  -
       
shell.      Make- -
    ( 8 ) -   -
 .

       ,    # 
  ,  .    -
  .   Make-    
  Makefile,      Make-  
   .  ,   Make-
  Makefile,      a, b,
c  d.  A, B, C  D ,     make
   -     A, B, C  D.  -
   Make-,      
, ..     make.

        Make-:

     E : D C
             cat D C > E

  D  C      ,
  E "",   D  C,  make  -
  -   .     -
  D / C,     
 D / C,      .   ,
     E,   -
    make      -
      E.  ,  
 D / C,    D  /  C    
,        , 
     make  -
  -   E.

         Make-:

     D : A B
             cat A B > D

  A, B  D         -
,             Make-
 ( D  ).     
 A / B,      A
/ C,     .  ,   -
    D,    -
        Make-.
,        A / B,  
 A / B   ,         


                           - 6 -










  ,      
    Make-.

        Make-:

     A : a b
             cat a b  > A

   a  b     .   
         -
.      A,     
    ,   
.        
.

        Make-:

     B : c d
             cat c d  > B

     ,    -
    .

        Make-:

     C : e f
             cat e f > C

   e  f     .   
         -
.      C,     
    ,   
.        
.

        make    
   .  , ,   
D,      

       % make  D

       C    D,    
  

       % make  C D

 ,  -     
  Make-.    ,  make
         Make-
.       ,   -
 Make-.




                           - 7 -










             ,  
    make.   -
  ,  /      
  .         -    
Make- (  ).     -
         .  
  ,         (clean  
clear),        
, :

            % make  clean
    
            % make  clear

       A, B, C, D  E.

            
shell  :

    sh -c _

     sh ( -
  0),    (         
  )  make       .
      .   
  6- :     
"-",         -
  rm.

      Make-      .
        
Make-       
shell,      .  
        .
 Makefile   :




















                           - 8 -










     SRC1 = a b        # 
     SRC2 = c d
     SRC3 = e f
     SRC4 = A B C D

     E : D C
             cat D C > E

     D : A B
             cat A B > D

     A : $(SRC1)     # A   SRC1
             cat $(SRC1) > A

     B : $(SRC2)     # B   SRC2
             cat $(SRC2) > B

     C : $(SRC3)     # C   SRC3
             cat $(SRC3) > C

     clean clear:
             -rm -f $(SRC4)

  Make-  -   ,
   SRC  .  
      ,
  $(SRC1).    
           
Make-.

      make    -
          .
,     .o    
     .c (  )  .s (
).   . ,   a.c,
b.c,  c.c   d.s,  ,   pro-
gram.   a.c, b.c  c.c  

    # include program.h

..    program.h. Make-   
    3 

    program: a.o b.o c.o d.o
             cc a.o b.o c.o d.o -o program

    a.o b.o c.o: program.h

  make        program.     
    :





                           - 9 -










      cc  -c a.c
      cc  -c b.c
      cc  -c c.c
      as - -o d.o d.s
      cc a.o b.o c.o d.o -o program

   ,    -
         .c 
.s,      Make-    ,  
   .  , , 
 make  e     
 program.h,   :

      cc  -c a.c
      cc  -c b.c
      cc  -c c.c
      cc a.o b.o c.o d.o -o program

   Make-      
b.c,  :

      cc  -c b.c
      cc a.o b.o c.o d.o -o program

, , ,      c.o,  
  

    make c.o

        
  Make-;  
       .

3.    Make

             -
      Make.     
      .



      ,    "_", 
        ([...], ?, *),  /   "."

 = 
      .      
     ,         
      .

     $()
     ${}
     $



                           - 10 -










       .   -
       $  ,  $$.


     ,    #    .  -
         # ,   
      .

  
       .      -
      \ ,    .

 , 
             ,
         .   
      .

_



        .  _    -
     .

 ._._:



           .     
     Make-         -
     ,   ,     -
       :

          .SUFFIXES: _


_ :[:] _
     _.  _     -
     .             
     _        
     _  _.

_ [_]
     _.  _ - .   -
         /   .  _   
       ,      -
       .   _      
     ,       ,  
     _      (  ,    
     Make-).

_ [_] [#]
     _.  _  -  .  


                           - 11 -










          "*", "?", [...], -
      /  .  _       ,
               Make-
     ,       -
     .  _     ,  
         ,  _
           (   ,      Make-
     ).

_ [#]
 ...............
_ [#]


     _.       -
       Shell.

''__shell
      _.


     _       -
        ";". _   
      :

          ''____shell    1

          ''@___shell    2

          ''-___shell    3

          ''-@__shell    4

             ;
             0, make -
         .     -
            ;  
             0,  make  
           .      
         ;   
              0, make   
       .    
          ;   -
           0, make   
        .   
      (     )  
          .       
         sh        :    sh     -c
     __shell


          -
      .     


                           - 12 -










_       
:

@     ;

?            ,      
     _.       .


         _    
  :

*    __;

@    __._;

<&lt;    __._.

4.   

       Make-   
    /  
   make  .   ,  -
      , 
    Make-.  
:  @,   - _; -
 ?,   -   _, -
  _.

       "@"  "?" 
            
 .       
  Make-,    .  -
 make      -
      Make-.  -
  ,    
 ;     -
 ,      -
     Make-.    -
           Make-
   ,     -
  Make-      -
,     .    -
,          
. ,

     A = $B
     B = $A

     Make-.

          -
      shell.  ,   


                           - 13 -










:

     -rw-r--r-- 1 user    15658   6 16:03 1.m
     -rw-r--r-- 1 user     2158   8 16:38 2.m
     -rw-r--r-- 1 user     5185   9 17:38 3.m
     -rw-r--r-- 1 user     4068  28 20:56 6.m
     -rw-r--r-- 1 user      100   9 14:30 f2
     -rw-r--r-- 1 user       66   9 17:42 f3

 Make-  Makefile :

     A = *
     B = f?
     C = [0-9].*

     aaa :
             echo $A
             echo $B
             echo $C

    make -s    :

     1.m 2.m 3.m 6.m f2 f3
     f2 f3
     1.m 2.m 3.m 6.m

 Make-     -
     .   -
    . :

     A = *
     B = [pg]*
     C = f?r*
     DIR1 = .
     DIR2 = /etc
     DIR3 = /usr/bin

     aaa :
             echo ${DIR1}/$A
             echo ${DIR2}/$B
             echo ${DIR3}/$C

  :

     ./1.m ./2.m ./3.m ./6.m ./f2 ./f3
     /etc/getty /etc/group /etc/passwd
     /usr/bin/fgrep


      ,    -
   . , 
Makefile



                           - 14 -










     =  ${}
     = 
     = 
     = , .
     =
     =
     = ,  .
     = $() $()
     = , , .

    t =    .
    x =    .
     = d e

     :  ${}
            echo ' ' $@
            echo '$$? -   :' $?
            echo '$$@ -   :' $@
            echo ' : ' $()
            echo '. : ' $()
            echo ' '

    ${} : b c
            echo ' ' $@
            echo '$$? -   :' $?
            echo '$$@ -   :' $@
            echo ' '

     ${}: ${}
            echo ' ' $@
            echo '$$? -   :' $?
            echo '$$@ -   :' $@
            echo ' : ' ${}
            echo $t
            echo $x
            echo ' '

     b:
     c:
     d:
     e:

    ,  $  
  ,    
 ,  $()    ${}  -
.    b,  c,  d    e    
      "?".  ,  
  make -s,    :







                           - 15 -










       
     $? -   : b c
     $@ -   : 

       
     $? -   : d e
     $@ -   : 
      :  , .
        .
        .

       
     $? -   :  
     $@ -   : 
      :,  .
     . : , , .

      .
 

    make -s  = , .

   :

       
     $? -   : b c
     $@ -   : 

       
     $? -   : d e
     $@ -   : 
      :  , .
        .
        .

       
     $? -   :  
     $@ -   : 
      :  , .
     . :  , , .


5.     Make-

        :

         ;

        ;

        ;




                           - 16 -










         /  ;

     ,    make,  -
          Make-.


      ,         
Make-,       .   
             
          . 
    ,     -
  .

        :  -
        ,  -
 .        , 
   ,    (-
)            
  .         ,
    ,    
.  ,  Make-  

    monitor.c : monitor.h

 ,   monitor.c    monitor.h.
  monitor.h     , 
               
monitor.o,   monitor.h , make 
      .     Make-  
 ,      
 ,   ,  
    .   ,   
    .

                
_   :   ,
   ,  _ 
  .        
   :

    __ : _    <---| 1 |

    __ : _    <---| 2 |
                 _    <---| 4 |

    __ : _    <---| 3 |


                
_    .    
  :




                           - 17 -










    __ :: _   <---| 1 |
                  _   <---| 2 |

    __ :: _   <---| 3 |
                  _   <---| 4 |

    __ :: _   <---| 5 |
                  _   <---| 6 |


6.    Make-

      make      
  Make-.    -
  :

     .SILENT     -    ;
     .IGNORE     -   ;
     .DEFAULT    -   ;
     .PRECIOUS   -   .

 .SILENT  .IGNORE          Make-
,       -s  -i, DEFAULT
 PRECIOUS   Make-.    -
 Make-:

    aa:     bb
            echo   $@

    bb:
            echo   $@
            ppp     #  
            sort e  #   e

       :

     echo   bb
       bb
     ppp    #  
     sh: ppp:  
     ***   1
     .

 make     .  
,        . 
     :


       -s      make;

       Make-  SILENT;




                           - 18 -










          @.


             -    
   .      -
   

     ''@_

   SILENT.

    aa: bb
           echo   $@

    bb:
           echo   $@
           ppp    #  
           sort e #   e

     .SILENT:

       :

       bb
     sh: ppp:  
     ***   1
     .

   make   . -
      (Make-
 ):


       -i   make  ;

       Make-  IGNORE;

          "-".


                
    ,   
     ,      
:

     ''-_

    SILENT    IGNORE.  
     






                           - 19 -










    aa: bb
           echo   $@

    bb:
           echo   $@
           ppp    #  
           sort e #   e

     .SILENT:

     .IGNORE:

       :

       bb
     sh: ppp:  
     ***   1 ()
     sort:    e
     ***   1 ()
       aa

 DEFAULT        
        .  
DEFAULT     ,    
    ,  
 , :





























                           - 20 -










    aa: bb
           echo   $@

    bb:  a b c d
           echo   $@
           ppp    #  
           sort e #   e

     .SILENT:

     .IGNORE:

     .DEFAULT:
           echo   .DEFAULT  $@

       :

       .DEFAULT  a
       .DEFAULT  b
       .DEFAULT  c
       .DEFAULT  d
       bb
     sh: ppp:  
     ***   1 ()
     sort:    e
     ***   1 ()
       aa

              Make-
.          , 
     (    -
)  .  ,    
       ,  
      .  
 ,   PRECIOUS,  -
:

    aaa:   file
           sort file > $@

     .PRECIOUS:


      Make-  
 CTRL/C,  $@  .

7.    

      Make-       -
   .       -
    ,    
  Make-,   . 
    make      .   


                           - 21 -










         .
,         ._1  
     ._2,   -
   :

    ._2 : ._1

                        

,    ,        -
,       , 
     . ,  *.c
     *.o   , ,
,           
  .    make   -
   

     ._1._2:

             _

     .SUFFIXES: ._1 ._2

  Make-    ,  ,
                    
._1,       ,    
   -     ._2.  -
      ,     -
 .    SUFFIXES 
   ,    
  .        .
,           Make-
     .    
   :

@    - _a (._2);

<&lt;    - _a (._1);

*    - .

      . ,    *.c
  *.k.          *.t,    -
 result.   ,   *.c   
file.h (  #include file.h).   -
      :









                           - 22 -










                         result
                           |
                          .t
                           |
                        --------
                        |      |
                       .c     .k

,   ,   :














































                           - 23 -










    result: d.t a.t b.t c.t
           echo ' ' $@
           echo '  $$@ - ' $@
           echo '  $$? - ' $?
           touch $@

     .k.t :
           echo '  .k.t :'
           echo '  $$* - ' $*
           echo '  $$@ - ' $@
           echo '  $$? - ' $?
           echo '  $$< - ' $<
           touch $@

     .c.t :
           echo '  .c.t :'
           echo '  $$* - ' $*
           echo '  $$@ - ' $@
           echo '  $$? - ' $?
           echo '  $$< - ' $<
           touch $@

    a.c b.c c.c : file.h

     .SUFFIXES: .t .c .k

       make -rs :

        .k.t :
        $* -  d
        $@ -  d.t
        $? -  d.k
        $< -  d.k

        .c.t :
        $* -  a
        $@ -  a.t
        $? -  file.h a.c
        $< -  a.c

        .c.t :
        $* -  b
        $@ -  b.t
        $? -  file.h b.c
        $< -  b.c

        .c.t :
        $* -  c
        $@ -  c.t
        $? -  file.h c.c
        $< -  c.c

        result


                           - 24 -










        $@ -  result
        $? -  d.t a.t b.t c.t

,   .k.t    ,  -
  .c.t -  ,      
,        result.  
  "?"        ,   
  -  .  "@"  -
  -  ,     -   -
 ._2.

      make     -
           .
    Make- , 
make         -r.  
        
        .   
,     :

     .out   -       ;
     .o     -     ;
     .c     -       ;
     .f     -       ;
     .p     -       ;
     .s     -      ;
     .l     -      lex;
     .y     -      yacc;

 ,    Make-    
:

LOADLIBES =   #  
AS = as -     #  
CC = cc       #  -
CFLAGS =      #  -
PC = pc       #  -
PFLAGS =      #  -
FF = f77      #  f77-
FFLAGS =      #  f77-
LEX = lex     #  
LFLAGS =      #  lex
YACC = yacc   #  
YFLAGS =      #  yacc

         
Make-,  ,      CFLAGS = -O,
   CFLAGS   
   Make-e.     -
     Make-,   -
    .





                           - 25 -










             .c   .f   .p   .s   .l   .y
              |    |    |    |    |    |
              |-------------------------
              |
              |
              --->  .out    <--- .o  ---
                                       |
                                       |
              --------------------------
             |    |    |    |    |    |
            .p   .f   .c   .s   .l   .y
                       |
                      ---
                     |   |
                    .l  .y








































                           - 26 -










 .l.out:
       $(LEX) $<
       $(CC) $(CFLAGS) lex.yy.c $(LOADLIBES) -ll -o $@
       rm lex.yy.c

 .y.out:
       $(YACC) $(YFLAGS) $<
       $(CC) $(CFLAGS) y.tab.c  $(LOADLIBES) -ly -o $@
       rm y.tab.c

 .f.out:
       $(FF) $(FFLAGS) $< $(LOADLIBES) -o $@
       -rm $*.o

 .o.out:
       $(CC) $(CFLAGS) $< $(LOADLIBES) -o $@

 .c.out:
       $(CC) $(CFLAGS) $< $(LOADLIBES) -o $@

 .p.out:
       $(PC) $(PFLAGS) $< $(LOADLIBES) -o $@

 .s.out:
       $(CC) $(CFLAGS) $< $(LOADLIBES) -o $@

 .l.c:
       $(LEX) $<
       mv lex.yy.c $@

 .y.c:
       $(YACC) $(YFLAGS) $<
       mv y.tab.c $@

 .l.o:
       $(LEX) $(LFLAGS) $<
       $(CC) $(CFLAGS) -c lex.yy.c
       rm lex.yy.c; mv lex.yy.o $@

 .y.o:
       $(YACC) $(YFLAGS) $<
       $(CC) $(CFLAGS) -c y.tab.c
       rm y.tab.c; mv y.tab.o $@

 .s.o:
       $(AS) -o $@ $<

 .f.o:
       $(FF) $(FFLAGS) -c $<

 .c.o:
       $(CC) $(CFLAGS) -c $<



                           - 27 -










 .p.o:
       $(PC) $(PFLAGS) -c $<

 .SUFFIXES: .out .o .c .f .p .y .l .s

,   f[1-6].c     -
 result.  f[1-3].c  

    # include file1.h
    # include file2.h

      f[4-6].c  

    # include file3.h

     result:

 CFLAGS = -O
 LDFLAGS = -s -n -o
 OBJS = f1.o f2.o f3.o f4.o f5.o f6.o

 result:  ${OBJS}
        ${CC} ${OBJS} ${LDFLAGS} $@

 f1.o f2.o f3.o : file1.h  file2.h

 f4.o f5.o f6.o : file3.h

   :

 cc -O -c f1.c
 cc -O -c f2.c
 cc -O -c f3.c
 cc -O -c f4.c
 cc -O -c f5.c
 cc -O -c f6.c
 cc f1.o f2.o f3.o f4.o f5.o f6.o -s -n -o result

     

    touch file3.h

   ,   :

     cc -O -c f4.c
     cc -O -c f5.c
     cc -O -c f6.c
     cc f1.o f2.o f3.o f4.o f5.o f6.o -s -n -o result

      touch f3.c 
  




                           - 28 -










     cc -O -c f3.c
     cc f1.o f2.o f3.o f4.o f5.o f6.o -s -n -o result

      
    ( -r),    
 ,    Make-. ,    -
          a1.t,
a2.t  a3.t,     sed,  -
        a1.c  a2.c  a3.c.    Make-
  :

     CFLAGS = -O
     LDFLAGS = -o
     OBJS = a1.o a2.o a3.o f1.o f2.o f3.o f4.o f5.o f6.o

     result:  ${OBJS}
            ${CC} ${OBJS} ${LDFLAGS} $@

     f1.o f2.o f3.o : file1.h  file2.h

     f4.o f5.o f6.o : file3.h

     a1.c: a1.t

     a2.c: a2.t

     a3.c: a3.t

     .t.c:
           sed s/aaa/bbb/ < $< > $*.c

     .SUFFIXES: .t

  :

 sed s/aaa/bbb/ < a1.t > a1.c
 cc -O -c a1.c
 sed s/aaa/bbb/ < a2.t > a2.c
 cc -O -c a2.c
 sed s/aaa/bbb/ < a3.t > a3.c
 cc -O -c a3.c
 cc -O -c f1.c
 cc -O -c f2.c
 cc -O -c f3.c
 cc -O -c f4.c
 cc -O -c f5.c
 cc -O -c f6.c
 cc a1.o a2.o a3.o f1.o f2.o f3.o f4.o f5.o f6.o -o result

Make       -
.     SUFFIXES    t, -
 c     .



                           - 29 -










8.     Make-

           :    
       (  -
  ).         
,    ,    ,   .
             :    
_            
(,    ,   ,
    ,     ).
    Make-    
     : _    
 .         
       (     
 _  ).   _   -
       :

    __(_____)

  ,       -
    

    __((____))

  Make-   
  libP.a:

    L      =   libP.a
    CFLAGS =  -O

    $(L)::
           ar r $(L)

    $(L):: $(L)(Ia.o) $(L)(La.o) $(L)(Da.o)

    # Iabs, Labs, Dabs -  

    $(L)(Iabs.o):     lib/Ia.c
           $(CC) $(CFLAGS) lib/Ia.c
           ar r $(L) Ia.o
           -rm -f Ia.o

    $(L)(Labs.o):     lib/La.c
           $(CC) $(CFLAGS) lib/La.c
           ar r $(L) La.o
           -rm -f La.o

    $(L)(Dabs.o):     lib/Da.c
           $(CC) $(CFLAGS) lib/Da.c
           ar r $(L) Da.o
           -rm -f Da.o

             -


                           - 30 -










Make-    . 
       "$(L)::"  -
     .    -
   ,      
    ,  100,  
  100   .      -
            
 ,      
         
 ,  ,      ,    
   Make-.   ,
   ,      
    .

      Make-,        
.            
    mylib

    m1.c m2.c m3.c m4.s m5.c m6.c m7.s

,       -
    :

    m4.o m2.o m1.o m5.o m6.o m7.o m3.o

 Make-:





























                           - 31 -










    CFLAGS = -O
    SRC    =  m1.c m2.c m3.c m4.s m5.c m6.c m7.s
    LIB    =  mylib

    ${LIB}:  ${SRC}
         echo $? | sed s/\\.[cs]/\\.o/g > list
         make `cat list`
         ar cr $@ `cat list`
         lorder $@ | tsort > list
        -@if cmp list topology ; \
         then \
             rm -f `cat list` list;\
         else \
             ar x ${LIB}; rm $@;\
             mv list topology;\
             ar cr $@ `cat topology`;\
             rm -f `cat topology`;\
             echo  $@ .;\
         fi
         ranlib ${LIB}
         echo  $@ .

    m1.c : x.h
            touch m1.c

    m2.c : x.h y.h
            touch m2.c

    m3.c : x.h
            touch m3.c

    m5.c : y.h
            touch m5.c

    m6.c : x.h
            touch m6.c

         
.   ,       
.          
    e   .  
    ,  
   "?" -  , -
    mylib.       ,  
       .  ,    Make-
         
  ,      
   o,   make   
     .    list -
     .  

    echo $? | sed s/\\.[cs]/\\.o/g > list



                           - 32 -










    list     o. 
sed         -
 c  s  o.   ,    list    
-,          
 .     ,  ,
:

    make `cat list`

            
.          
   mylib

    ar rc mylib `cat list`

   mylib ,  ,  
     ,   
  (   ar   cr).

       "make `cat list`"   Makefile
(          Make-
).  ,       
Make-.            
     ,  
    .    make 
,       -
 Make-.    ,   -
  Make-       -
     .    
  ,         
      -,   make  
 .

        ,  
  .         Make-  
 lorder  tsort.  Lorder    -
    ,  tsort   
 ,      -
,  ..          
      .   
Make-     ,      
     list   
      topology.     
 :

            ,  
   topology     list.

          .    
    topology    list  ,
-,         
topology,  -,        
 (       ),


                           - 33 -










        .  -
   

    ar x mylib

         
 .     .
        ,   
             topology  
:

    ar rc mylib `cat topology`

 shell     if      
:

    if     _;\
    then \
           _;\
    else \
           _;\
    fi

 Makefile   :

    -@if cmp list topology ; \
      then \
          rm -f `cat list` list;\
      else \
          ar x $(LIB); rm $@;\
          mv list topology;\
          ar cr $@ `cat topology`;\
          rm -f `cat topology`;\
          echo  $@ .;\
      fi

     :

     ''-@if cmp list topology ; \

    8  .   "-"
,         shell  if 
    0.   "@"  
    .

      Make-     
  .        (
)    LIB, SRC    
   .     
 ,         ranlib
$@.          
 .



                           - 34 -










      ,  

     make -s
     cc  -c m1.c
     cc  -c m2.c
     cc  -c m3.c
     as - -o m4.o m4.s
     cc  -c m5.c
     cc  -c m6.c
     as - -o m7.o m7.s
     cmp:    topology
      mylib .
      mylib .


      mylib ,     -
,   x.h

     touch x.h
     make -s
     cc  -c m1.c
     cc  -c m2.c
     cc  -c m3.c
     cc  -c m6.c
      mylib .


          m5.c.   -
   :  m5   
m1

     make -s
     cc  -c m5.c
      mylib .
      mylib .

  topology    

    m4.o m2.o m5.o m1.o m6.o m7.o m3.o


         .    -
    SRC  Make-.    m8.c , -
    m5.c

     cc  -c m8.c
     list topology : char 12, line 3
      mylib .
      mylib .

  topology    

    m4.o m2.o m8.o m5.o m1.o m6.o m7.o m3.o


                           - 35 -










       m1.c ,      m2.c,
  m2.c  m1.c, ..   -
    m1  m2

     make -s
     cc  -c m1.c
     tsort:  
     tsort: m2.o
     tsort: m1.o
      mylib .
      mylib .

 tsort       -
.    ,    , -
   .      mylib  
,           , 
   .

9.      Make

         Make-      
Makefile.           
      make    


    make -f _

      Make-
,      Make-,    
make  

    make -f _1 -f _2  ..

      Make-    
,       .

        Make-      make  
  Make-, :

    LLL: a b c d
          make -k -f _Make- $?

  ,          -
 ,  -k    -
    Make-,    
        .      
  ,      Make-,  
   Makefile    
     .

          -
.  ,  Make-  



                           - 36 -










    SRC = a1.c a2.c a3.c     # 

 a3.c   # 9 ,     
,      SRC.

       "<"  "*"    
     ,     -
   .

     ,         -
     shell.    -
      "-"    "@"     make.
  make     -
.     -     ,  
     shell.   ,
,     

     ''#cat file

,           "exec(#   cat
file);"  -?

            ,
        
.   :

    _:[:];  __ [# ]

 ";" .

           
Make-    ,      . 
    ,   
        -
,         -
  ()     Make-.  
  ,   -,  -
:

    print: f1 f2 f3
           print $?
           touch print

     .DEFAULT:
           touch print

        print. 
        ,  -
   .  DEFAULT  
  ,   print .

      touch  ,   -
         . 


                           - 37 -










,      make      
 .

            make    
:

-d    ,       
        Make-.

-f       Make-.  -
         Makefile  makefile.   ,
       Makefile.      -
        -f  .

-i           
     .    IGNORE.

-k          ,  
            -
      ,    -  .

-n   ,               Make-
     .

-p        Make-.

-q        .
          , -
      -1,  0.

-r           -
     ,    .

-s      .    -
      SILENT.

-S     Make-   -
      - .

-t        (-
       )   .

10.    Make-

         Make-      -
,         -
   .       
 mkmf.      .  -
   f.h, f1.c, f2.c  f3.c,   -
   a.out:





                           - 38 -










     /*
     **  f.h
     */
     # include       <stdio.h>
     # include       <ctype.h>
     # include       <time.h>

     /*
     **  f1.c
     */
     # include       f.h

     main(ac, av)
     int ac;
     char **av;
     {
           f1(); f2(); f3();

     printf("   example.\n");
     }
     f1(){
           return;
     }

     /*
     **  f2.c
     */
     # include       f.h

     int f2(){
           return( a2());
     }
     # include       <stat.h>
     char *a2(){
          return;
     }

     /*
     **  f3.c
     */
     # include       f.h

     int f3(){
            return( nn());
     }

     char *nn(){
            return;
     }

          .  
  mkmf.            
Makefile     a.out:


                           - 39 -










    DEST          = .

    EXTHDRS       = /usr/include/ctype.h \
                    /usr/include/stat.h  \
                    /usr/include/stdio.h \
                    /usr/include/time.h

    HDRS          = f.h

    LDFLAGS       =

    LIBS          =

    LINKER        = cc

    MAKEFILE      = Makefile

    OBJS          = f1.o f2.o f3.o

    PRINT         = pr

    PROGRAM       = a.out

    SRCS          = f1.c f2.c f3.c

    all:            $(PROGRAM)

    $(PROGRAM): $(OBJS) $(LIBS)
                @echo -n " $(PROGRAM) ..."
                @$(LINKER) $(LDFLAGS) $(OBJS) \
                           $(LIBS) -o $(PROGRAM)
                @echo "."

    clean:;     @rm -f $(OBJS)

    depend:;    @mkmf -f $(MAKEFILE) \
                PROGRAM=$(PROGRAM) DEST=$(DEST)

    index:;     @ctags -wx $(HDRS) $(SRCS)

    install:    $(PROGRAM)
                @echo  $(PROGRAM)  $(DEST)
                @install -s $(PROGRAM) $(DEST)

    print:;     @$(PRINT) $(HDRS) $(SRCS)

    program:;   $(PROGRAM)

    tags:       $(HDRS) $(SRCS)
                @ctags $(HDRS) $(SRCS)

    update:     $(DEST)/$(PROGRAM)



                           - 40 -










    $(DEST)/$(PROGRAM): $(SRCS) $(LIBS) \
                        $(HDRS) $(EXTHDRS)
                @make -f $(MAKEFILE) \
                    DEST=$(DEST) install

    ###
    f1.o: f.h /usr/include/stdio.h \
              /usr/include/ctype.h \
              /usr/include/time.h

    f2.o: f.h /usr/include/stdio.h \
              /usr/include/ctype.h \
              /usr/include/time.h  \
              /usr/include/stat.h

    f3.o: f.h /usr/include/stdio.h \
              /usr/include/ctype.h \
              /usr/include/time.h

 mkmf    - -
    /usr/new/lib/p.Makefile,   -
     .

       mkmf      :  
    -    -
  ,      include-
   ,    -
    -.         
   .

     Makefile  ,    -
.    ,     mkmf,
     ,     
      .

      Makefile,      -,
  :

CFLAGS
      -;

DEST
     ,     ;

EXTHDRS
        include-;

HDRS
        include-,      
     ;

LIBS
          ;


                           - 41 -










MAKEFILE
        Make-;

OBJS
       ,        -
     ;

PROGRAM
      ,   ;

SRCS
           ;


         EXTHDRS,  HDRS,  OBJS,  SRCS
    mkmf     
.        
Makefile    ,     
.

         Make-,      
   :

all
     ,         
     ;

clean
       ;

depend
       Make-    -
      Makefile;

index
         ;

install
     ,         
     ;

print
      include-   ;

tags
       ./tags -  ,   
      ,   ;

update
      Makefile, ,     
          .    
               
      ,      .


                           - 42 -










        f[123].c, f.h  Makefile,  
     DEST  /usr/tmp  -
 PROGRAM -  example.      
:

    % make program install clean

       

    cc  -c f1.c
    cc  -c f2.c
    cc  -c f3.c
     example ... .
       example
     example  /usr/tmp

  

     % make index

          

     a2       5 f2.c      char *a2(){
     f1      11 f1.c      f1(){
     f2       2 f2.c      int f2(){
     f3       2 f3.c      int f3(){
     main     5 f1.c      main(ac, av)
     nn       6 f3.c      char *nn(){

 mkmf   Makefile    -
.                     -
/usr/new/lib/l.Makefile     -
 LIBRARY ( )    extract (-
             ),
library (   ).

              -
 /usr/new/lib/[lp].Makefile     
  .              
l.Makefile  p.Makefile.















                           - 43 -












 1. " .,  .      
    UNIX. - .:   , 1986." AI

 2. " .   UNIX.- .: , 1986." AN

 3. " .      UNIX.  -  .:
    , 1987." AM

 4. " .       UNIX.  -
    .:   , 1985." AE

 5. "     .
    - : , 1985." AK

 6. "     /
    ..  ,  .. , ..   . - .:
      , 1985." AH

 7. " .,  .,  .    
    .        .  - .:   ,
    1985." AF

 8. " .     UNIX. - .:
      , 1985." AJ

 9. " .,  .        
     . - .:   , 1986." AG

10. "Aho A. V., Kernighan Brian V. W., Weinberger  Peter  J.
    AWK - a pattern scanning and processing language. Second
    edition. UNIX Programmers manual,  42  BSD,  1980.  Bell
    Laboratries: Murray Hill, New Jersey, 1978." AL

11. "Feldman S. I. Make - a program maitaining computer pro-
    gramms.  Bell  Laboratries:  Murray  Hill,  New  Jersey,
    1978." AB

12. "Joy W. N. An introduction the UNIX C-shell.  UNIX  Pro-
    grammers  manual, 42 BSD, 1980. Bell Laboratries: Murray
    Hill, New Jersey, 1978." AA

13. "Johnson S. C. YACC  -  yet  another  compiler-compiler.
    Comp.  Sci.  tech.  rep.  N 32. Bell Laboratries: Murray
    Hill, New Jersey, 1975." AD

14. "Lesk M. E. Lex - lexical analyzer generator. Comp. Sci.
    tech. rep. N 39. Bell Laboratries: Murray Hill, New Jer-
    sey, 1975." AC





                           - 44 -










                         



     .........................................    2

1.   ..........................................    3

2.    Make- ................    4

3.    Make .............................   10

4.    .....................   13

5.     Make- ................   16

6.    Make- ..................   18

7.     ..............................   21

8.     Make- ...............   30

9.      Make ........   36

10.   Make- ......   38

     ........................................   44




























                           - 45 -




Last-modified: Mon, 29 Jun 1998 14:13:47 GMT
: