Unix make

Tom Kelliher, CS 245

Nov. 25, 2002

Administrivia

Announcements

Test Analysis report due 12/4.

Second exam on 12/6.

Assignment

From Last Time

``Lessons learned.''

Outline

  1. Introduction to make.

  2. make lab.

Coming Up

Open days.

Introduction to make

A make file for GalaEvents:

# Hi, I'm a comment.

JC = /usr/bin/javac

GalaEvents.class: GalaEvents.java Gigobite.class
   ${JC} GalaEvents.java

Gigobite.class: Gigobite.java
   ${JC} Gigobite.java

GalaEvents.java:

Gigobite.java:

clean:
   /bin/rm -f *.class
   echo "All shiny and new."

Notes:

  1. Make file constituent parts:
    1. Comments.

    2. Variable definitions and uses.

    3. Targets and dependency specifications.

    4. Shell commands (must be preceded by a Tab character).

      These are the instructions for making the target.

    5. Note the blank lines between target specifications.

  2. Make file name: Makefile. To run type make. To make a specific target, other than the first:
    make <target>
    

  3. Targets are made only when required. How does make know this?

Dependency graph for GalaEvents:

This information is embedded in the make file target dependencies.

A More Complex Example

XSLOAD = xsload
XSLOAD_SRCS = main.c bitstream.c pport.c jtag.c utility.c xc40.c
XSLOAD_OBJS = ${XSLOAD_SRCS:.c=.o}

ADDTEST = addTest
ADDTEST_SRCS = addTest.c pport.c utility.c
ADDTEST_OBJS = ${ADDTEST_SRCS:.c=.o}

EXES = ${XSLOAD} ${ADDTEST}
SRCS = ${XSLOAD_SRCS} ${ADDTEST_SRCS}
OBJS = ${XSLOAD_OBJS} ${ADDTEST_OBJS}

CC = gcc
CFLAGS = -O

${XSLOAD}: ${XSLOAD_OBJS}
   ${CC} ${CFLAGS} -o ${XSLOAD} ${XSLOAD_OBJS}

${ADDTEST}: ${ADDTEST_OBJS}
   ${CC} ${CFLAGS} -o ${ADDTEST} ${ADDTEST_OBJS}

root:
   chown root ${EXES}
   chmod 4555 ${EXES}

depend:
   makedepend -I/usr/src/linux-2.2.5/include/linux \
              -I/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include \
              -- ${CFLAGS} -- ${SRCS}

clean:
   /bin/rm -f ${OBJS}

spotless:
   /bin/rm -f ${EXES} ${OBJS}

make Lab



Thomas P. Kelliher
Thu Nov 21 08:23:05 EST 2002
Tom Kelliher