190075Sobrien@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2119256Skan@c 1999, 2000, 2001, 2003 Free Software Foundation, Inc. 390075Sobrien@c This is part of the GCC manual. 490075Sobrien@c For copying conditions, see the file gcc.texi. 590075Sobrien 690075Sobrien@node Fragments 790075Sobrien@chapter Makefile Fragments 890075Sobrien@cindex makefile fragment 990075Sobrien 1090075SobrienWhen you configure GCC using the @file{configure} script, it will 1190075Sobrienconstruct the file @file{Makefile} from the template file 1290075Sobrien@file{Makefile.in}. When it does this, it can incorporate makefile 1390075Sobrienfragments from the @file{config} directory. These are used to set 1490075SobrienMakefile parameters that are not amenable to being calculated by 1590075Sobrienautoconf. The list of fragments to incorporate is set by 16132718Skan@file{config.gcc} (and occasionally @file{config.build} 17132718Skanand @file{config.host}); @xref{System Config}. 1890075Sobrien 1990075SobrienFragments are named either @file{t-@var{target}} or @file{x-@var{host}}, 2090075Sobriendepending on whether they are relevant to configuring GCC to produce 2190075Sobriencode for a particular target, or to configuring GCC to run on a 2290075Sobrienparticular host. Here @var{target} and @var{host} are mnemonics 2390075Sobrienwhich usually have some relationship to the canonical system name, but 2490075Sobrienno formal connection. 2590075Sobrien 2690075SobrienIf these files do not exist, it means nothing needs to be added for a 2790075Sobriengiven target or host. Most targets need a few @file{t-@var{target}} 2890075Sobrienfragments, but needing @file{x-@var{host}} fragments is rare. 2990075Sobrien 3090075Sobrien@menu 3190075Sobrien* Target Fragment:: Writing @file{t-@var{target}} files. 3290075Sobrien* Host Fragment:: Writing @file{x-@var{host}} files. 3390075Sobrien@end menu 3490075Sobrien 3590075Sobrien@node Target Fragment 3690075Sobrien@section Target Makefile Fragments 3790075Sobrien@cindex target makefile fragment 3890075Sobrien@cindex @file{t-@var{target}} 3990075Sobrien 4090075SobrienTarget makefile fragments can set these Makefile variables. 4190075Sobrien 4290075Sobrien@table @code 4390075Sobrien@findex LIBGCC2_CFLAGS 4490075Sobrien@item LIBGCC2_CFLAGS 4590075SobrienCompiler flags to use when compiling @file{libgcc2.c}. 4690075Sobrien 4790075Sobrien@findex LIB2FUNCS_EXTRA 4890075Sobrien@item LIB2FUNCS_EXTRA 4990075SobrienA list of source file names to be compiled or assembled and inserted 5090075Sobrieninto @file{libgcc.a}. 5190075Sobrien 5290075Sobrien@findex Floating Point Emulation 5390075Sobrien@item Floating Point Emulation 5490075SobrienTo have GCC include software floating point libraries in @file{libgcc.a} 5590075Sobriendefine @code{FPBIT} and @code{DPBIT} along with a few rules as follows: 5690075Sobrien@smallexample 5790075Sobrien# We want fine grained libraries, so use the new code 5890075Sobrien# to build the floating point emulation libraries. 5990075SobrienFPBIT = fp-bit.c 6090075SobrienDPBIT = dp-bit.c 6190075Sobrien 6290075Sobrien 6390075Sobrienfp-bit.c: $(srcdir)/config/fp-bit.c 6490075Sobrien echo '#define FLOAT' > fp-bit.c 6590075Sobrien cat $(srcdir)/config/fp-bit.c >> fp-bit.c 6690075Sobrien 6790075Sobriendp-bit.c: $(srcdir)/config/fp-bit.c 6890075Sobrien cat $(srcdir)/config/fp-bit.c > dp-bit.c 6990075Sobrien@end smallexample 7090075Sobrien 7190075SobrienYou may need to provide additional #defines at the beginning of @file{fp-bit.c} 7290075Sobrienand @file{dp-bit.c} to control target endianness and other options. 7390075Sobrien 7490075Sobrien 7590075Sobrien@findex CRTSTUFF_T_CFLAGS 7690075Sobrien@item CRTSTUFF_T_CFLAGS 7790075SobrienSpecial flags used when compiling @file{crtstuff.c}. 7890075Sobrien@xref{Initialization}. 7990075Sobrien 8090075Sobrien@findex CRTSTUFF_T_CFLAGS_S 8190075Sobrien@item CRTSTUFF_T_CFLAGS_S 8290075SobrienSpecial flags used when compiling @file{crtstuff.c} for shared 8390075Sobrienlinking. Used if you use @file{crtbeginS.o} and @file{crtendS.o} 8490075Sobrienin @code{EXTRA-PARTS}. 8590075Sobrien@xref{Initialization}. 8690075Sobrien 8790075Sobrien@findex MULTILIB_OPTIONS 8890075Sobrien@item MULTILIB_OPTIONS 8990075SobrienFor some targets, invoking GCC in different ways produces objects 9090075Sobrienthat can not be linked together. For example, for some targets GCC 9190075Sobrienproduces both big and little endian code. For these targets, you must 9290075Sobrienarrange for multiple versions of @file{libgcc.a} to be compiled, one for 9390075Sobrieneach set of incompatible options. When GCC invokes the linker, it 9490075Sobrienarranges to link in the right version of @file{libgcc.a}, based on 9590075Sobrienthe command line options used. 9690075Sobrien 9790075SobrienThe @code{MULTILIB_OPTIONS} macro lists the set of options for which 9890075Sobrienspecial versions of @file{libgcc.a} must be built. Write options that 9990075Sobrienare mutually incompatible side by side, separated by a slash. Write 10090075Sobrienoptions that may be used together separated by a space. The build 10190075Sobrienprocedure will build all combinations of compatible options. 10290075Sobrien 10390075SobrienFor example, if you set @code{MULTILIB_OPTIONS} to @samp{m68000/m68020 10490075Sobrienmsoft-float}, @file{Makefile} will build special versions of 10590075Sobrien@file{libgcc.a} using the following sets of options: @option{-m68000}, 10690075Sobrien@option{-m68020}, @option{-msoft-float}, @samp{-m68000 -msoft-float}, and 10790075Sobrien@samp{-m68020 -msoft-float}. 10890075Sobrien 10990075Sobrien@findex MULTILIB_DIRNAMES 11090075Sobrien@item MULTILIB_DIRNAMES 11190075SobrienIf @code{MULTILIB_OPTIONS} is used, this variable specifies the 11290075Sobriendirectory names that should be used to hold the various libraries. 11390075SobrienWrite one element in @code{MULTILIB_DIRNAMES} for each element in 11490075Sobrien@code{MULTILIB_OPTIONS}. If @code{MULTILIB_DIRNAMES} is not used, the 11590075Sobriendefault value will be @code{MULTILIB_OPTIONS}, with all slashes treated 11690075Sobrienas spaces. 11790075Sobrien 11890075SobrienFor example, if @code{MULTILIB_OPTIONS} is set to @samp{m68000/m68020 11990075Sobrienmsoft-float}, then the default value of @code{MULTILIB_DIRNAMES} is 12090075Sobrien@samp{m68000 m68020 msoft-float}. You may specify a different value if 12190075Sobrienyou desire a different set of directory names. 12290075Sobrien 12390075Sobrien@findex MULTILIB_MATCHES 12490075Sobrien@item MULTILIB_MATCHES 12590075SobrienSometimes the same option may be written in two different ways. If an 12690075Sobrienoption is listed in @code{MULTILIB_OPTIONS}, GCC needs to know about 12790075Sobrienany synonyms. In that case, set @code{MULTILIB_MATCHES} to a list of 12890075Sobrienitems of the form @samp{option=option} to describe all relevant 12990075Sobriensynonyms. For example, @samp{m68000=mc68000 m68020=mc68020}. 13090075Sobrien 13190075Sobrien@findex MULTILIB_EXCEPTIONS 13290075Sobrien@item MULTILIB_EXCEPTIONS 13390075SobrienSometimes when there are multiple sets of @code{MULTILIB_OPTIONS} being 13490075Sobrienspecified, there are combinations that should not be built. In that 13590075Sobriencase, set @code{MULTILIB_EXCEPTIONS} to be all of the switch exceptions 13690075Sobrienin shell case syntax that should not be built. 13790075Sobrien 138119256SkanFor example the ARM processor cannot execute both hardware floating 139119256Skanpoint instructions and the reduced size THUMB instructions at the same 140119256Skantime, so there is no need to build libraries with both of these 141119256Skanoptions enabled. Therefore @code{MULTILIB_EXCEPTIONS} is set to: 14290075Sobrien@smallexample 143119256Skan*mthumb/*mhard-float* 14490075Sobrien@end smallexample 14590075Sobrien 14690075Sobrien@findex MULTILIB_EXTRA_OPTS 14790075Sobrien@item MULTILIB_EXTRA_OPTS 14890075SobrienSometimes it is desirable that when building multiple versions of 14990075Sobrien@file{libgcc.a} certain options should always be passed on to the 15090075Sobriencompiler. In that case, set @code{MULTILIB_EXTRA_OPTS} to be the list 151119256Skanof options to be used for all builds. If you set this, you should 152119256Skanprobably set @code{CRTSTUFF_T_CFLAGS} to a dash followed by it. 153119256Skan 154169689Skan@findex NATIVE_SYSTEM_HEADER_DIR 155169689Skan@item NATIVE_SYSTEM_HEADER_DIR 156169689SkanIf the default location for system headers is not @file{/usr/include}, 157169689Skanyou must set this to the directory containing the headers. This value 158169689Skanshould match the value of the @code{SYSTEM_INCLUDE_DIR} macro. 159169689Skan 160119256Skan@findex SPECS 161119256Skan@item SPECS 162119256SkanUnfortunately, setting @code{MULTILIB_EXTRA_OPTS} is not enough, since 163119256Skanit does not affect the build of target libraries, at least not the 164119256Skanbuild of the default multilib. One possible work-around is to use 165119256Skan@code{DRIVER_SELF_SPECS} to bring options from the @file{specs} file 166119256Skanas if they had been passed in the compiler driver command line. 167119256SkanHowever, you don't want to be adding these options after the toolchain 168119256Skanis installed, so you can instead tweak the @file{specs} file that will 169119256Skanbe used during the toolchain build, while you still install the 170119256Skanoriginal, built-in @file{specs}. The trick is to set @code{SPECS} to 171119256Skansome other filename (say @file{specs.install}), that will then be 172119256Skancreated out of the built-in specs, and introduce a @file{Makefile} 173119256Skanrule to generate the @file{specs} file that's going to be used at 174119256Skanbuild time out of your @file{specs.install}. 17590075Sobrien@end table 17690075Sobrien 17790075Sobrien@node Host Fragment 17890075Sobrien@section Host Makefile Fragments 17990075Sobrien@cindex host makefile fragment 18090075Sobrien@cindex @file{x-@var{host}} 18190075Sobrien 18290075SobrienThe use of @file{x-@var{host}} fragments is discouraged. You should do 18390075Sobrienso only if there is no other mechanism to get the behavior desired. 18490075SobrienHost fragments should never forcibly override variables set by the 18590075Sobrienconfigure script, as they may have been adjusted by the user. 18690075Sobrien 18790075SobrienVariables provided for host fragments to set include: 18890075Sobrien 18990075Sobrien@table @code 19090075Sobrien 19190075Sobrien@item X_CFLAGS 19290075Sobrien@itemx X_CPPFLAGS 19390075SobrienThese are extra flags to pass to the C compiler and preprocessor, 19490075Sobrienrespectively. They are used both when building GCC, and when compiling 195169689Skanthings with the just-built GCC@. 19690075Sobrien 19790075Sobrien@item XCFLAGS 19890075SobrienThese are extra flags to use when building the compiler. They are not 19990075Sobrienused when compiling @file{libgcc.a}. However, they @emph{are} used when 20090075Sobrienrecompiling the compiler with itself in later stages of a bootstrap. 20190075Sobrien 20290075Sobrien@item BOOT_LDFLAGS 20390075SobrienFlags to be passed to the linker when recompiling the compiler with 20490075Sobrienitself in later stages of a bootstrap. You might need to use this if, 20590075Sobrienfor instance, one of the front ends needs more text space than the 20690075Sobrienlinker provides by default. 20790075Sobrien 20890075Sobrien@item EXTRA_PROGRAMS 20990075SobrienA list of additional programs required to use the compiler on this host, 21090075Sobrienwhich should be compiled with GCC and installed alongside the front 21190075Sobrienends. If you set this variable, you must also provide rules to build 21290075Sobrienthe extra programs. 21390075Sobrien 21490075Sobrien@end table 215