[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
-
[Assignment]
Groupings:
[EBoards]
[Examples]
[Handouts]
[Outlines]
[Readings]
Related Courses:
[CSC223 2007F (Davis)]
[CSC223 2004F (Rebelsky)]
Misc:
[SamR]
Back to Tools: Version Management with Subversion. On to Concepts: Dynamic Code.
This outline is also available in PDF.
Held: Thursday, March 4, 2010
Summary:
While our primary focus today is supposedly make
, we will
consider a wide variety of topics.
Related Pages:
Notes:
Overview:
The Most Beautiful Code I Never Wrote
targets
default
: The default thing or things to build (e.g.,
the application or library)
test
or check
: Instructions for testing the
main thing. (Generally predicated on building default
first.)
install
: Install the things we've just built.
clean
: Remove intermediate files (such as .o files).
package
: Put everything together into a tarball.
Part one: Building a simple C program
array-utils.{h,c}
, which contain the initial parts of
a library of array utilities. Your library need only include the
procedure str_swap(char *A[], int i, int j)
. Sample
code appears below.
quicksort.{h,c}
, which contain an implementation of the
Quicksort routine. You library need only contain
str_quicksort(char *A[], int lb, int ub)
, which sorts a subarray of an array of strings.
qsort.c
, which sorts the strings given on the
command line (that is, argv
)
qstest.c
, a simple unit test for
str_quicksort
. (You can use C's assert
procedure for writing your unit tests.)
qsort
application
when the make
command is invoked with no parameters.
qstest
when
the make
command is invoked with test
.
Part two: Making a library
Ideally, the library code we write would eventually end up in a library that we could link.
#include "array-utils.h"
to now read #include <array-utils.h>
.
CFLAGS
to
include an appropriate -I
flag.)
quicksort.h
.
array-utils.o
and
quicksort.o
into a library, which we'll call
libcsc323.a
. Write instructions for doing so. Note that
to make a library, you use two commands
ar cru libname.a source-files
ranlib libname.a
-lcsc323
)
rather than the .o
files.
Part three: A different task
It is often useful to convert html documents to more useful formats. Write a generic makefile for such conversion.
html2ps
to convert HTML files to Postscript.
ps2pdf
to convert PostScript files to PDF.
array-utils.h
#ifndef __ARRAY_UTILS_H__ #define __ARRAY_UTILS_H__ /** * Swap the elements in positions i and j of A. * Pre: * 0 <= i,j < length of A * A[i] = I * A[j] = J * Post * A[i] = J * A[j] = I * For all x, x != i and x != j, A[x] is unchanged. */ void str_swap (char *A[], int i, int j); #endif /* __ARRAY_UTILS_H__ */
array-utils.c
#include "array-utils.h" ...
Back to Tools: Version Management with Subversion. On to Concepts: Dynamic Code.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
-
[Assignment]
Groupings:
[EBoards]
[Examples]
[Handouts]
[Outlines]
[Readings]
Related Courses:
[CSC223 2007F (Davis)]
[CSC223 2004F (Rebelsky)]
Misc:
[SamR]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue May 11 12:40:52 2010.
The source to the document was last modified on Mon Jan 25 20:52:44 2010.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC323/2010S/Outlines/outline.12.html
.
You may wish to
validate this document's HTML
;
;
http://creativecommons.org/licenses/by-nc/2.5/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.