The Queen's University of Belfast

Parallel Computer Centre
[Next] [Previous] [Top]
Installation Utilities
Installation Utilities
- tar
- uncompress
- uuencode/uudecode
- gzip/gunzip
- make utility
- imake
- xmkmf
- aimk
tar
tape archive
- tar archives and extracts multiple files onto a single tar, file archive, called a tarfile.
- General form
tar cvf tarfile filename {c => create}
tar tvf tarfile {t => table of contents}
tar xvf tarfile {x => extract}
- Use the t option to view the contents and to examine the pathnames of the included files before extracting the files.
- Generally create a sub-directory and test the effect of the extract command in it.
uncompress
uncompress [-cv] filename
- Files are often compressed to reduce the amount of disk space needed and the time to download them.
- Files with the extension .Z are compressed and should be uncompressed as follows:
uncompress myfile.Z
- Uncompress creates a newfile of the same name minus the .Z . When the command completes the .Z file is deleted.
uuencode/uudecode
- uuencode converts a binary file to an ASCII-encoded file for transmission using mail.
- Often given the extension .uue
- Decode a file using:
uudecode encoded-filename
- The first line of an encoded file contains the name of the file to create when decoding. The first line will look something like:
begin 600 filename
{600 represents ownership and permission modes}
gzip/gunzip
- Commonly used public domain package for compressing and uncompressing files.
- Files with the extension .gz should be restored with gunzip
- Form:
gunzip filename.gz
- A new file of the same name but without the .gz extension is created
- gunzip can decompress files created by gzip, zip, compress or pack.
- Source: unix.hensa.ac.uk at path .archive/gnu/software/Utilities
make utility
- make is a powerful and flexible tool often used to compile and install public domain products. Also used to maintain and organize the various files associated with an application during development.
- Many features of make are not covered. The material presented attempts to cover the salient features needed for application installation.
- Shell scripts can be used instead of make but in all except trivial cases due to the complexity of a script, which would perform all the automatic checks, make is preferable.
Limitations
- Make does not execute in a cshell so built in commands such as alias, foreach, ... are not available.
- A Bourne shell is invoked if the command includes shell special characters or operators such as ; >> << > < | * ? [ ] $ = " ' ` \ # etc. If a shell is not required to parse the line make exec()'s the command directly.
- On some systems script files are executed under sh. Use #!/bin/csh, #!/bin/sh etc. to ensure the correct shell is used.
Makefile
- make reads a file called makefile which contains information about the files and how to build the application
- make searches the current working directory for either Makefile or makefile. As ls displays files with uppercase letters first Makefile is often preferred.
- Makefile lists the transformations between source and object files in the form of a dependency graph
- Executable commands may be associated with each node in the graph
Variables
- A variable may be defined as follows:
name = a list of words which may be \
quite long
names = fred jim joe
- Variables may be used in other variable declarations or in rules (see later). Variable substitution is obtained thus $(name)
names = $(names) tom dick harry
- Either () or {} may be used - this is not a cshell expansion
Defining dependencies
- Makefiles consist mostly of a dependency graph. These can be very complicated (calls to other makefiles or recursive calls to the same makefile are also possible).
- Configuring the makefile for an installation normally only requires simple alterations to the dependency graph.
- General form of graph node (the white space separators are mandatory):
target:<tab> list of dependencies
<tab> command line 1
<tab> command line 2
Special symbols
- $* is the target name minus extension
- $< is the source name
- $@ is the destination name
- $? is the list of out-of-date dependencies
- @ prefixed to a command to execute silently (also .SILENT)
- For example:
clean: myfile.c
@echo " Cleaning directory."
rm -f core $*.o $*
Example
# Makefile for Scales
CC = gcc
COMPILER_FLAGS = -g -ansi -pedantic -Wall \
-Wmissing -prototypes -Wno -implicit
# The name of the executable
PROGRAM = scales
# The object files
OBJS = main.o scale_routines.o gfunctions.o \
printing.o
# How to make the program
$(PROGRAM): $(OBJS)
@echo "Linking Object files"
$(CC) -o $(PROGRAM) $(OBJS)
$(OBJS): config.h my_headers.h standard_headers.h
@echo "Compiling Source files..."
$(CC) -c $(COMPILER_FLAGS) $*.c
clean:
\rm -f *.ln *.o core errs $(PROGRAM)
Default Transformations
- Make has an inbuilt set of rules which it will apply to files based on the file suffix, for example:
foo.c foo.f me.tiff
- Suffixes may be added. For example:
.SUFFIXES: .ada .new .old .GIF .tiff
would add these suffixes to the known list and
.SUFFIXES
would delete the list of known suffixes. This is rarely used.
- Additional rules may be added, the general form being:
.src.dst: ; rule
where .src and .dst are the source and destination suffixes.
.GIF.tiff: ; jpeg $< -o $@
- The above would add a rule for converting .GIF to .tiff. Anytime make encounters a dependency with a .GIF file it will apply the rule to the object file.
- The above may be combined to give the following makefile:
# Simple makefile example
#Define suffixes
.SUFFIXES: .GIFF .tiff
#Define a rule
.GIFF.tiff ; jpeg $< -o $@
#Simple dependency graph
all: tmp.tiff
- In the above example make checks the date of tmp.tiff against that of tmp.GIF and if the .tiff is out-of-date then the default transformation is applied
The command line
- Specific dependency nodes may be selected.
- For example:
%make install
%make clean
%make myfile
- Nodes may be the same as filenames but don't confuse the two.
- A number of command line switches are available. Some of the most useful are given;
- -d debug (can be undocumented)
- -f file use file instead of default makefile
- -n trace and print but do not execute commands
- -k if a command fails, continue on other nodes instead of quitting completely
Related Commands
- touch file change the update time on a file. Since make only updates if a target it depends on is newer, this will force the update
- ar maintains groups of files combined into a single archive file
- ranlib make a library randomly accessable
- install used within makefiles to copy new versions of files into a destination directory and to create the destination directory itself
- Creating libraries
dolib: $(OBJECTS)
rm -f $(LIBNAME)
ar rv $(LIBNAME) $(OBJECTS)
ranlib $(LIBNAME)
- Note that library names always have the form: libmyname.a
- Dependencies generation varies from system to system, but there is usually a way to generate a dependency graph for .h files included by C programs
- sometimes called mkdep
- sometimes a special c compiler switch
- sometimes a very hairy site dependent standard makefile
- Compilers have important switches which should be understood. On a Unix system these will include:
- -Ipathname paths to searched for .h files
- -Ldirectory paths to be searched for libxxx.a files
- -lname link with library libname.a
- Switches vary from system to system so the man pages need to checked, or use Gnu CC.
imake
- Uses the c preprocessor, cpp, to generate files for use with the make utility
- Makefiles are generated by combining
- a template
- cpp macros
- an input file called Imakefile
- Machine dependencies are separated from the description of the application to be built
xmkmf
- Used to create a Makefile from an Imakefile for applications which use X11 windows system
- Form
xmkmf [-a] [topdir [ curdir]]
- The installation process for X configures xmkmf to include the system specific location of X
- Runs imake with system specific arguments to convert the Imakefile to a Makefile
- The optional arguments are not normally used.
aimk
- aimk - architecture independent make file
- aimk is a portable make wrapper script
- Used to select PVM/XPVM options when building an application such that machine specific features such as file locations are handled
- Uses a file Makefile.aimk
- Invoked as aimk
- Covered in more detail later
[Next] [Previous] [Top]
All documents are the responsibility of, and copyright, © their authors and do not represent the views of The Parallel Computer Centre, nor of The Queen's University of Belfast.
Maintained by Alan Rea, email A.Rea@qub.ac.uk
Generated with CERN WebMaker