mirror of
https://github.com/gnustep/tools-make.git
synced 2025-04-23 22:33:28 +00:00
Changes to make activation of ARC for a project easier and more flexible
This commit is contained in:
parent
46acbafc20
commit
2e4a65737d
4 changed files with 76 additions and 52 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2020-02-17 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* library-combo.make: removed GS_WITH_ARC support
|
||||
* rules.make: added GS_WITH_ARC stuff
|
||||
* Documentation/gnustep-make.texi: Document the changes ...
|
||||
We can define GS_WITH_ARC more freely (it is no longer necessary to
|
||||
define it before common.make). The default compiler flags for ARC
|
||||
support now include -fobjc-arc-exceptions. We can now define
|
||||
ARC_CPPFLAGS and ARC_OBJCFLAGS to overide the flags sent to the
|
||||
preprocessor and compiler/linker when ARC is enabled using GS_WITH_ARC
|
||||
|
||||
2019-10-29 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* GNUmakefile.in:
|
||||
|
|
|
@ -930,13 +930,23 @@ linker as the following example illustrates.
|
|||
ADDITIONAL_GUI_LIBS = -lMiscGui
|
||||
@end smallexample
|
||||
|
||||
@defvar GS_WITH_ARC
|
||||
@code{GS_WITH_ARC} may be set to 1 to say that Objective-C source code
|
||||
is to be compiled for ARC memory management. This variable must be set
|
||||
before @file{common.make} is included, and only works if the library
|
||||
combo includes the 'ng' runtime specification.
|
||||
@defvar ADDITIONAL_INSTALL_DIRS
|
||||
@code{ADDITIONAL_INSTALL_DIRS} is the list of additional directories
|
||||
that should be created when the Makefile Package installs the file for
|
||||
the project. These directories are only one that the project needs to
|
||||
be created but that the Makefile Package does not automatically
|
||||
create. The directories should be absolute paths but use the
|
||||
@code{GNUSTEP_LIBRARY} variable and other Makefile Package define
|
||||
variables, see @ref{Directory Paths}, so that the directories get
|
||||
created in the appropriate place relative to the other file installed
|
||||
for the project. The following example illustrates how two additional
|
||||
directories can be created during installation.
|
||||
@end defvar
|
||||
|
||||
@smallexample
|
||||
ADDITIONAL_INSTALL_DIRS = $(GNUSTEP_RESOURCES)/MyProject
|
||||
@end smallexample
|
||||
|
||||
@defvar LIBRARIES_DEPEND_UPON
|
||||
@code{LIBRARIES_DEPEND_UPON} is the set of libraries that the shared
|
||||
library depends upon, see @ref{library.make} for more information about
|
||||
|
@ -963,23 +973,6 @@ additional user library.
|
|||
LIBRARIES_DEPEND_UPON = -lsimple $(FND_LIBS) $(OBJC_LIBS) $(SYSTEM_LIBS)
|
||||
@end smallexample
|
||||
|
||||
@defvar ADDITIONAL_INSTALL_DIRS
|
||||
@code{ADDITIONAL_INSTALL_DIRS} is the list of additional directories
|
||||
that should be created when the Makefile Package installs the file for
|
||||
the project. These directories are only one that the project needs to
|
||||
be created but that the Makefile Package does not automatically
|
||||
create. The directories should be absolute paths but use the
|
||||
@code{GNUSTEP_LIBRARY} variable and other Makefile Package define
|
||||
variables, see @ref{Directory Paths}, so that the directories get
|
||||
created in the appropriate place relative to the other file installed
|
||||
for the project. The following example illustrates how two additional
|
||||
directories can be created during installation.
|
||||
@end defvar
|
||||
|
||||
@smallexample
|
||||
ADDITIONAL_INSTALL_DIRS = $(GNUSTEP_RESOURCES)/MyProject
|
||||
@end smallexample
|
||||
|
||||
@node GNUmakefile.postamble, Common Variables, GNUmakefile.preamble, Top
|
||||
@section Global Rules (@file{GNUmakefile.postamble})
|
||||
|
||||
|
@ -1573,25 +1566,24 @@ However, there are some variables which, while not in provided in
|
|||
be documented here:
|
||||
|
||||
@defvar GS_WITH_ARC
|
||||
@code{GS_WITH_ARC = 1} turns on ARC for the current build if using the
|
||||
Next Generation runtime setting.
|
||||
This variable may be defined as an environment variable, or on the make
|
||||
command line, or (usually) at the start of GNUmakefile.
|
||||
@code{GS_WITH_ARC} may be set to 1 to turns on ARC for the current build if using the Next Generation runtime setting. This variable may be defined as an environment variable, or on the make command line, or (usually) in the GNUmakefile. The library-combo needs to specify the next generation runtime (eg ng-gnu-gnu) for this variable to take effect. When the ng runtme is used, setting this variable causes the the flags specified in ARC_OBJCFLAGS to be used when compiling any Objective-C source files). If no value is defined for @code{ARC_OBJCFLAGS} it is assumed to be '-fobjc-arc -fobjc-arc-exceptions' so that code is built with ARC enabled and with support for exceptions (objects are not leaked when an exception occurs). Alternatively, to switch on ARC for individual files, you can have a makefile fragment like this:
|
||||
@end defvar
|
||||
The variable needs to be defined before @file{common.make} is included,
|
||||
and the library-combo needs to be ng-gnu-gnu for it to take effect (in
|
||||
which case it causes the -fobjc-arc flag to be used when compiling any
|
||||
Objective-C source files).
|
||||
Alternatively, to switch on ARC for individual files, you can have a makefile
|
||||
fragment like this:
|
||||
@smallexample
|
||||
ifeq ($(OBJC_RUNTIME_LIB), ng)
|
||||
file1.m_FILE_FLAGS+=-fobjc-arc
|
||||
file2.m_FILE_FLAGS+=-fobjc-arc
|
||||
file9.m_FILE_FLAGS+=-fobjc-arc
|
||||
file1.m_FILE_FLAGS+="-fobjc-arc -fobjc-arc-exceptions"
|
||||
file2.m_FILE_FLAGS+="-fobjc-arc -fobjc-arc-exceptions"
|
||||
file9.m_FILE_FLAGS+="-fobjc-arc -fobjc-arc-exceptions"
|
||||
endif
|
||||
@end smallexample
|
||||
|
||||
@defvar ARC_CPPFLAGS
|
||||
@code{ARC_CPPFLAGS} sets the flags to defien preprocessor values be used when building code for ARC. This variable is used only if ng runtime is used and the @code{GS_WITH_ARC} variable is set to say that ARC is used.
|
||||
@end defvar
|
||||
|
||||
@defvar ARC_OBJCFLAGS
|
||||
@code{ARC_OBJCFLAGS} sets the compiler/linker flags to be used when building code for ARC. This variable is used only if ng runtime is used and the 'GS_WITH_ARC' variable is set to say that ARC is used. The -fobjc-arc flag enables ARC, but by default ARC_OBJCFLAGS is assumed to be -fobjc-arc -fobjc-arc-exceptions, which adds support for exceptions (reducing performance, but preventing leaked memory when an exception occurs).
|
||||
@end defvar
|
||||
|
||||
@defvar xxx_FILE_FILTER_OUT_FLAGS
|
||||
@code{xxx_FILE_FILTER_OUT_FLAGS} (where xxx is the file name, such as mframe.m)
|
||||
is a filter-out make pattern of flags to be filtered out
|
||||
|
|
|
@ -52,21 +52,6 @@ ifeq ($(OBJC_RUNTIME_LIB), ng)
|
|||
endif
|
||||
RUNTIME_FLAG = -fobjc-runtime=$(RUNTIME_VERSION) -fblocks
|
||||
RUNTIME_DEFINE = -DGNUSTEP_RUNTIME=1 -D_NONFRAGILE_ABI=1
|
||||
# Projects may control the use of ARC by defining GS_WITH_ARC=1
|
||||
# or GS_WITH_ARC=0 at the start of their GNUmakefile, or in the environment,
|
||||
# or as an argument to the 'make' command.
|
||||
# The default behavior is not to use ARC, unless GNUSTEP_NG_ARC is
|
||||
# set to 1 (perhaps in the GNUstep config file; GNUstep.conf).
|
||||
#
|
||||
ifeq ($(GS_WITH_ARC),)
|
||||
ifeq ($(GNUSTEP_NG_ARC), 1)
|
||||
GS_WITH_ARC=1
|
||||
endif
|
||||
endif
|
||||
ifeq ($(GS_WITH_ARC), 1)
|
||||
RUNTIME_FLAG += -fobjc-arc
|
||||
RUNTIME_DEFINE += -DGS_WITH_ARC=1
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OBJC_RUNTIME_LIB), nx)
|
||||
|
|
40
rules.make
40
rules.make
|
@ -204,6 +204,41 @@ ifeq ($(AUTO_DEPENDENCIES_FLAGS),)
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OBJC_RUNTIME_LIB), ng)
|
||||
# Projects may control the use of ARC by defining GS_WITH_ARC=1
|
||||
# or GS_WITH_ARC=0 in their GNUmakefile, or in the environment,
|
||||
# or as an argument to the 'make' command.
|
||||
# The default behavior is not to use ARC, unless GNUSTEP_NG_ARC is
|
||||
# set to 1 (perhaps in the GNUstep config file; GNUstep.conf).
|
||||
# The value of ARC_OBJCFLAGS is used to specify the flags passed
|
||||
# to the compiler when building ARC code. If it has not been set,
|
||||
# it defaults to -fobjc-arc -fobjc-arc-exceptions so that objects
|
||||
# are not leaked when an exception is raised.
|
||||
# The value of ARC_CPPFLAGS is used to specify the flags passed
|
||||
# to the preprocessor when building ARC code. If it has not been set,
|
||||
# it defaults to -DGS_WITH_ARC=1
|
||||
ifeq ($(GS_WITH_ARC),)
|
||||
ifeq ($(GNUSTEP_NG_ARC), 1)
|
||||
GS_WITH_ARC=1
|
||||
endif
|
||||
endif
|
||||
ifeq ($(GS_WITH_ARC), 1)
|
||||
ifeq ($(ARC_OBJCFLAGS),)
|
||||
ARC_OBJCFLAGS = -fobjc-arc -fobjc-arc-exceptions
|
||||
endif
|
||||
ifeq ($(ARC_CPPFLAGS),)
|
||||
ARC_CPPFLAGS = -DGS_WITH_ARC=1
|
||||
endif
|
||||
INTERNAL_OBJC_FLAGS += $(ARC_OBJCFLAGS)
|
||||
else
|
||||
ARC_OBJCFLAGS=
|
||||
ARC_CPPFLAGS=
|
||||
endif
|
||||
else
|
||||
ARC_OBJCFLAGS=
|
||||
ARC_CPPFLAGS=
|
||||
endif
|
||||
|
||||
# The difference between ADDITIONAL_XXXFLAGS and AUXILIARY_XXXFLAGS is the
|
||||
# following:
|
||||
#
|
||||
|
@ -241,7 +276,7 @@ endif
|
|||
#
|
||||
|
||||
ALL_CPPFLAGS = $(AUTO_DEPENDENCIES_FLAGS) $(CPPFLAGS) $(ADDITIONAL_CPPFLAGS) \
|
||||
$(AUXILIARY_CPPFLAGS)
|
||||
$(AUXILIARY_CPPFLAGS) $(ARC_CPPFLAGS)
|
||||
|
||||
# -I./obj/PrecompiledHeaders/ObjC must be before anything else because
|
||||
# we want an existing and working precompiled header to be used before
|
||||
|
@ -311,7 +346,8 @@ ALL_LDFLAGS += $(ADDITIONAL_LDFLAGS) $(AUXILIARY_LDFLAGS) $(GUI_LDFLAGS) \
|
|||
$(BACKEND_LDFLAGS) $(SYSTEM_LDFLAGS) $(INTERNAL_LDFLAGS)
|
||||
# In some cases, ld is used for linking instead of $(CC), so we can't use
|
||||
# this in ALL_LDFLAGS
|
||||
CC_LDFLAGS = $(RUNTIME_FLAG)
|
||||
CC_LDFLAGS = $(RUNTIME_FLAG) $(ARC_OBJCFLAGS)
|
||||
|
||||
|
||||
ALL_LIB_DIRS = $(ADDITIONAL_FRAMEWORK_DIRS) $(AUXILIARY_FRAMEWORK_DIRS) \
|
||||
$(ADDITIONAL_LIB_DIRS) $(AUXILIARY_LIB_DIRS) \
|
||||
|
|
Loading…
Reference in a new issue