Once you have unzipped you will have a directory structure that looks like this:
- avsdk +- apps +- bin +- inc +- libGerard's free sdk is entirely command line based, so in order to make things easy you will need to have the avsdk\bin directory on your path. Under NT this can be done with the "System" control panel under "Environment". Under Win95 I think you have to put it in your autoexec.bat to make the change permanent. Or you can just say something like
set PATH=%PATH%;C:\the\path\to\the\free\avsdkAt the command prompt you plan on using every time you start.
Just a note, you can also use relative paths, which can be handy and slightly more compact than full paths:
set PATH=%PATH%;..\..\bin
avapp -p1 -rsokoban.app(-p1 means use com1, -p2 com2, etc. -r means replace any existing sokoban.app that is already on the Avigo)
<...2 hours and 10 sokoban levels later...>
So what files are necessary? You need at least a .c file, a
makefile, an icon.bmp file, and a .def file.
Copy the above files from, say, hellow, in a new directory for your
app. Let's call it 'myapp'. Change the current directory to
the new myapp directory with 'cd'.
So how does make do it's magic? It's all in the rules.
Rules take the form:
Let's look at a concrete example from hellow's makefile:
These lines are very similar:
That all makes sense, but what if we wanted to say that any
file ending in ".c" should be compiled to become a
".rel" file? That's what these lines do:
Rolling Your Own
To make your own apps, the easiest way is to just copy the files
for hellow or sokoban into a different directory, then edit them to
suit your needs.
Those are the basics. There are other factors that come into play if
you want to draw sprites. I may write something up on that
eventually, but for now examine sokoban to see how it handles sprite
drawing.
What's a Makefile?
At this point you can go ahead and start using the Freeware SDK to
develop Avigo apps. But there may be one lingering question in your
mind: "what the heck is a makefile?" You don't really need to know
much about how makefiles work to use the SDK, but they are definitely
worth figuring out. This section gives a brief introduction to
make and makefiles to help you on your way to
total enlightenment.
Make Basics
A makefile is a list of rules which describe how to update
targets based on their dependencies. In English
that means "it says what to do when something needs to be done."
Compiling programs is the most common use for make, but it
can theoretically be used in any situation where something needs to
happen when something else changes. Using make (or
avmake) and a makefile is not necessary, just very
convenient. If you use make you type this every time you
wish to recompile:
avmake
And if you don't you type something like this:
avcp -I../../inc myapp.c | avcc > myapp.asm
avas myapp.asm
avlink -s -omyapp -b_code=0x4000 -b_data=0x8000 ../../lib/crt.rel myapp.rel
avmkapp myapp.def
In the old days before make I guess that's pretty much what people
did. Fortunately you don't have to. You can use
make and save your fingers for coding. But you won't just
save your fingers work, you'll save your computer work too. That's
becuase make automatically determines the minimal amount of
work it has to do in order to update your program.
target: dependencies
actions
That says that target needs to be updated when
any of the dependencies change by executing the
actions. Typically targets and
dependencies are files. Make figures out
which dependencies have changed by comparing the last
modified dates on the files: if the date on any of the
dependencies is newer than that on the
target then it knows it must execute
actions. Otherwise it knows it doesn't have to do
anything. That's how it saves your computer work. IMPORTANT:
any actions must begin with a tab character.
This is the source of many subtle bugs in makefiles.
$(appname).app:$(appname).s19 $(appname).def icon.bmp
avmkapp $(appname).def
$(varname) is the syntax for using variables in
makefiles. At the top of the file appears the line "appname =
hellow", which tells make that it should replace any
occurrence of $(appname) with the string "hellow".
So lets do that ourselves:
hellow.app:hellow.s19 hellow.def icon.bmp
avmkapp hellow.def
This tells make that if any of hellow.s19,
hellow.def or icon.bmp has changed more recently
than hellow.app then hellow.app needs to be updated
by executing the command "avmkapp hellow.def".
$(appname).s19:$(rels)
avlink -s -o$(appname) -b_code=0x4000 -b_data=0x8000 ../../lib/crt.rel $(rels)
They say that hellow.s19 should be remade with that
"avlink" command when any of the $(rels) change.
.c.rel:
avcp -I../../inc $*.c | avcc > $*.asm
avas $*.asm
The $* is a special variable which make
automatically sets to be whatever file was found that ended in
".c" (without the ".c" part).
Running Make
You can make just a particular target by specifying it on the command
line. For instance to make just the .s19 file for hellow
and stop there, you can type avmake hellow.s19. If you
don't specify a target a default is picked which in this case turns
out to be the ".app". Usually the first rule specifies the default,
I'm not sure why that's not the case in the makefiles that come with
the free sdk. The important thing is that one rule can trigger other
rules to be used too. For instance if you are trying to make
hellow.app, make will see from the dependency list
that it depends on hellow.s19. It will then
search for a rule that has hellow.s19 as a target to see if
it also needs to be updated. When it finds hellow.s19 as a target it
checks its dependencies and looks if they are described by any
targets, and so on. In this way eventually everything that needs to
be updated gets updated.
Special targets
Targets don't have to be real files. There are two special targets in
the hellow makefile: "install" and "clean". None of
the default targets depend upon these targets, so they will never be
invoked by simply running "avmake". They can, however, be
invoked directly by typing "avmake install" or "avmake
clean". Here is what those two rules look like:
install:
avapp -p2 -r$(appname).app
clean:
del *.s19
del *.rel
del *.asm
del *.app
The install target runs avapp to install the app on the
Avigo using com port 2. If your Avigo cradle is not on COM2, then
edit the makefile and change the -p2 to whatevery port you
use. The clean target deletes all the files generated
by the make process. One note: on my WinNT 4.0/SP3 machine,
avmake exited with an error when it tried to invoke the
"del" command. I'm not sure why, but after installing the
Unix 95 Collection and changing the clean target to use
"rm" everything was fine:
clean: rm *.s19 rm *.rel rm *.asm rm *.appOne final hint. If you have .c files that include certain .h files that you are likely to change from time to time, you can make a rule for that .c file that makes that dependency explicit so that make knows to recompile when the header changes:
myfile.rel: myfile.c myfile.h avcp -I../../inc $*.c | avcc > $*.asm avas $*.asm
Return to Avigo Agora Main Page