Computer Science 125

Introduction to Computer Science


A sample makefile:

This file is used by the make utility to help assembly programs that use multiple files. A makefile should be placed in the directory where your programs are. Once there, you need only type: "make run" to compile and run a non-applet program.

makefile:

# This is an example of a makefile for GNU make for use with
# java files (non applet version).

# Requirements:
#
# (1) All java source files for a project (and only those
# files) live in the same directory as this makefile. New
# files can be added as they are incorporated into the
# project without changing this file.
# (2) The file containing the function "main()" is named
# "Manager.java"
# (3) The lines beginning with javac and java must have a TAB
# before them. For example, without the tab before javac,
# you will get the error:
#
#          makefile:24: *** missing separator. Stop.
#
# To compile, simply type "make"
#
# To execute the program, type "make run".

%.class : %.java
         javac $<

objects := $(patsubst %.java,%.class,$(wildcard *.java))

program : $(objects)

run:
         java Manager