# Project Management

Anjuta has a powerful Project Manager plugin which can open most automake/autoconf-based projects. It might fail on some oddly-configured projects, but as long as the project uses automake/autoconf in a typical way, it should work.

The neat thing is that Anjuta does not store any project information beyond what is already available in the project structure. That is, there is no separate project data maintained by Anjuta and all project processing is done directly within the project structure. This allows a project to be maintained or developed outside Anjuta without any need to convert to or from an Anjuta-specific format. Since technically Anjuta projects are just automake projects, mixed development (with both Anjuta and non-Anjuta users) or switching back and forth between Anjuta and other tools is quite possible without any hindrance.

## Creating a New Project

### Creating a project from a template

The project wizard plugin uses a powerful template processing engine called autogen. All new projects are created from templates that are written in autogen syntax. The project wizard lets you create new projects from a selection of project templates. The selection includes simple generic, flat (no subdirectory), GTK+, GNOME, Java, Python projects and more. New templates can be easily downloaded and installed since each template is just a collection of text files.

To create a project, choose the menu item File New Project … to start the application wizard. Read the first page carefully. Click on Next to proceed.

Select the type of application you want to create in the second page. Click on Next to proceed.

On the following pages, enter all necessary details for your project. You can change these settings later, but it is advisable to set them right initially in order to maintain the project's integrity. White spaces or any non-alphanumeric characters, except underscore (_) and dash (-), are not allowed in many of the entry boxes that follow (except perhaps the Author text box).

You can also specify whether your project will have internationalization support using gettext (read the gettext info page for more details). This gives your project multilingual support for different languages such as English, French and Dutch. The rest of the options are for setting whether the GNU copyright statement should appear in the comments at the top of each file, and for enabling GNOME desktop menu information if necessary. Shared library support allows you to add shared library modules later on. If you plan to have libraries in your project, it would be good to enable this. Depending on the project type that is being created, Anjuta may request additional information.

The final step is to verify the information you have just supplied. Click on Finish to start generating the project.

Once the project has been generated, you can try it out by building it and executing it.

### Importing Projects

The import project feature is used to import an already existing project and convert it into an Anjuta project. Activate the import project wizard via File New Project from existing sources and follow the instructions dictated by the wizard. Once a project has been imported, it can be opened in Anjuta subsequently just like any other Anjuta project.

The import project feature only works if your existing project uses autoconf/automake or, to a very limited extent, a plain Makefile.

## Loading and Saving Projects

### Loading Projects

To open a project, choose the menu item File Open …. Select the project file (`*.anjuta`) in the dialog and click OK.

If the project has recently been opened, then you will find it listed in the menu File Recent. Choose the project filename from the list, and the project will be opened.

As soon as a project is opened, Anjuta will enter Project mode. There are three panes in the project window. The first is the project pane and lists project files organized by file type. The second is the symbol browser, which has already been discussed in the section The Symbol Browser. The third pane is the file view of the project and is more or less similar to a mini file-manager. In the file view, all the files present in the project tree are visible. Right-clicking on these files will pop up a context menu with file operations.

If the project is also a CVS tree, then corresponding file revision numbers are also listed to the right of file names in the file view pane.

### Saving Projects

The project is automatically saved when you close because all changes are made directly in the project structure.

## Project structure

Here is the Project window with its context menu (accessible by clicking on the right mouse button).

### Project window

The Project window

The Project window displays the project's automake hierarchy organized into groups of targets. Groups correspond to directories in your project and targets correspond to normal automake targets (not to be confused with make targets). The Project window actually has two parts: the lower part shows the complete project hierarchy and the upper part lists important targets directly. Important targets include executable and library targets; the view makes these easily accessible. This is particularly useful in large projects where the hierarchy can be deep and hard to navigate from the tree alone. Targets are, in turn, composed of source files.

- Groups are used to logically organize targets. A project can contain any number of groups. Each group can have subgroups as well as targets. In automake projects, groups are just subdirectories in the project. The top-level group is always labeled "/".

- Targets are the build targets in the project, such as programs (executable binaries), scripts, libraries and miscellaneous data. Not all target types are built from sources; some exist just to organize sources and therefore may not exist physically (e.g. a Miscellaneous Data target). Targets exist under groups. See "Adding targets" for a full list of available target types.

- Source files may be used to build targets, though some source files simply belong to targets. They exist only under targets. Many target types expect certain type of source files (e.g. the Programs and Libraries target types), but some can accept any file (e.g. a Miscellaneous Data target).

Each project group and target is configurable in the standard automake way. You can set compiler and linker flags directly for each target, or set configure variables. Groups allow you to set an installation destination for their targets.

