Installation and Overview

This module provides limited support for using the common make build tool and its associated makefiles. It provides no support for generating such makefiles, nor for keeping them updated with changing situations in the IDE; rather, it enables you to start the make tool from within the IDE using a UI somewhat consistent with other forms of compilation. Thus, it is essentially a convenience and not full support. Providing true makefile support for the IDE is a longer-term goal.

There should be no special requirements for installation of this module as opposed to any other.

When the module is installed, makefiles present in the Filesystems Explorer tab should be recognized as such and given a distinctive icon. You can double-click them to open them in the Editor (as plain text). The normal IDE UI mechanisms for compiling and executing objects should work on them (e.g. F9 to compile, or check the context menu, etc.); these actions simply run the appropriate targets in the makefile.

The Execution tab of the property sheet holds information about the selected compilation and testing configuration of each executor, similar to that used by Java source files and other object types. The module installs a special compiler type and a special executor designed for makefiles, which are described in the following sections. These are the defaults for makefile objects; for more information on configuring such settings in general you are referred to the User's Guide regarding Service Types.

By default, files ending in common extensions such as *.mak as well as files with common names such as Makefile will be recognized as makefiles by the IDE. You may customize this algorithm under the property sheet for the makefile object type under Global Options | Object Types.

Using the Makefile Pseudo-Compiler

The Run a Makefile compiler type follows similar principles to that used for external compilation of Java sources. You may configure the actual process to run to launch make. This process can include the make command you use, any switches it should have, and the name of the directory plus makefile to run (or similar information; see the arguments key for details).

You may also configure the targets to be run in the makefile under different circumstances. These may be the name of a make target, or they may be left blank to use make's default target (normally the first one found in the makefile). There are three targets you may configure:

Regular Target
Should bring the default targets of this makefile up-to-date if they need to be. This is often represented by a target named all. This will be run during the IDE command Compile.
Rebuild Target
Should bring the default master target up-to-date, again, but assume that everything needs to be rebuilt from scratch (i.e. do not trust the timestamps). Useful when building production releases to sure everything is fresh. This will be run during the IDE command Build (and also during Compile run directly on one makefile). Common target names are e.g. rebuild or force; not all makefiles do this sort of thing so the default is to just use the default target and not really rebuild.
Clean Target
Should clean out make-produced product files. Typically corresponds to the target clean; and in the IDE the Clean command.

Running compile on a makefile should run the proper target, and if make reports errors in a format the IDE can recognize (e.g. from Javac compilation) then these will be hyperlinked as usual when they appear in the Output Window. But errors may not be hyperlinked correctly if your makefile uses submakes or otherwise changes working directory from the directory the makefile itself lives in. See the ToDo file for ideas on how to fix this.

Caution: the makefile compiler type will be used if the IDE is asked to compile a makefile. But if the IDE sees a file (e.g. Java source) that could be handled by the makefile, it does not know this and trying to compile such a file will run the IDE's normal direct compilation step--bypassing your makefile. That is, you must initiate the compilation on the makefile itself, not the source files. The ToDo list includes a description of what a solution to this deficiency might look like, and what problems might need to be solved. In the meantime, beware that if you have a package structure like this:

+ mypackage
  |
  + Makefile
  |
  + A.java
  |
  + B.java

and you select Compile on mypackage, this will not do what you want! This is because the IDE will simultaneously try to run Javac itself on the two source files, while also asking make to build its default target (which typically would be the same thing). This could result in the compiles interfering with each other, make becoming confused about the status of its targets, etc. So do not do this. Suggestions:

Using the Makefile Tester

The Test a Makefile executor is configured partially like regular External Execution for Java applications. The description of the makefile compiler type mostly applies here as well. However, there is only one target, which should be a target you wish to run when you hit Execute on the makefile. Typically this will be named something like test, and would start e.g. a whole application in a testing mode after making sure it is up-to-date.

Note that the arguments key includes the ability to use a target set in the executor itself; and each individual makefile using that executor may also have an alternate target (or NAME=VALUE pairs, etc.) to be passed to the make command, which may be set in its Arguments property in the Execution tab just as for Java applications.

Information

Information, feedback, comments, etc. for this module: see makefile.netbeans.org.