Next: About this document ... Up: More on GNUstep Makefiles Previous: 2 Libraries

3 Aggregate projects

A nice feature of the GNUstep make package is the support for aggregate projects.

As an example, suppose that you are writing a networked game. Your source code will probably contain two different subprojects: a gui application (the client application game) and a command line tool (the server). The server keeps the game map, and any information on the current state of the game; it allows to save, load, reset a game; to set game options. To play, the players will start a client each, and use it to connect to the server from machines on the network, and play against each other. The server is a command line tool, while the client application is a nice user-friendly gui application with lots of images and mouse actions. Naturally enough, you want to develop and distribute the two subprojects together. This is where GNUstep subprojects come handy.

Imagine that your game is called MyGame. You will have a top-level directory

MyGame
and two subdirectories
MyGame/Server
MyGame/Client
In MyGame/Server you keep the source code of your server tool, with its own GNUmakefile. In MyGame/Client you keep the source code of your client application, with its own GNUmakefile.

You can now you add the following GNUmakefile in the top-level directory:

include $(GNUSTEP_MAKEFILES)/common.make

PACKAGE_NAME = MyGame

SUBPROJECTS = Server Client

include $(GNUSTEP_MAKEFILES)/aggregate.make
This GNUmakefile simply tells to the make package that your project has two subprojects, Server, and Client. Please note that the make package follows the order you specify, so in this case Server is always compiled before Client (this could be important if one of your subprojects is a library, and another subproject is an application which needs to be linked against that library: then, you always want the library to be compiled before the application, so the library should come before the application in the list of subprojects).

In this example, we have two subprojects, but you can have any number of subprojects.

At this point you are ready. For example, typing

make debug=yes
in the top-level directory will cause the make package to step into the Server subdirectory, and run make debug=yes there, and then step into the Client subdirectory, and run make debug=yes there.

The same will work with all the standard make commands, such as make clean, make distclean, make install etc.

Subprojects can be nested, so that for example the Server project could be itself composed of subprojects.


Next: About this document ... Up: More on GNUstep Makefiles Previous: 2 Libraries
Nicola 2002-05-28