Just like the file manager, the project manager view also has convenience actions (accessible from the context menu) for source files and targets.

Many command-line tools are available to maintain and manage a project, and each tool has its own specific rules and capabilities. Anjuta tries to automate most common operations using plugins. However, you might occasionally still need to perform certain operations manually.

You may modify a project's structure using external tools or by hand-editing the project files. It doesn't matter whether the project is loaded in Anjuta or not. Anjuta will update itself with any external changes made to a project.

## Groups and targets

### Adding Groups

To add a new group (which is a directory in automake-based projects):

- Select Project Add Group and a dialog to add a new group will pop up.

- Select the group under which to add the new group.

- Enter the name of the new group and click Add.

With automake projects, a new directory with the given name will be created under the parent group's directory.

You can also add a new group from the Project window directly. Right-click the group under which to add the new group, then choose Add Group from the context menu.

### Removing Groups

To remove a group:

- Right-click the group in the Project Manager view.

- Select Remove from the context menu.

The target and sources associated with the group will also be removed from the project. (They are not deleted from the file system, though. You can add them to the project again later if you like.)

### Adding Targets

To add a new target:

- Select Project Add Target and a dialog to add a new target will popup.

- Select the group under which to add the target.

- Select the target type.

- Enter a name for the new target and click Add.

You can also add a new target from the Project window directly. Right-click the group under which to add the target, then select Add target from the context menu.

Target names usually require some standard prefix and suffix, depending on the type of target. Anjuta will warn you if a name is not valid and may provide an example of a valid name.

There are several target types for automake projects. They are:

- The Program target type is for executable binaries. Select this type if you want to add an executable to the project. By default, all program targets will be installed in the standard executable directory, e.g. /usr/bin or /usr/local/bin. You can override this by specifying a different installation directory in the properties of the group containing the target.

- The Shared Library target type is for shared or dynamic libraries. Select this type if you are adding a shared library to the project. By default, all shared libraries are installed in the standard libraries directory, e.g. /usr/lib or /usr/local/lib. You can override this by specifying a different installation directory in the properties of the group containing the target.

- The Static Library target type is for static libraries. Select this type if you are adding a static library to the project. By default, all static libraries are installed in the standard libraries directory, e.g. /usr/lib or /usr/local/lib. You can override this by specifying a different installation directory in the properties of the group containing the target.

- The Java Module target type is for Java modules. Select this type if you are grouping Java sources into a module. You need to provide an installation directory for this target where the .class files will be installed. It can be set in the properties of the group containing the target.

  There can really be only one Java module in a group. This is a restriction made by automake. Please read the automake info page for more details.

- The Python Module target type is for Python modules. Select this type if you are grouping Python sources into a module. You need to provide an installation directory for this target where the sources will be installed. It can be set in the properties of the group containing the target.

- The Scripts target type is for grouping scripts. They will be installed in the standard executable directory.

- The Miscellaneous Data target type is for grouping simple files in a project. You must specify an installation directory in the group properties.

- The Header Files target type is for grouping C/C++ header files that need to be installed on a system (for example as part of a library API). (For header files that do not need to be installed, make them part of the Program target along with the sources.) Header files will be installed in the standard include directory unless an installation path is specified in the group properties.

- The Man Documentation and Info Documentation target types are for grouping man and info documentation respectively. By default, documentation files will be installed in the standard installation directories.

### Removing Targets

To remove a target:

- Right-click the target in the Project Manager view.

- Select Remove from the context menu.

The sources associated with the targets will also be removed from the project (they are not deleted from the file system, though).

## Adding and Removing Files

### Adding Source Files

Select the menu item Project Add Source File. From the dialog, select the target to which the file should be added and the file itself. You can add multiple files at once. To do that, select multiple files from the file selection dialog using either the Shift or Ctrl key. Then click Add to add the files to the project.

By default, the current editor file will be preselected for addition in the dialog. Another convenient way to add a file is to right-click it in the File Manager and choose Add to project from the context menu.

If the file you choose has already been added to the project, then Anjuta will not add it again. It will also give you a warning that the file has already been added.

If the file you choose is not in the project directory, you will be asked to confirm that you wish to copy the file into the target's directory. Anjuta cannot add files which are outside of a target's directory without copying them in.

### Removing Source Files

To remove a file from the project, right-click the file you want to remove in the Project window and choose Remove from the context menu.

A confirmation dialog will appear, and the file will be removed from the project.

#### The file is not deleted!

The file is not deleted from the filesystem. It still exists, and you can add it back again later if you so wish. The file is only removed from the project listing, and will not take part in any project operations such as compiling, building, or distribution.

## Project Configuration

