## 4 Application Makefiles ¶

Application makefiles are very similiar to those used to build Tools and Objective-C programmes, but allow extra specifications to build application wrappers and include their resource files. We assume you are already familiar with the GNUstep Makefile system.

Below is a generic, but complete application makefile, followed by an explanation of the various parameters.

    include $(GNUSTEP_MAKEFILES)/common.make

    APP_NAME = ExampleApplication
    PACKAGE_NAME = ExampleApplication
    VERSION = 1.0

    ExampleApplication_OBJC_FILES = main.m AppController.m \
      ExampleClass.m

    ExampleApplication_C_FILES = regexp.c fun.c

    ExampleApplication_OBJC_LIBS = -lLibNumberOne -lPDFKit -lFunKit
    ExampleApplication_RESOURCE_FILES = \
      ExampleApplication.gorm \
      Info-gnustep.plist

    -include GNUmakefile.preamble
    include $(GNUSTEP_MAKEFILES)/application.make
    -include GNUmakefile.postamble

`common.make` and `application.make` are necessary to build an application, and need to be at the beginning and end respectively to the Makefile to operate properly. The `GNUmakefile.preamble` and `GNUmakefile.postamble` are optional, and permit you to define extra rules for building your application. You can include those lines without those files containing anything. Templates for those files also exist with the source code for gnustep-gui, which can simply be copied into your project and modified accordingly.

The table below describes the makefile variables that you can set to control the output of the make process. Note that appname refers to the application name that you set with `APP_NAME`. It is case sensistive and so are file names. Also, most of the variables listed below are optional if you wish to get a program to compile, but it is recommend you make use of them where appropriate. Where variables ask for flags and compiler options, they should be in the format that `gcc` or `clang` expects, these the only compilers currently used with GNUstep. Many variables also take more than one parameter. They are usually separated by a space, and line breaks with a backslash. Please refer to the GNUstep Makefile Manual for more details.

`APP_NAME`

  [Required] This is the name of your application, and will be used to generate the name of your application wrapper.

`PACKAGE_NAME`

  This is used to generate a rpm or deb package for distribution of your application. See the GNUstep Makefile Manual for more details.

`VERSION`

  A version number for your application.

`appname_OBJC_FILES`

  [Required] Replacing appname with the name of your application, you list the Objective-C files (.m), separated by a space. As shown above, you can split it across one or more lines by placing a slash at the end of the line to indicate a split.

`appname_APPLICATION_ICON`

  [Optional] You can place the name of the image file that will be used as your application icon here.

`appname_MAIN_MODEL_FILE`

  [Recommended] Put the name of your interface file (`.gorm`) here. It will then be placed in the property list of your application.

`appname_PRINCIPAL_CLASS`

  [Optional] If you subclass `NSApplication` with your own application class, you should place it’s name here. By default, GNUstep uses `NSApplication` as the application class.

`appname_C_FILES`

  [Optional] This is where you list the C source code files (.c) to be compiled into your programme. It takes the same form as `appname_OBJC_FILES`.

`appname_CC_FILES`

  [Optional] This is where you list your C++ files (*.cpp, *.cc) to be compiled into your programme. It takes the same form as `appname_OBJC_FILES`.

`appname_OBJCC_FILES`

  [Optional] This is where you list your Objective-C++ files (*.mm) to be compiled into your programme. It takes the same form as the `appname_OBJC_FILES`.3

`appname_RESOURCE_FILES`

  [Recommended] Here you list the resource files that are to be included with your application, including your application property list, interface file(s) and other images, data, etc. You can also list directories here, which should be added recursively (e.g. `.gorm` files are actually a directory containing three files, used to describe your interface).

`appname_RESOURCE_DIRS`

  [Optional] Here you can list directories that will be copied into your application wrapper as resources.

`appname_OBJC_LIBS`

  Here you list the names of the libraries you need your application to link against. Each one is prefixed by ’-l’ e.g. `-lMyLib`, separated by a space. You do not need to list the gnustep-gui, gnustep-base and Objective-C runtime, as these are included for you.

`appname_C_FLAGS`
`appname_CC_FLAGS`
`appname_OBJC_FLAGS`
`appname_OBJCC_FLAGS`

  Here you specify the flags to be passed to the compiler when processing this file type. These included warning flags and macro overrides.

#### Footnotes

##### (3)

You will need either clang or gcc 4.1 or higher to compile Objective-C++ programmes.