Appendix F Using the GNUstep Make Package
Reference/doc on the GNUstep make package; mainly examples of various
types of projects.
F.1 Makefile Contents
Note. Type man make
for assistance.
Make files comprise four key content types:
- Comments
#
prefixes comments.
- Macros
SRC=main.m
assigns a macro that is implemented as:gcc $(SRC)
and is interpreted as:
gcc main.m
- Explicit rules
Explicit rules are used to indicate which files depend upon supporting files and
the commands required for their compilation:
targetfile : sourcefiles
commands
A Tab precedes each command that must be implemented on the source files in order
to create the target file:
main: main.m List.h
gcc -o main main.m List.h
- Implicit rules
Implicit rules broadly echo explicit variants but do not specify commands, rather the
extensions indicate which commands are performed:
servertest.o: servertest.c io.h
is interpreted as:
$(CC) $(CFLAGS) -c servertest.c io.h
F.1.1 Makefile Example
# The following two lines force the standard make to recognize the
# Objective-C .m suffix.
.SUFFIXES: .o .m
.m.o:
$(CC) -c $(CFLAGS) $<
# Macro declarations
CC = gcc
CFLAGS = -g
LIBS = -lobjc
SRC=main.m Truck.m Station.m Vehicle.m
OBJ=main.o Truck.o Station.o Vehicle.o
# Explicit rules
hist: $(OBJ)
$(CC) $(CFLAGS) -o main $(OBJ) $(LIBS)
# Implicit rules
Truck.o: Truck.h Truck.m
Station.o: Truck.h Station.h Station.m
Vehicle.o: Truck.h Vehicle.h Vehicle.m
main.o: Station.h Vehicle.h
F.1.2 Makefile Structure
The following Makefile defines a project:
#
# A GNUmakefile
#
# Check that the GNUSTEP_MAKEFILES environment variable is set
ifeq ($(GNUSTEP_MAKEFILES),)
GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null)
ifeq ($(GNUSTEP_MAKEFILES),)
$(error You need to set GNUSTEP_MAKEFILES before compiling!)
endif
endif
# Include the common variables
include $(GNUSTEP_MAKEFILES)/common.make
# Build an Objective-C program
OBJC_PROGRAM_NAME = simple
# Objective-C files requiring compilation
simple_OBJC_FILES = source.m
-include GNUmakefile.preamble
# Include in the rules for making Objective-C programs
include $(GNUSTEP_MAKEFILES)/objc.make
-include GNUmakefile.postamble
To compile a package that uses the Makefile Package, type make
in the
top-level directory of the package. A non-GNUstep Objective-C file may be
compiled by adding -lobjc on
at the command line.
F.1.3 Debug and Profile Information
By default the Makefile Package does not flag the compiler to generate debugging
information that is generated by typing:
make debug=yes
This command also causes the Makefile Package to turn off optimization. It is
therefore necessary to override the optimization flag when running Make if both
debugging information and optimization is required. Use the variable OPTFLAG to
override the optimization flag.
By default the Makefile Package does not instruct the compiler to create profiling
information that is generated by typing:
make profile=yes
F.1.4 Static, Shared and DLLs
By default the Makefile Package generates a shared library if it is building a
library project type, and it will link with shared libraries if it is building
an application or command-line tool project type. To tell the Makefile Package
not to build using shared libraries but using static libraries instead, type:
make shared=no
This default is only applicable on systems that support shared libraries;
systems that do not support shared libraries will always build using static
libraries. Some systems support DLLs that are a form of shared libraries; on
these systems DLLs are built by default unless the Makefile Package is told to
build using static libraries instead.
F.2 Project Types
Projects are divided into different types. To create a project of a specific
type, a make file is specified:
include $(GNUSTEP_MAKEFILES)/application.make
Each project type is independent, and if you want to create two project types in
the same directory (e.g. a tool and a Java program), include both the desired
make files in your main Make file.
- Aggregate - aggregate.make
An Aggregate project holds several sub-projects that are of any valid
project type (including the Aggregate type). The only project variable is the
SUBPROJECTS variable:
Aggregate project: SUBPROJECTS
SUBPROJECTS defines the directory names that hold the sub-projects that the
Aggregate project should build.
- Graphical Applications - application.make
An application is an Objective-C program that includes a GUI component, and by
default links in all the GNUstep libraries required for GUI development, such as
the Base and GUI libraries.
- Bundles - bundle.make
A bundle is a collection of resources and code that can be used to enhance an
existing application or tool dynamically using the NSBundle class from the
GNUstep base library.
- Command Line C Tools - ctool.make
A ctool is a project that uses only C language files. Otherwise it is similar to
the ObjC project type.
- Documentation - documentation.make
The Documentation project provides rules to use various types of documentation
such as texi and LaTeX documentation, and convert them into finished
documentation like info, PostScript, HTML, etc.
- Frameworks - framework.make
A Framework is a collection of resources and a library that provides common code
that can be linked into a Tool or Application. In many respects it is similar to
a Bundle.
- Java - java.make
This project provides rules for building java programs. It also makes it easy to
make java projects that interact with the GNUstep libraries.
- Libraries - library.make
The Makefile Package provides a project type for building libraries that may be
static, shared, or dynamic link libraries (DLLs). The latter two variants are
supported only on some platforms.
Concept Index
| Index Entry | | Section |
|
A | | |
| abstract class: | | Objective-C |
| advanced messaging: | | Advanced Messaging |
| allocating objects: | | Objects |
| AppKit: | | Introduction |
| assertion facilities: | | Exception Handling |
| assertion handling, compared with Java: | | Exception Handling |
| assertions: | | Exception Handling |
|
B | | |
| base library: | | Base Library |
| basic OO terminology: | | Introduction |
| bundles: | | Bundles and Frameworks |
| bycopy and byref type qualifiers: | | Distributed Objects |
|
C | | |
| categories: | | Classes |
| class cluster: | | Objective-C |
| class, abstract: | | Objective-C |
| class, root: | | Objective-C |
| classes: | | Objective-C |
| client/server processes: | | Distributed Objects |
| cluster, classes: | | Objective-C |
| compilation, conditional: | | Compliance to Standards |
|
D | | |
| differences and similarities, Objective-C and C++: | | Objective-C Java and C++ |
| differences and similarities, Objective-C and Java: | | Objective-C Java and C++ |
| directory layout: | | Introduction |
| distributed objects: | | Distributed Objects |
| distributed objects: | | Distributed Objects |
| Distributed Objects Name Server, GNUstep: | | Distributed Objects |
| distributed objects, client code: | | Distributed Objects |
| distributed objects, client code: | | Distributed Objects |
| distributed objects, error checking: | | Distributed Objects |
| distributed objects, example (no error checking): | | Distributed Objects |
| distributed objects, using a protocol: | | Distributed Objects |
|
E | | |
| error checking, distributed objects: | | Distributed Objects |
| exception facilities: | | Exception Handling |
| exception handling, compared with Java: | | Exception Handling |
| exceptions: | | Exception Handling |
|
F | | |
| filesystem layout: | | Introduction |
| forward invocation, distributed objects: | | Distributed Objects |
| forwarding: | | Advanced Messaging |
| frameworks: | | Bundles and Frameworks |
|
G | | |
| game server example: | | Distributed Objects |
| garbage collection: | | Objects |
| gdomap: | | Distributed Objects |
| GNUstep base library: | | Introduction |
| GNUstep Make package: | | Make |
| GNUstep make utility: | | Introduction |
| GNUstep, what is?: | | Introduction |
| graphical programming: | | Introduction |
| gsdoc: | | GSDoc |
| GUI: | | Introduction |
|
H | | |
| history of NeXTstep: | | Introduction |
| history of Objective-C: | | Introduction |
| history of OpenStep: | | Introduction |
|
I | | |
| in, out, and inout type qualifiers: | | Distributed Objects |
| inheritance: | | Objective-C |
| inheriting methods: | | Objective-C |
| instance variables, referring to: | | Objective-C |
| interface: | | Classes |
|
J | | |
| Java and Guile, programming GNUstep: | | Java and Guile |
|
L | | |
| layout, filesystem: | | Introduction |
| logging: | | Exception Handling |
| logging facilities: | | Exception Handling |
| logging, compared with Java: | | Exception Handling |
|
M | | |
| Make package, GNUstep: | | Make |
| make utility, GNUstep: | | Introduction |
| memory deallocation: | | Objects |
| memory management: | | Objects |
| memory management, explicit: | | Objects |
| memory management, garbage collection based: | | Objects |
| memory management, OpenStep-style: | | Objects |
| memory management, retain count: | | Objects |
| message forwarding, distributed objects: | | Distributed Objects |
| messages: | | Objective-C |
| messaging, advanced techniques: | | Advanced Messaging |
|
N | | |
| naming constraints: | | Objective-C |
| naming conventions: | | Objective-C |
| NeXTstep, history: | | Introduction |
| NSAssert macro: | | Exception Handling |
| NSAssertionHandler class: | | Exception Handling |
| NSConnection class: | | Distributed Objects |
| NSDebugLog function: | | Exception Handling |
| NSException class: | | Exception Handling |
| NSLog function: | | Exception Handling |
| NSObject: | | Objective-C |
| NSProxy class: | | Distributed Objects |
| NSRunLoop class: | | Distributed Objects |
| NSUncaughtExceptionHandler: | | Exception Handling |
| NSWarnLog function: | | Exception Handling |
| NS_DURING macro: | | Exception Handling |
| NS_ENDHANDLER macro: | | Exception Handling |
| NS_HANDLER macro: | | Exception Handling |
|
O | | |
| object interaction, remote objects: | | Distributed Objects |
| object-oriented programming: | | Introduction |
| Objective-C and C++, differences and similarities: | | Objective-C Java and C++ |
| Objective-C and Java, differences and similarities: | | Objective-C Java and C++ |
| Objective-C, history: | | Introduction |
| Objective-C, what is?: | | Introduction |
| objects: | | Objective-C |
| objects, initalizing and allocating: | | Objects |
| objects, working with: | | Objects |
| oneway, type qualifier: | | Distributed Objects |
| OpenStep compliance: | | Compliance to Standards |
| OpenStep, history: | | Introduction |
| OS X compatibility: | | Compliance to Standards |
| out, type qualifier: | | Distributed Objects |
| overriding methods: | | Objective-C |
|
P | | |
| polymorphism: | | Objective-C |
| profiling facilities: | | Exception Handling |
| protocol for distributed objects: | | Distributed Objects |
| protocol type qualifiers: | | Distributed Objects |
| protocols: | | Classes |
| protocols, formal: | | Classes |
|
R | | |
| remote objects: | | Distributed Objects |
| resources, application: | | Bundles and Frameworks |
| root class: | | Objective-C |
|
S | | |
| standards compliance: | | Compliance to Standards |
| standards, GNUstep compliance to: | | Compliance to Standards |
| static typing: | | Objective-C |
|
U | | |
| user defaults, API compliance: | | Compliance to Standards |
|
W | | |
| what is GNUstep?: | | Introduction |
| what is Objective-C?: | | Introduction |
| working with objects: | | Objects |
| writing new classes: | | Classes |
|
Y | | |
| your first Objective-C program: | | Introduction |
|
Z | | |
| Zones: | | Objects |
|