Make Svn Lab
Swe0607
Introduction
In this exercise you will get to know two tools that are used especially in the open source world. The first is a build management system
make of which many implementations exist. On linux systems
gnumake is most common. Have a look at
gnumake's manual if you have trouble writing Makefiles on pure intuition (or lack a vast number of monkeys).
The other tool that will be introduced is
subversion, a version control system. It has a centralized distribution system with one repository at the center. There are many different implementations for subversion. Apart from the very useful plugins for
eclipse and
visual studio, there is a very nice point and click interface for microsoft windows called
tortoise.
The best thing about subversion is the fact that the university allows you to create as many repositories as you like (well, as long as there's no abuse). When logged in at the university you can
create an account and
create a repository for it. You can give other students with an account access as well, for example if you're working together on a project or assignment.
Subversion is documented pretty well in the
manual and it also never hurts to have a look at svn's own build in help (type
svn help in a console).
Getting Started
This assignment will be performed on linux, but it will suffice to log onto a linux machine using
putty. You should be able to run make, flex, bison and svn in the console. Next download
this repository package and unpack it (I will assume it's located at
$REPO). Normally a repository would be at a server, but svn also supports direct file access.
Leave the repository alone, you should not alter any files within the repository's directory structure. Checkout a working copy of the repository with the following command:
svn checkout file://$REPO
Alternativaly use
tortoise: right-click in a directory in explorer and use the first item in the context menu named
SVN Checkout. The rest is up to you.
You have now the source code of a small interpreter. It already has a build script which uses bash. You can compile it by running
./buildme.sh and try it with
./interpreter < test-03.lam. The output should be
1000.
The actual purpose of the program is not very important, though. More
important are the following facts about the implementation:
- The program consists of several C source files and header files such as
main.c, abstract.h, etc.
- The parser is implemented using the Bison parser generator which translates a Bison parser specificition (
parser.y) into a C-language parser corresponding to the specified grammar.
- Likewise, the lexical analyser (lexer) is implemented using the Flex lexer generator. The lexer is specified in
lexer.l.
The Exercise
The current build script is not very easy to maintain and it will recompile all source files every time it is called. Compiling big programs can take a lot of time, so we should try to recompile as few files as possible.
Your job is to write a Makefile that will take care of this. It should at least have the following targets:
-
clean which removes all files created by the compilation process
-
interpreter which compiles the entire program and recompiles only the necessary parts if something has changed, this should be the default target
Furthermore you should introduce pattern rules for the lexer and parser files. Make already has some pattern rules for
*.l and
*.y files, but it uses the deprecated lex and yacc.
Since finding all the dependencies is probably not your favourite kind of work, you can use a tool called makedepend that does this for you. Have a look at the man page to get more information.
If you've finished the makefile, commit your changes to the repository.
Fiddling with subversion
Checkout a new working copy in a different directory and try to create conflicts. Conflicts can sometimes be resolved automatically and sometimes not, find out and describe when subversion cannot resolve a conflict. Describe how you created both kinds of conflicts.
Handing in the Exercise
Zip the repository (not your working copy!) which should now include the new makefile, make sure it still works after creating the conflicts. You can answer the question about subversions conflicts in a readme file.
Credits
This exercise is based heavily on a
previous exercise.
--
GideonSmeding - 27 Sep 2006