Project configuration involves setting the correct build flags for targets, groups and the project itself. You can set these flags in their respective properties dialogs.

You can freely use autoconf and automake variables that are automatically set for the project during configuration. Apart from these automatically set variables, you can also define your own variables in Project Properties and use them in properties. This will make it easy to update flags later, especially when a variable is used in several targets.

Some of the many common variables are listed here. For full list of them see the automake info documentation.

- $(prefix): The installation prefix. The project is installed under various subdirectories under this prefix. By default it is /usr/local.

- $(bindir): The installation directory for executable binaries. All your executable and script targets will be installed in this directory. By default, it is $(prefix)/bin.

- $(libdir): The installation directory for libraries. All your library targets (both shared and static) will be installed in this directory or a subdirectory below it. By default, it is $(prefix)/lib.

- $(module_CFLAGS) and $(module_LIBS): These flags are set by configure for the packages that your project depends on. The packages used by the project are set in Project Properties. 'module' is a package group that you specify in the project properties as described below.

### Project properties

The project properties dialog can be opened only by choosing Project Properties from the toplevel menu bar. You can:

- Set the project name, version and URL in the General page. configure variables can also be use in these fields. The URL is the bug report URL for the project.

- Add and remove dependencies for your project in the Packages page. See below for details.

- Create more configure variables in the Variables page to use in group and target properties.

Dependencies are external packages that the project uses and are hence required to build it. Only packages installed using pkg-config can be added from this interface. For others, the configure.ac file can be edited manually.

#### Project properties dialog

Project properties dialog

External package dependencies are grouped into modules, so that their combined build flags can be conveniently added to different targets. Modules are just arbitrary groups of packages and can be named anything (only alphanumeric characters and _ are allowed in module names). Usually, they follow the name of targets they would be used in. Consequently, for small projects with single targets, just one module to hold all dependencies is enough.

Each package exports a set of compiler flags and libraries. They are aggregated together for all packages under a module, and configure variables $(module_CFLAGS) and $(module_LIBS) are defined. These variables can then be used in Group properties and Target properties.

To add a package dependency:

- Select Project Properties to bring up the project properties dialog.

- Select the tab Packages to bring up the Packages page.

- Select the module to add the package to. If there is no module created yet or there is no appropriate module, create one by clicking Add module. Give a sensible name to the module, preferably in UPPERCASE to match other configure variables (only use alphanumeric and '_' characters) and press Enter to create it.

- Click Add Package to bring up the package selection dialog.

- Select the package to add and click Add.

- Click Close to close the properties dialog.

### Group properties

To edit a group's properties, double-click the group in the Project window to open the Group Properties dialog. (You can alternatively right-click the group and select Properties from the context menu.)

#### Group properties dialog

Group properties dialog

Properties set for a group apply to all the targets under it. So any compiler or linker flags set for a group will be automatically be part of all the targets in it (in addition to each target's individual properties). The following fields are available in the Group Properties dialog.

- Includes: Set your include directories for your C and C++ targets here. You need to provide the full include options of the compiler here, e.g. -I/usr/include/blah. The include paths will be used to find header files included by your source files. (You can also add other compiler flags here, but it's preferable to set them in their respective compiler flags fields as described below.)

- Compiler flags: Set your compiler-specific flags here. There are different fields for different compiler categories. Flags that can be set here depend on the actual compiler used. The default compiler used for C/C++ is gcc/g++ (the GNU C compiler). Check out the gcc info documentation for more details.

- Install directories: The dialog will display a field for each target in the group that requires an installation directory. Set each installation directory as relative to one of the many automake directory variables, such as $(prefix), $(bindir), $(libdir), or $(datadir).

### Target properties

Any properties set for a target apply to that target only. A target also inherits properties from its containing group.

To set a target's properties, double-click the target in the Project window to open the Target Properties dialog. (You can alternatively right-click the target and select Properties from the context menu.)

#### Target properties dialog

Target properties dialog

You can add the modules you have added in Project properties to a specific target here. To activate the module simply toggle the checkbox next to the module name. This will automatically add include and linker flags to that target and enable you to use the module within this target.

#### Advanced target options

The following fields are available in the advanced target configuration that you reach when you clicked the Advanded... button in the target properties dialog.

##### Target properties dialog

Target properties dialog

- Compiler settings: Set your compiler-specific flags here. There are different fields for different compiler categories. Flags that can be set here depend on the actual compiler used. The default compiler used for C/C++ is gcc/g++ (the GNU C compiler). Check out the gcc info documentation for more details.

- Linker flags: Set linker flags that should be used when linking the target. These flags apply only to Program and Library targets. See the ld info documentation for available linker options.

- Libraries: Set the libraries that the target depends on.