| 1 | # $Id: GCC.kmk 471 2006-07-15 04:33:22Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild Tool Config - Generic GCC.
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
|
|---|
| 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 |
|
|---|
| 27 |
|
|---|
| 28 | TOOL_GCC := Generic GCC
|
|---|
| 29 |
|
|---|
| 30 | TOOL_GCC_CC := gcc$(HOSTSUFF_EXE)
|
|---|
| 31 | TOOL_GCC_COBJSUFF := .o
|
|---|
| 32 | TOOL_GCC_CFLAGS := -g
|
|---|
| 33 | TOOL_GCC_CFLAGS.debug := -O0
|
|---|
| 34 | TOOL_GCC_CFLAGS.release := -O2
|
|---|
| 35 | TOOL_GCC_CFLAGS.profile := -O2 #-pg
|
|---|
| 36 | TOOL_GCC_CINCS :=
|
|---|
| 37 | TOOL_GCC_CDEFS :=
|
|---|
| 38 |
|
|---|
| 39 | TOOL_GCC_CXX := g++$(HOSTSUFF_EXE)
|
|---|
| 40 | TOOL_GCC_CXXOBJSUFF := .o
|
|---|
| 41 | TOOL_GCC_CXXOBJSUFF := .o
|
|---|
| 42 | TOOL_GCC_CXXFLAGS := -g
|
|---|
| 43 | TOOL_GCC_CXXFLAGS.debug := -O0
|
|---|
| 44 | TOOL_GCC_CXXFLAGS.release := -O2
|
|---|
| 45 | TOOL_GCC_CXXFLAGS.profile := -O2 #-pg
|
|---|
| 46 | TOOL_GCC_CXXINCS :=
|
|---|
| 47 | TOOL_GCC_CXXDEFS :=
|
|---|
| 48 |
|
|---|
| 49 | TOOL_GCC_AS := gcc$(HOSTSUFF_EXE)
|
|---|
| 50 | TOOL_GCC_ASFLAGS := -g -x assembler-with-cpp
|
|---|
| 51 | TOOL_GCC_ASOBJSUFF := .o
|
|---|
| 52 |
|
|---|
| 53 | TOOL_GCC_AR := ar$(HOSTSUFF_EXE)
|
|---|
| 54 | TOOL_GCC_ARFLAGS := cr
|
|---|
| 55 | TOOL_GCC_ARLIBSUFF := .a
|
|---|
| 56 |
|
|---|
| 57 | TOOL_GCC_LD := g++$(HOSTSUFF_EXE)
|
|---|
| 58 | TOOL_GCC_LDFLAGS :=
|
|---|
| 59 | TOOL_GCC_LDFLAGS.debug := -g
|
|---|
| 60 | TOOL_GCC_LDFLAGS.release := -s
|
|---|
| 61 | TOOL_GCC_LDFLAGS.dll.os2 := -Zdll
|
|---|
| 62 | ifndef TOOL_GCC_LDFLAGS.$(BUILD_TARGET)
|
|---|
| 63 | TOOL_GCC_LDFLAGS.dll := -shared
|
|---|
| 64 | else
|
|---|
| 65 | TOOL_GCC_LDFLAGS.dll := $(TOOL_GCC_LDFLAGS.$(BUILD_TARGET))
|
|---|
| 66 | endif
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | ## Compile C source.
|
|---|
| 70 | # @param $(target) Normalized main target name.
|
|---|
| 71 | # @param $(source) Source filename (relative).
|
|---|
| 72 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 73 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 74 | # @param $(flags) Flags.
|
|---|
| 75 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 76 | # @param $(incs) Includes. No -I or something.
|
|---|
| 77 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 78 | # @param $(deps) Other dependencies.
|
|---|
| 79 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 80 | # @param $(objsuff) Object suffix.
|
|---|
| 81 | #
|
|---|
| 82 | TOOL_GCC_COMPILE_C_OUTPUT =
|
|---|
| 83 | TOOL_GCC_COMPILE_C_DEPEND =
|
|---|
| 84 | TOOL_GCC_COMPILE_C_DEPORD =
|
|---|
| 85 | define TOOL_GCC_COMPILE_C_CMDS
|
|---|
| 86 | $(TOOL_GCC_CC) -c\
|
|---|
| 87 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 88 | -Wp,-MD,$(dep) -Wp,-MT,$(out) \
|
|---|
| 89 | -o $(out)\
|
|---|
| 90 | $(call ABSPATH,$(source))
|
|---|
| 91 | endef
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 | ## Compile C++ source.
|
|---|
| 95 | # @param $(target) Normalized main target name.
|
|---|
| 96 | # @param $(source) Source filename (relative).
|
|---|
| 97 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 98 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 99 | # @param $(flags) Flags.
|
|---|
| 100 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 101 | # @param $(incs) Includes. No -I or something.
|
|---|
| 102 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 103 | # @param $(deps) Other dependencies.
|
|---|
| 104 | #
|
|---|
| 105 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 106 | # @param $(objsuff) Object suffix.
|
|---|
| 107 | TOOL_GCC_COMPILE_CXX_OUTPUT =
|
|---|
| 108 | TOOL_GCC_COMPILE_CXX_DEPEND =
|
|---|
| 109 | TOOL_GCC_COMPILE_CXX_DEPORD =
|
|---|
| 110 | define TOOL_GCC_COMPILE_CXX_CMDS
|
|---|
| 111 | $(TOOL_GCC_CXX) -c\
|
|---|
| 112 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 113 | -Wp,-MD,$(dep) -Wp,-MT,$(out) \
|
|---|
| 114 | -o $(out)\
|
|---|
| 115 | $(call ABSPATH,$(source))
|
|---|
| 116 | endef
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | ## Compile Assembly source.
|
|---|
| 120 | # @param $(target) Normalized main target name.
|
|---|
| 121 | # @param $(source) Source filename (relative).
|
|---|
| 122 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 123 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 124 | # @param $(flags) Flags.
|
|---|
| 125 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 126 | # @param $(incs) Includes. No -I or something.
|
|---|
| 127 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 128 | # @param $(deps) Other dependencies.
|
|---|
| 129 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 130 | # @param $(objsuff) Object suffix.
|
|---|
| 131 | #
|
|---|
| 132 | TOOL_GCC_COMPILE_AS_OUTPUT =
|
|---|
| 133 | TOOL_GCC_COMPILE_AS_DEPEND =
|
|---|
| 134 | TOOL_GCC_COMPILE_AS_DEPORD =
|
|---|
| 135 | define TOOL_GCC_COMPILE_AS_CMDS
|
|---|
| 136 | $(TOOL_GCC_AS) -c\
|
|---|
| 137 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 138 | -Wp,-MD,$(dep) -Wp,-MT,$(out) \
|
|---|
| 139 | -o $(out)\
|
|---|
| 140 | $(call ABSPATH,$(source))
|
|---|
| 141 | endef
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | ## Link library
|
|---|
| 145 | # @param $(target) Normalized main target name.
|
|---|
| 146 | # @param $(out) Library name.
|
|---|
| 147 | # @param $(objs) Object files to put in the library.
|
|---|
| 148 | # @param $(flags) Flags.
|
|---|
| 149 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 150 | # @param $(deps) Other dependencies.
|
|---|
| 151 | #
|
|---|
| 152 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 153 | TOOL_GCC_LINK_LIBRARY_OUTPUT =
|
|---|
| 154 | TOOL_GCC_LINK_LIBRARY_DEPEND =
|
|---|
| 155 | TOOL_GCC_LINK_LIBRARY_DEPORD =
|
|---|
| 156 | define TOOL_GCC_LINK_LIBRARY_CMDS
|
|---|
| 157 | $(TOOL_GCC_AR) $(flags) $(out) $(objs)
|
|---|
| 158 | endef
|
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 | ## Link program
|
|---|
| 162 | # @param $(target) Normalized main target name.
|
|---|
| 163 | # @param $(out) Program name.
|
|---|
| 164 | # @param $(objs) Object files to link together.
|
|---|
| 165 | # @param $(libs) Libraries to search.
|
|---|
| 166 | # @param $(libpath) Library search paths.
|
|---|
| 167 | # @param $(flags) Flags.
|
|---|
| 168 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 169 | # @param $(deps) Other dependencies.
|
|---|
| 170 | # @param $(othersrc) Unhandled sources.
|
|---|
| 171 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 172 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 173 | #
|
|---|
| 174 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 175 | TOOL_GCC_LINK_PROGRAM_OUTPUT =
|
|---|
| 176 | TOOL_GCC_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 177 | TOOL_GCC_LINK_PROGRAM_DEPORD =
|
|---|
| 178 | define TOOL_GCC_LINK_PROGRAM_CMDS
|
|---|
| 179 | $(TOOL_GCC_LD) $(flags) -o $(out) $(objs) \
|
|---|
| 180 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 181 | endef
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 | ## Link DLL
|
|---|
| 185 | # @param $(target) Normalized main target name.
|
|---|
| 186 | # @param $(out) Program name.
|
|---|
| 187 | # @param $(objs) Object files to link together.
|
|---|
| 188 | # @param $(libs) Libraries to search.
|
|---|
| 189 | # @param $(libpath) Library search paths.
|
|---|
| 190 | # @param $(flags) Flags.
|
|---|
| 191 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 192 | # @param $(deps) Other dependencies.
|
|---|
| 193 | # @param $(othersrc) Unhandled sources.
|
|---|
| 194 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 195 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 196 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 197 | TOOL_GCC_LINK_DLL_OUTPUT =
|
|---|
| 198 | TOOL_GCC_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 199 | TOOL_GCC_LINK_DLL_DEPORD =
|
|---|
| 200 | define TOOL_GCC_LINK_DLL_CMDS
|
|---|
| 201 | $(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $(out) $(objs) \
|
|---|
| 202 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 203 | endef
|
|---|
| 204 |
|
|---|