| 1 | # $Id: GCC.kmk 2545 2011-09-13 19:09:05Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | # kBuild Tool Config - Generic GCC Using The System GCC.
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2004-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
|---|
| 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 | # As a special exception you are granted permission to include this file, via
|
|---|
| 27 | # the kmk include directive, as you wish without this in itself causing the
|
|---|
| 28 | # resulting makefile, program or whatever to be covered by the GPL license.
|
|---|
| 29 | # This exception does not however invalidate any other reasons why the makefile,
|
|---|
| 30 | # program, whatever should not be covered the GPL.
|
|---|
| 31 | #
|
|---|
| 32 | #
|
|---|
| 33 |
|
|---|
| 34 | TOOL_GCC := Generic GCC Using The System GCC.
|
|---|
| 35 |
|
|---|
| 36 | # Tool Specific Properties
|
|---|
| 37 | TOOL_GCC_CC ?= gcc$(HOSTSUFF_EXE)
|
|---|
| 38 | TOOL_GCC_CXX ?= g++$(HOSTSUFF_EXE)
|
|---|
| 39 | TOOL_GCC_AS ?= gcc$(HOSTSUFF_EXE)
|
|---|
| 40 | TOOL_GCC_AR ?= ar$(HOSTSUFF_EXE)
|
|---|
| 41 | TOOL_GCC_RANLIB ?= ranlib$(HOSTSUFF_EXE)
|
|---|
| 42 | TOOL_GCC_LD ?= gcc$(HOSTSUFF_EXE)
|
|---|
| 43 | TOOL_GCC_LDFLAGS.dll.os2 ?= -Zdll
|
|---|
| 44 | TOOL_GCC_LDFLAGS.dll.darwin ?= -dynamiclib
|
|---|
| 45 | ifndef TOOL_GCC_LDFLAGS.$(KBUILD_TARGET)
|
|---|
| 46 | TOOL_GCC_LDFLAGS.dll ?= -shared
|
|---|
| 47 | else
|
|---|
| 48 | TOOL_GCC_LDFLAGS.dll ?= $(TOOL_GCC_LDFLAGS.$(KBUILD_TARGET))
|
|---|
| 49 | endif
|
|---|
| 50 |
|
|---|
| 51 | # General Properties used by kBuild
|
|---|
| 52 | TOOL_GCC_COBJSUFF ?= .o
|
|---|
| 53 | TOOL_GCC_CFLAGS ?=
|
|---|
| 54 | TOOL_GCC_CFLAGS.debug ?= -g
|
|---|
| 55 | TOOL_GCC_CFLAGS.profile ?= -g -O2 #-pg
|
|---|
| 56 | TOOL_GCC_CFLAGS.release ?= -O2
|
|---|
| 57 | TOOL_GCC_CINCS ?=
|
|---|
| 58 | TOOL_GCC_CDEFS ?=
|
|---|
| 59 |
|
|---|
| 60 | TOOL_GCC_CXXOBJSUFF ?= .o
|
|---|
| 61 | TOOL_GCC_CXXOBJSUFF ?= .o
|
|---|
| 62 | TOOL_GCC_CXXFLAGS ?=
|
|---|
| 63 | TOOL_GCC_CXXFLAGS.debug ?= -g -O0
|
|---|
| 64 | TOOL_GCC_CXXFLAGS.profile ?= -g -O2 #-pg
|
|---|
| 65 | TOOL_GCC_CXXFLAGS.release ?= -O2
|
|---|
| 66 | TOOL_GCC_CXXINCS ?=
|
|---|
| 67 | TOOL_GCC_CXXDEFS ?=
|
|---|
| 68 |
|
|---|
| 69 | TOOL_GCC_ASFLAGS ?= -x assembler-with-cpp
|
|---|
| 70 | TOOL_GCC_ASFLAGS.debug ?= -g
|
|---|
| 71 | TOOL_GCC_ASFLAGS.profile ?= -g
|
|---|
| 72 | TOOL_GCC_ASOBJSUFF ?= .o
|
|---|
| 73 |
|
|---|
| 74 | TOOL_GCC_ARFLAGS ?= cr
|
|---|
| 75 | TOOL_GCC_ARLIBSUFF ?= .a
|
|---|
| 76 |
|
|---|
| 77 | TOOL_GCC_LDFLAGS ?=
|
|---|
| 78 | TOOL_GCC_LDFLAGS.debug ?= -g
|
|---|
| 79 | TOOL_GCC_LDFLAGS.profile ?= -g
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | ## Compile C source.
|
|---|
| 83 | # @param $(target) Normalized main target name.
|
|---|
| 84 | # @param $(source) Source filename (relative).
|
|---|
| 85 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 86 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 87 | # @param $(flags) Flags.
|
|---|
| 88 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 89 | # @param $(incs) Includes. No -I or something.
|
|---|
| 90 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 91 | # @param $(deps) Other dependencies.
|
|---|
| 92 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 93 | # @param $(objsuff) Object suffix.
|
|---|
| 94 | #
|
|---|
| 95 | TOOL_GCC_COMPILE_C_OUTPUT =
|
|---|
| 96 | TOOL_GCC_COMPILE_C_DEPEND =
|
|---|
| 97 | TOOL_GCC_COMPILE_C_DEPORD =
|
|---|
| 98 | define TOOL_GCC_COMPILE_C_CMDS
|
|---|
| 99 | $(QUIET)$(TOOL_GCC_CC) -c\
|
|---|
| 100 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 101 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
|---|
| 102 | -o $(obj)\
|
|---|
| 103 | $(abspath $(source))
|
|---|
| 104 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 105 | endef
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 | ## Compile C++ source.
|
|---|
| 109 | # @param $(target) Normalized main target name.
|
|---|
| 110 | # @param $(source) Source filename (relative).
|
|---|
| 111 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 112 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 113 | # @param $(flags) Flags.
|
|---|
| 114 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 115 | # @param $(incs) Includes. No -I or something.
|
|---|
| 116 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 117 | # @param $(deps) Other dependencies.
|
|---|
| 118 | #
|
|---|
| 119 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 120 | # @param $(objsuff) Object suffix.
|
|---|
| 121 | TOOL_GCC_COMPILE_CXX_OUTPUT =
|
|---|
| 122 | TOOL_GCC_COMPILE_CXX_DEPEND =
|
|---|
| 123 | TOOL_GCC_COMPILE_CXX_DEPORD =
|
|---|
| 124 | define TOOL_GCC_COMPILE_CXX_CMDS
|
|---|
| 125 | $(QUIET)$(TOOL_GCC_CXX) -c\
|
|---|
| 126 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 127 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
|---|
| 128 | -o $(obj)\
|
|---|
| 129 | $(abspath $(source))
|
|---|
| 130 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 131 | endef
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | ## Compile Assembly source.
|
|---|
| 135 | # @param $(target) Normalized main target name.
|
|---|
| 136 | # @param $(source) Source filename (relative).
|
|---|
| 137 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 138 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 139 | # @param $(flags) Flags.
|
|---|
| 140 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 141 | # @param $(incs) Includes. No -I or something.
|
|---|
| 142 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 143 | # @param $(deps) Other dependencies.
|
|---|
| 144 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 145 | # @param $(objsuff) Object suffix.
|
|---|
| 146 | #
|
|---|
| 147 | TOOL_GCC_COMPILE_AS_OUTPUT =
|
|---|
| 148 | TOOL_GCC_COMPILE_AS_DEPEND =
|
|---|
| 149 | TOOL_GCC_COMPILE_AS_DEPORD =
|
|---|
| 150 | define TOOL_GCC_COMPILE_AS_CMDS
|
|---|
| 151 | $(QUIET)$(TOOL_GCC_AS) -c\
|
|---|
| 152 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 153 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) \
|
|---|
| 154 | -o $(obj)\
|
|---|
| 155 | $(abspath $(source))
|
|---|
| 156 | $(QUIET)$(APPEND) -n "$(dep)" "" "$(source):" ""
|
|---|
| 157 | endef
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | ## Link library
|
|---|
| 161 | # @param $(target) Normalized main target name.
|
|---|
| 162 | # @param $(out) Library name.
|
|---|
| 163 | # @param $(objs) Object files to put in the library.
|
|---|
| 164 | # @param $(flags) Flags.
|
|---|
| 165 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 166 | # @param $(deps) Other dependencies.
|
|---|
| 167 | #
|
|---|
| 168 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 169 | TOOL_GCC_LINK_LIBRARY_OUTPUT =
|
|---|
| 170 | TOOL_GCC_LINK_LIBRARY_DEPEND =
|
|---|
| 171 | TOOL_GCC_LINK_LIBRARY_DEPORD =
|
|---|
| 172 | define TOOL_GCC_LINK_LIBRARY_CMDS
|
|---|
| 173 | $(QUIET)$(TOOL_GCC_AR) $(flags) $(out) $(objs)
|
|---|
| 174 | $(call xargs,$(QUIET)$(TOOL_GCC_AR) $(flags) $(out),$(objs))
|
|---|
| 175 | $(foreach lib,$(othersrc)\
|
|---|
| 176 | ,$(NL)$(TAB)$(call MSG_AR_MERGE,$(target),$(out),$(lib)) \
|
|---|
| 177 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))ar.tmp.dir/* \
|
|---|
| 178 | $(NL)$(TAB)$(QUIET)$(MKDIR) -p $(dir $(outbase))/ar.tmp.dir/ \
|
|---|
| 179 | $(NL)$(TAB)$(QUIET)(cd $(dir $(outbase))ar.tmp.dir/ \
|
|---|
| 180 | && $(TOOL_GCC_AR) x $(abspath $(lib)) \
|
|---|
| 181 | && $(TOOL_GCC_AR) $(flags) $(out) *) \
|
|---|
| 182 | $(NL)$(TAB)$(QUIET)$(RM_EXT) -f $(dir $(outbase))/ar.tmp.dir/* \
|
|---|
| 183 | $(NL)$(TAB)$(QUIET)$(RMDIR) $(dir $(outbase))ar.tmp.dir/)
|
|---|
| 184 | $(QUIET)$(TOOL_GCC_RANLIB) $(out)
|
|---|
| 185 | endef
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | ## Link program
|
|---|
| 189 | # @param $(target) Normalized main target name.
|
|---|
| 190 | # @param $(out) Program name.
|
|---|
| 191 | # @param $(objs) Object files to link together.
|
|---|
| 192 | # @param $(libs) Libraries to search.
|
|---|
| 193 | # @param $(libpath) Library search paths.
|
|---|
| 194 | # @param $(flags) Flags.
|
|---|
| 195 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 196 | # @param $(deps) Other dependencies.
|
|---|
| 197 | # @param $(othersrc) Unhandled sources.
|
|---|
| 198 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 199 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 200 | #
|
|---|
| 201 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 202 | TOOL_GCC_LINK_PROGRAM_OUTPUT =
|
|---|
| 203 | TOOL_GCC_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 204 | TOOL_GCC_LINK_PROGRAM_DEPORD =
|
|---|
| 205 | define TOOL_GCC_LINK_PROGRAM_CMDS
|
|---|
| 206 | $(QUIET)$(TOOL_GCC_LD) $(flags) -o $(out) $(objs) \
|
|---|
| 207 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
|---|
| 208 | endef
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 | ## Link DLL
|
|---|
| 212 | # @param $(target) Normalized main target name.
|
|---|
| 213 | # @param $(out) Program name.
|
|---|
| 214 | # @param $(objs) Object files to link together.
|
|---|
| 215 | # @param $(libs) Libraries to search.
|
|---|
| 216 | # @param $(libpath) Library search paths.
|
|---|
| 217 | # @param $(flags) Flags.
|
|---|
| 218 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 219 | # @param $(deps) Other dependencies.
|
|---|
| 220 | # @param $(othersrc) Unhandled sources.
|
|---|
| 221 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 222 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 223 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 224 | TOOL_GCC_LINK_DLL_OUTPUT =
|
|---|
| 225 | TOOL_GCC_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 226 | TOOL_GCC_LINK_DLL_DEPORD =
|
|---|
| 227 | define TOOL_GCC_LINK_DLL_CMDS
|
|---|
| 228 | $(QUIET)$(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
|
|---|
| 229 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))
|
|---|
| 230 | endef
|
|---|
| 231 |
|
|---|