mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-27 18:50:47 +00:00
227 lines
5.9 KiB
Text
227 lines
5.9 KiB
Text
|
@node Make
|
||
|
@appendix Using the GNUstep Make Package
|
||
|
@cindex GNUstep Make package
|
||
|
@cindex Make package, GNUstep
|
||
|
|
||
|
Reference/doc on the GNUstep make package; mainly examples of various
|
||
|
types of projects.
|
||
|
|
||
|
@section Makefile Contents
|
||
|
@paragraphindent 0
|
||
|
|
||
|
@b{Note. Type @code{man make} for assistance.}
|
||
|
|
||
|
Make files comprise four key content types:
|
||
|
|
||
|
@itemize @bullet
|
||
|
@item
|
||
|
@b{Comments}
|
||
|
|
||
|
@code{#} prefixes comments.
|
||
|
|
||
|
@item
|
||
|
@b{Macros}
|
||
|
|
||
|
@code{SRC=main.m} assigns a macro that is implemented as:@code{gcc $(SRC)}
|
||
|
and is interpreted as:
|
||
|
@code{gcc main.m}
|
||
|
|
||
|
@item
|
||
|
@b{Explicit rules}
|
||
|
Explicit rules are used to indicate which files depend upon supporting files and
|
||
|
the commands required for their compilation:
|
||
|
@example
|
||
|
targetfile : sourcefiles
|
||
|
commands
|
||
|
@end example
|
||
|
|
||
|
A Tab precedes each command that must be implemented on the source files in order
|
||
|
to create the target file:
|
||
|
@example
|
||
|
main: main.m List.h
|
||
|
gcc -o main main.m List.h
|
||
|
@end example
|
||
|
|
||
|
@item
|
||
|
@b{Implicit rules}
|
||
|
Implicit rules broadly echo explicit variants but do not specify commands, rather the
|
||
|
extensions indicate which commands are performed:
|
||
|
|
||
|
@code{servertest.o: servertest.c io.h}
|
||
|
@*
|
||
|
is interpreted as:
|
||
|
@*
|
||
|
@code{$(CC) $(CFLAGS) -c servertest.c io.h}
|
||
|
@end itemize
|
||
|
|
||
|
@subsection Makefile Example
|
||
|
|
||
|
@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
|
||
|
|
||
|
@end example
|
||
|
|
||
|
|
||
|
@subsection Makefile Structure
|
||
|
|
||
|
The following Makefile defines a project:
|
||
|
|
||
|
@example
|
||
|
#
|
||
|
# A GNUmakefile
|
||
|
#
|
||
|
|
||
|
# 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 = simple.m
|
||
|
|
||
|
-include GNUmakefile.preamble
|
||
|
|
||
|
# Include in the rules for making Objective-C programs
|
||
|
include $(GNUSTEP_MAKEFILES)/objc.make
|
||
|
|
||
|
-include GNUmakefile.postamble
|
||
|
@end example
|
||
|
|
||
|
|
||
|
To compile a package that uses the Makefile Package, type @code{make} in the
|
||
|
top-level directory of the package. A non-GNUstep Objective-C file may be
|
||
|
compiled by adding @code{-lobjc on} at the command line.
|
||
|
|
||
|
|
||
|
@subsection Debug and Profile Information
|
||
|
|
||
|
|
||
|
By default the Makefile Package does not flag the compiler to generate debugging
|
||
|
information that is generated by typing:
|
||
|
|
||
|
@code{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:
|
||
|
|
||
|
@code{make profile=yes}
|
||
|
@sp 1
|
||
|
|
||
|
@subsection 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:
|
||
|
|
||
|
@code{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.
|
||
|
|
||
|
@section Project Types
|
||
|
|
||
|
Projects are divided into different types. To create a project of a specific
|
||
|
type, a make file is specified:
|
||
|
|
||
|
@code{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.
|
||
|
|
||
|
@itemize @bullet
|
||
|
@item
|
||
|
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:
|
||
|
|
||
|
@code{Aggregate project: SUBPROJECTS}
|
||
|
|
||
|
SUBPROJECTS defines the directory names that hold the sub-projects that the
|
||
|
Aggregate project should build.
|
||
|
|
||
|
|
||
|
@item 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.
|
||
|
|
||
|
|
||
|
@item 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.
|
||
|
|
||
|
|
||
|
@item 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.
|
||
|
|
||
|
|
||
|
@item 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.
|
||
|
|
||
|
@item 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.
|
||
|
|
||
|
@item 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.
|
||
|
|
||
|
@item 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.
|
||
|
@end itemize
|