[72] | 1 | # $Id: GCC.kmk 973 2007-05-27 17:09:49Z bird $
|
---|
| 2 | ## @file
|
---|
| 3 | #
|
---|
[667] | 4 | # kBuild Tool Config - Generic GCC Using The System GCC.
|
---|
[72] | 5 | #
|
---|
[782] | 6 | # Copyright (c) 2004-2007 knut st. osmundsen <bird-kBuild-spam@anduin.net>
|
---|
[72] | 7 | #
|
---|
| 8 | #
|
---|
| 9 | # This file is part of kBuild.
|
---|
| 10 | #
|
---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
---|
| 12 | # it under the terms of the GNU General Public License as published by
|
---|
| 13 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | # (at your option) any later version.
|
---|
| 15 | #
|
---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | # GNU General Public License for more details.
|
---|
| 20 | #
|
---|
| 21 | # You should have received a copy of the GNU General Public License
|
---|
| 22 | # along with kBuild; if not, write to the Free Software
|
---|
| 23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 24 | #
|
---|
| 25 | #
|
---|
| 26 |
|
---|
[667] | 27 | TOOL_GCC := Generic GCC Using The System GCC.
|
---|
[72] | 28 |
|
---|
[667] | 29 | # Tool Specific Properties
|
---|
| 30 | TOOL_GCC_CC ?= gcc$(HOSTSUFF_EXE)
|
---|
| 31 | TOOL_GCC_CXX ?= g++$(HOSTSUFF_EXE)
|
---|
| 32 | TOOL_GCC_AS ?= gcc$(HOSTSUFF_EXE)
|
---|
| 33 | TOOL_GCC_AR ?= ar$(HOSTSUFF_EXE)
|
---|
[846] | 34 | TOOL_GCC_RANLIB ?= ranlib$(HOSTSUFF_EXE)
|
---|
[973] | 35 | TOOL_GCC_LD ?= gcc$(HOSTSUFF_EXE)
|
---|
[667] | 36 | TOOL_GCC_LDFLAGS.dll.os2 ?= -Zdll
|
---|
[846] | 37 | TOOL_GCC_LDFLAGS.dll.darwin ?= -dynamiclib
|
---|
[667] | 38 | ifndef TOOL_GCC_LDFLAGS.$(BUILD_TARGET)
|
---|
| 39 | TOOL_GCC_LDFLAGS.dll ?= -shared
|
---|
| 40 | else
|
---|
| 41 | TOOL_GCC_LDFLAGS.dll ?= $(TOOL_GCC_LDFLAGS.$(BUILD_TARGET))
|
---|
| 42 | endif
|
---|
[73] | 43 |
|
---|
[667] | 44 | # General Properties used by kBuild
|
---|
| 45 | TOOL_GCC_COBJSUFF ?= .o
|
---|
[782] | 46 | TOOL_GCC_CFLAGS ?=
|
---|
[667] | 47 | TOOL_GCC_CFLAGS.debug ?= -g
|
---|
| 48 | TOOL_GCC_CFLAGS.profile ?= -g -O2 #-pg
|
---|
| 49 | TOOL_GCC_CFLAGS.release ?= -O2
|
---|
| 50 | TOOL_GCC_CINCS ?=
|
---|
| 51 | TOOL_GCC_CDEFS ?=
|
---|
[72] | 52 |
|
---|
[667] | 53 | TOOL_GCC_CXXOBJSUFF ?= .o
|
---|
| 54 | TOOL_GCC_CXXOBJSUFF ?= .o
|
---|
[782] | 55 | TOOL_GCC_CXXFLAGS ?=
|
---|
[667] | 56 | TOOL_GCC_CXXFLAGS.debug ?= -g -O0
|
---|
| 57 | TOOL_GCC_CXXFLAGS.profile ?= -g -O2 #-pg
|
---|
| 58 | TOOL_GCC_CXXFLAGS.release ?= -O2
|
---|
| 59 | TOOL_GCC_CXXINCS ?=
|
---|
| 60 | TOOL_GCC_CXXDEFS ?=
|
---|
[72] | 61 |
|
---|
[667] | 62 | TOOL_GCC_ASFLAGS ?= -x assembler-with-cpp
|
---|
| 63 | TOOL_GCC_ASFLAGS.debug ?= -g
|
---|
| 64 | TOOL_GCC_ASFLAGS.profile ?= -g
|
---|
| 65 | TOOL_GCC_ASOBJSUFF ?= .o
|
---|
[73] | 66 |
|
---|
[667] | 67 | TOOL_GCC_ARFLAGS ?= cr
|
---|
| 68 | TOOL_GCC_ARLIBSUFF ?= .a
|
---|
[73] | 69 |
|
---|
[667] | 70 | TOOL_GCC_LDFLAGS ?=
|
---|
| 71 | TOOL_GCC_LDFLAGS.debug ?= -g
|
---|
| 72 | TOOL_GCC_LDFLAGS.profile ?= -g
|
---|
[73] | 73 |
|
---|
[74] | 74 |
|
---|
[72] | 75 | ## Compile C source.
|
---|
[73] | 76 | # @param $(target) Normalized main target name.
|
---|
| 77 | # @param $(source) Source filename (relative).
|
---|
[235] | 78 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
[73] | 79 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 80 | # @param $(flags) Flags.
|
---|
| 81 | # @param $(defs) Definitions. No -D or something.
|
---|
| 82 | # @param $(incs) Includes. No -I or something.
|
---|
[235] | 83 | # @param $(dirdep) Directory creation dependency.
|
---|
| 84 | # @param $(deps) Other dependencies.
|
---|
[73] | 85 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[235] | 86 | # @param $(objsuff) Object suffix.
|
---|
[380] | 87 | #
|
---|
| 88 | TOOL_GCC_COMPILE_C_OUTPUT =
|
---|
| 89 | TOOL_GCC_COMPILE_C_DEPEND =
|
---|
| 90 | TOOL_GCC_COMPILE_C_DEPORD =
|
---|
| 91 | define TOOL_GCC_COMPILE_C_CMDS
|
---|
[696] | 92 | $(QUIET)$(TOOL_GCC_CC) -c\
|
---|
[73] | 93 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
[846] | 94 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
---|
| 95 | -o $(obj)\
|
---|
[697] | 96 | $(abspath $(source))
|
---|
[72] | 97 | endef
|
---|
| 98 |
|
---|
[73] | 99 |
|
---|
[77] | 100 | ## Compile C++ source.
|
---|
| 101 | # @param $(target) Normalized main target name.
|
---|
| 102 | # @param $(source) Source filename (relative).
|
---|
[235] | 103 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
[77] | 104 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 105 | # @param $(flags) Flags.
|
---|
| 106 | # @param $(defs) Definitions. No -D or something.
|
---|
| 107 | # @param $(incs) Includes. No -I or something.
|
---|
[235] | 108 | # @param $(dirdep) Directory creation dependency.
|
---|
| 109 | # @param $(deps) Other dependencies.
|
---|
[77] | 110 | #
|
---|
| 111 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[235] | 112 | # @param $(objsuff) Object suffix.
|
---|
[380] | 113 | TOOL_GCC_COMPILE_CXX_OUTPUT =
|
---|
| 114 | TOOL_GCC_COMPILE_CXX_DEPEND =
|
---|
| 115 | TOOL_GCC_COMPILE_CXX_DEPORD =
|
---|
| 116 | define TOOL_GCC_COMPILE_CXX_CMDS
|
---|
[696] | 117 | $(QUIET)$(TOOL_GCC_CXX) -c\
|
---|
[77] | 118 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
[846] | 119 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
---|
| 120 | -o $(obj)\
|
---|
[697] | 121 | $(abspath $(source))
|
---|
[77] | 122 | endef
|
---|
| 123 |
|
---|
| 124 |
|
---|
[465] | 125 | ## Compile Assembly source.
|
---|
| 126 | # @param $(target) Normalized main target name.
|
---|
| 127 | # @param $(source) Source filename (relative).
|
---|
| 128 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
---|
| 129 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
---|
| 130 | # @param $(flags) Flags.
|
---|
| 131 | # @param $(defs) Definitions. No -D or something.
|
---|
| 132 | # @param $(incs) Includes. No -I or something.
|
---|
| 133 | # @param $(dirdep) Directory creation dependency.
|
---|
| 134 | # @param $(deps) Other dependencies.
|
---|
| 135 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 136 | # @param $(objsuff) Object suffix.
|
---|
| 137 | #
|
---|
[469] | 138 | TOOL_GCC_COMPILE_AS_OUTPUT =
|
---|
[465] | 139 | TOOL_GCC_COMPILE_AS_DEPEND =
|
---|
| 140 | TOOL_GCC_COMPILE_AS_DEPORD =
|
---|
| 141 | define TOOL_GCC_COMPILE_AS_CMDS
|
---|
[696] | 142 | $(QUIET)$(TOOL_GCC_AS) -c\
|
---|
[465] | 143 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
---|
[846] | 144 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
---|
| 145 | -o $(obj)\
|
---|
[697] | 146 | $(abspath $(source))
|
---|
[465] | 147 | endef
|
---|
| 148 |
|
---|
| 149 |
|
---|
[73] | 150 | ## Link library
|
---|
| 151 | # @param $(target) Normalized main target name.
|
---|
[380] | 152 | # @param $(out) Library name.
|
---|
[73] | 153 | # @param $(objs) Object files to put in the library.
|
---|
| 154 | # @param $(flags) Flags.
|
---|
[235] | 155 | # @param $(dirdep) Directory creation dependency.
|
---|
| 156 | # @param $(deps) Other dependencies.
|
---|
[73] | 157 | #
|
---|
| 158 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[380] | 159 | TOOL_GCC_LINK_LIBRARY_OUTPUT =
|
---|
| 160 | TOOL_GCC_LINK_LIBRARY_DEPEND =
|
---|
[465] | 161 | TOOL_GCC_LINK_LIBRARY_DEPORD =
|
---|
[380] | 162 | define TOOL_GCC_LINK_LIBRARY_CMDS
|
---|
[696] | 163 | $(QUIET)$(TOOL_GCC_AR) $(flags) $(out) $(objs)
|
---|
[846] | 164 | $(call xargs,$(QUIET)$(TOOL_GCC_AR) $(flags) $(out),$(objs))
|
---|
| 165 | $(foreach lib,$(othersrc)\
|
---|
| 166 | ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
|
---|
| 167 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
|
---|
| 168 | $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
|
---|
| 169 | $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
|
---|
| 170 | && $(TOOL_GCC_AR) x $(abspath $(lib)) \
|
---|
| 171 | && $(TOOL_GCC_AR) $(flags) $(out) *) \
|
---|
| 172 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
|
---|
| 173 | $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
|
---|
| 174 | $(QUIET)$(TOOL_GCC_RANLIB) $(out)
|
---|
[73] | 175 | endef
|
---|
| 176 |
|
---|
[74] | 177 |
|
---|
| 178 | ## Link program
|
---|
| 179 | # @param $(target) Normalized main target name.
|
---|
[353] | 180 | # @param $(out) Program name.
|
---|
[74] | 181 | # @param $(objs) Object files to link together.
|
---|
| 182 | # @param $(libs) Libraries to search.
|
---|
| 183 | # @param $(libpath) Library search paths.
|
---|
| 184 | # @param $(flags) Flags.
|
---|
[235] | 185 | # @param $(dirdep) Directory creation dependency.
|
---|
| 186 | # @param $(deps) Other dependencies.
|
---|
| 187 | # @param $(othersrc) Unhandled sources.
|
---|
| 188 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 189 | # @param $(custom_post) Custom step invoked after linking.
|
---|
[74] | 190 | #
|
---|
| 191 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
[380] | 192 | TOOL_GCC_LINK_PROGRAM_OUTPUT =
|
---|
| 193 | TOOL_GCC_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
[465] | 194 | TOOL_GCC_LINK_PROGRAM_DEPORD =
|
---|
[380] | 195 | define TOOL_GCC_LINK_PROGRAM_CMDS
|
---|
[696] | 196 | $(QUIET)$(TOOL_GCC_LD) $(flags) -o $(out) $(objs) \
|
---|
[380] | 197 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
[74] | 198 | endef
|
---|
| 199 |
|
---|
[130] | 200 |
|
---|
[353] | 201 | ## Link DLL
|
---|
[130] | 202 | # @param $(target) Normalized main target name.
|
---|
[353] | 203 | # @param $(out) Program name.
|
---|
[130] | 204 | # @param $(objs) Object files to link together.
|
---|
| 205 | # @param $(libs) Libraries to search.
|
---|
| 206 | # @param $(libpath) Library search paths.
|
---|
| 207 | # @param $(flags) Flags.
|
---|
[235] | 208 | # @param $(dirdep) Directory creation dependency.
|
---|
| 209 | # @param $(deps) Other dependencies.
|
---|
| 210 | # @param $(othersrc) Unhandled sources.
|
---|
| 211 | # @param $(custom_pre) Custom step invoked before linking.
|
---|
| 212 | # @param $(custom_post) Custom step invoked after linking.
|
---|
[380] | 213 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
---|
| 214 | TOOL_GCC_LINK_DLL_OUTPUT =
|
---|
| 215 | TOOL_GCC_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
---|
[465] | 216 | TOOL_GCC_LINK_DLL_DEPORD =
|
---|
[380] | 217 | define TOOL_GCC_LINK_DLL_CMDS
|
---|
[696] | 218 | $(QUIET)$(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
|
---|
[353] | 219 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
---|
[130] | 220 | endef
|
---|
| 221 |
|
---|