16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Development Tools<br />

5. DEVELOPMENT TOOLS<br />

Program/Project Development Tools<br />

Make rebuild programs when source files are modified<br />

touch put a new time on a file<br />

lint rigorously check program syntax & semantics<br />

cb c beautifier – correctly indent C programs<br />

indent a better program that indents C programs<br />

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />

UBUNTU: cb is not provided<br />

Indent is not installed<br />

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />

ctags generates "tags" file used by vi editor for quickly finding function definitions<br />

cc c compiler options<br />

cpp c preprocessor – called by cc<br />

ld link loader – called by cc<br />

size bytes for text, data and bss sections<br />

strip remove symbol & line information from common object file<br />

ar archival libraries e.g. /usr/lib/libxxx.a<br />

diff prints lines that differ in two files<br />

sccs toolkit used for managing revisions of programs and group projects<br />

adb/sdb assembler and symbolic debuggers<br />

dbx source code debugger<br />

tar write file tree to tape/disk<br />

compress compact to save space<br />

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />

UBUNTU: compress provided as “ncompress” but is not installed<br />

sccs is not provided<br />

adb/sdb is not provided<br />

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />

lex<br />

yacc<br />

generate c code for lexical analysis<br />

yet ano<strong>the</strong>r compiler-compiler<br />

MAKE<br />

When a program is written as multiple .c and .h files <strong>the</strong>re can be many steps to recompiling and eventually linking<br />

<strong>the</strong> entire system. Manually keeping track of which files that need to be recompiled can be a difficult and unreliable<br />

process. To automate this <strong>Unix</strong> provides <strong>the</strong> make program.<br />

When invoked, make searches for a text file called "Makefile" or "makefile" which defines <strong>the</strong> rules for rebuilding<br />

any part or sub-part of a system. In <strong>the</strong> most common case we wish to rebuild (compile) an object file<br />

corresponding to a .c file.<br />

For example a rule in <strong>the</strong> makefile like:<br />

# ------------------------<br />

main.a: main.c win.h<br />

cc -DDEBUG -c main.c<br />

# ------------------------<br />

would indicate that to build <strong>the</strong> target file "main.o" we need <strong>the</strong> files "main.c" and 'win.h". The commands to create<br />

<strong>the</strong> target file follow this heading and must be indented, <strong>with</strong> a (in this case <strong>the</strong> “cc" command) . Any shell<br />

command may be used.<br />

Programs often consist of many source files, each of which may need to pass through preprocessors, assemblers,<br />

compilers, and o<strong>the</strong>r utilities before being combined. Forgetting to recompile a module that has been changed – or<br />

that depends on something you've changed – can lead to frustrating bugs.<br />

51

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!