Node:Adding a File, Next:, Previous:Utility Functions, Up:Top



Adding a File

Version 1.1.1 was the first version of 3DLDF since it became a GNU package (the current version is 1.1.5.1). In previous versions, recompilation was controlled by an auxilliary program, which I wrote in C++ using CWEB. However, in the course of making 3DLDF conformant to the GNU Coding Standards1, this has been changed. Recompilation is now controlled by make, as is customary. The chapter "Compiling" in previous editions of this manual, is therefore no longer needed.

Nonetheless, using CWEB still has consequences for the way recompilation must be handled, and it was fairly tricky getting make to work for 3DLDF. Users who only put code in main.web and/or change code in existing files won't have to worry about this; for others, this chapter explains how to add files to 3DLDF.

Let's say you want to add a file widgets.web that defines a class Widget, and that the latter needs access to class Rectangle, and is in turn required by class Ellipse. Code must be added to 3DLDF-1.1.5.1/CWEB/Makefile for ctangling widgets.web, compiling widgets.cxx, and linking widgets.o with the other object files to make the executable 3dldf.

The best way to do this is to change 3DLDF-1.1.5.1/CWEB/Makefile.am and use Automake to generate a new Makefile.in. Then, configure can be used to generate a new Makefile. It would be possible to modify Makefile by hand, but I don't recommend it. The following assumes that the user has access to Automake. If he or she is using a GNU/Linux system, this is probably true.2

widgets.web must be added between rectangs.web and ellipses.web in the following variable declaration in 3DLDF-1.1.5.1/CWEB/Makefile.am:

     3dldf_SOME_CWEBS = pspglb.web io.web colors.web transfor.web \
                        shapes.web pictures.web points.web \
                        lines.web planes.web paths.web curves.web \
                        polygons.web rectangs.web ellipses.web \
                        circles.web patterns.web solids.web
                        solfaced.web cuboid.web polyhed.web \
                        utility.web parser.web examples.web
     

Now, add widgets.o between ellipses.o and rectangs.o in the following variable declaration:

     3dldf_OBS_REVERSED = main.o examples.o parser.o utility.o \
                          polyhed.o cuboid.o  solfaced.o solids.o \
                          patterns.o circles.o ellipses.o rectangs.o \
                          polygons.o curves.o paths.o \
                          planes.o lines.o points.o pictures.o shapes.o
                          transfor.o colors.o io.o pspglb.o
     

3dldf_OBS_REVERSED is needed, because 3DLDF fails with a "Segmentation fault", if the executable is linked using $(3dldf_OBJECTS). This may cause problems, if 3dldf isn't built using the GNU C++ compiler (GCC).

Now add a target for widgets.o between the targets for rectangs.o and ellipses.o, and add widgets.tim after rectangs.tim in the list of prerequisites for ellipses.o:

     rectangs.o: loader.tim pspglb.tim io.tim colors.tim transfor.tim \
              shapes.tim pictures.tim points.tim lines.tim planes.tim \
              paths.tim curves.tim polygons.tim rectangs.cxx
     
     ellipses.o: loader.tim pspglb.tim io.tim colors.tim transfor.tim \
              shapes.tim pictures.tim points.tim lines.tim planes.tim \
              paths.tim curves.tim polygons.tim rectangs.tim ellipses.cxx
     

This is the result:

     rectangs.o: loader.tim pspglb.tim io.tim colors.tim transfor.tim \
              shapes.tim pictures.tim points.tim lines.tim planes.tim \
              paths.tim curves.tim polygons.tim rectangs.cxx
     
     widgets.o: loader.tim pspglb.tim io.tim colors.tim transfor.tim \
              shapes.tim pictures.tim points.tim lines.tim planes.tim \
              paths.tim curves.tim polygons.tim rectangs.tim \
              widgets.cxx
     
     ellipses.o: loader.tim pspglb.tim io.tim colors.tim transfor.tim \
              shapes.tim pictures.tim points.tim lines.tim planes.tim \
              paths.tim curves.tim polygons.tim rectangs.tim widgets.tim \
              ellipses.cxx
     

In addition, widgets.tim must be added to the list of prerequisites in all of the following targets up to and including examples.o.


Footnotes

  1. The GNU Coding Standards are available at http://www.gnu.org/prep/standards_toc.html.

  2. Automake is available for downloading from http://ftp.gnu.org/gnu/automake/. The Automake website is at http://www.gnu.org/software/automake/.