| 1 | # $Id: GCC4MACH.kmk 474 2006-07-16 03:43:04Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild Tool Config - Darwin / Mac OS X / Mach GCC (v4).
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright (c) 2004-2006 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 | TOOL_GCC4MACH := Mach GCC v4
|
|---|
| 28 |
|
|---|
| 29 | TOOL_GCC4MACH_CC := gcc$(HOSTSUFF_EXE)
|
|---|
| 30 | TOOL_GCC4MACH_COBJSUFF := .o
|
|---|
| 31 | TOOL_GCC4MACH_CFLAGS := -g
|
|---|
| 32 | TOOL_GCC4MACH_CFLAGS.debug := -O0
|
|---|
| 33 | TOOL_GCC4MACH_CFLAGS.release := -O2
|
|---|
| 34 | TOOL_GCC4MACH_CFLAGS.profile := -O2 #-pg
|
|---|
| 35 | TOOL_GCC4MACH_CINCS :=
|
|---|
| 36 | TOOL_GCC4MACH_CDEFS :=
|
|---|
| 37 |
|
|---|
| 38 | TOOL_GCC4MACH_CXX := g++$(HOSTSUFF_EXE)
|
|---|
| 39 | TOOL_GCC4MACH_CXXOBJSUFF := .o
|
|---|
| 40 | TOOL_GCC4MACH_CXXOBJSUFF := .o
|
|---|
| 41 | TOOL_GCC4MACH_CXXFLAGS := -g
|
|---|
| 42 | TOOL_GCC4MACH_CXXFLAGS.debug := -O0
|
|---|
| 43 | TOOL_GCC4MACH_CXXFLAGS.release := -O2
|
|---|
| 44 | TOOL_GCC4MACH_CXXFLAGS.profile := -O2 #-pg
|
|---|
| 45 | TOOL_GCC4MACH_CXXINCS :=
|
|---|
| 46 | TOOL_GCC4MACH_CXXDEFS :=
|
|---|
| 47 |
|
|---|
| 48 | TOOL_GCC4MACH_AS := gcc$(HOSTSUFF_EXE)
|
|---|
| 49 | TOOL_GCC4MACH_ASFLAGS := -g -x assembler-with-cpp
|
|---|
| 50 | TOOL_GCC4MACH_ASOBJSUFF := .o
|
|---|
| 51 |
|
|---|
| 52 | TOOL_GCC4MACH_AR := ar$(HOSTSUFF_EXE)
|
|---|
| 53 | TOOL_GCC4MACH_ARFLAGS := -c -rs
|
|---|
| 54 | TOOL_GCC4MACH_ARLIBSUFF := .a
|
|---|
| 55 |
|
|---|
| 56 | TOOL_GCC4MACH_AR_IMP := $(ECHO) not supported!
|
|---|
| 57 |
|
|---|
| 58 | TOOL_GCC4MACH_LD := g++$(HOSTSUFF_EXE)
|
|---|
| 59 | TOOL_GCC4MACH_LD_SYSMOD := ld$(HOSTSUFF_EXE)
|
|---|
| 60 | TOOL_GCC4MACH_LDFLAGS :=
|
|---|
| 61 | TOOL_GCC4MACH_LDFLAGS.debug := -g
|
|---|
| 62 | TOOL_GCC4MACH_LDFLAGS.release := -s
|
|---|
| 63 | ifndef TOOL_GCC4MACH_LDFLAGS.$(BUILD_TARGET)
|
|---|
| 64 | TOOL_GCC4MACH_LDFLAGS.dll := -shared
|
|---|
| 65 | else
|
|---|
| 66 | TOOL_GCC4MACH_LDFLAGS.dll := $(TOOL_GCC4MACH_LDFLAGS.$(BUILD_TARGET))
|
|---|
| 67 | endif
|
|---|
| 68 | TOOL_GCC4MACH_LDFLAGS.sysmod := -r
|
|---|
| 69 | TOOL_GCC4MACH_LD_SONAME = -Wl,-soname=$(firstword $($(1)_SONAME.$(BUILD_TARGET).$(BUILD_TYPE)) $($(1)_SONAME.$(BUILD_TARGET)) $($(1)_SONAME.$(BUILD_TYPE)) $($(1)_SONAME) $(notdir $(2)))
|
|---|
| 70 | TOOL_GCC4MACH_LD_MAP =
|
|---|
| 71 | TOOL_GCC4MACH_LD_SYSMOD_MAP =
|
|---|
| 72 |
|
|---|
| 73 | ifdef SLKRUNS
|
|---|
| 74 | TOOL_GCC4MACH_CC += -fmessage-length=0
|
|---|
| 75 | TOOL_GCC4MACH_CXX += -fmessage-length=0
|
|---|
| 76 | endif
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 | ## Compile C source.
|
|---|
| 80 | # @param $(target) Normalized main target name.
|
|---|
| 81 | # @param $(source) Source filename (relative).
|
|---|
| 82 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 83 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 84 | # @param $(flags) Flags.
|
|---|
| 85 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 86 | # @param $(incs) Includes. No -I or something.
|
|---|
| 87 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 88 | # @param $(deps) Other dependencies.
|
|---|
| 89 | #
|
|---|
| 90 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 91 | # @param $(objsuff) Object suffix.
|
|---|
| 92 | TOOL_GCC4MACH_COMPILE_C_OUTPUT =
|
|---|
| 93 | TOOL_GCC4MACH_COMPILE_C_DEPEND =
|
|---|
| 94 | TOOL_GCC4MACH_COMPILE_C_DEPORD =
|
|---|
| 95 | define TOOL_GCC4MACH_COMPILE_C_CMDS
|
|---|
| 96 | $(TOOL_GCC4MACH_CC) -c\
|
|---|
| 97 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 98 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 99 | -o $(obj)\
|
|---|
| 100 | $(call ABSPATH,$(source))
|
|---|
| 101 | endef
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | ## Compile C++ source.
|
|---|
| 105 | # @param $(target) Normalized main target name.
|
|---|
| 106 | # @param $(source) Source filename (relative).
|
|---|
| 107 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 108 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 109 | # @param $(flags) Flags.
|
|---|
| 110 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 111 | # @param $(incs) Includes. No -I or something.
|
|---|
| 112 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 113 | # @param $(deps) Other dependencies.
|
|---|
| 114 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 115 | # @param $(objsuff) Object suffix.
|
|---|
| 116 | TOOL_GCC4MACH_COMPILE_CXX_OUTPUT =
|
|---|
| 117 | TOOL_GCC4MACH_COMPILE_CXX_DEPEND =
|
|---|
| 118 | TOOL_GCC4MACH_COMPILE_CXX_DEPORD =
|
|---|
| 119 | define TOOL_GCC4MACH_COMPILE_CXX_CMDS
|
|---|
| 120 | $(TOOL_GCC4MACH_CXX) -c\
|
|---|
| 121 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 122 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 123 | -o $(obj)\
|
|---|
| 124 | $(call ABSPATH,$(source))
|
|---|
| 125 | endef
|
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 | ## Compile Assembly source.
|
|---|
| 129 | # @param $(target) Normalized main target name.
|
|---|
| 130 | # @param $(source) Source filename (relative).
|
|---|
| 131 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 132 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 133 | # @param $(flags) Flags.
|
|---|
| 134 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 135 | # @param $(incs) Includes. No -I or something.
|
|---|
| 136 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 137 | # @param $(deps) Other dependencies.
|
|---|
| 138 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 139 | # @param $(objsuff) Object suffix.
|
|---|
| 140 | #
|
|---|
| 141 | TOOL_GCC4MACH_COMPILE_AS_OUTPUT =
|
|---|
| 142 | TOOL_GCC4MACH_COMPILE_AS_DEPEND =
|
|---|
| 143 | TOOL_GCC4MACH_COMPILE_AS_DEPORD =
|
|---|
| 144 | define TOOL_GCC4MACH_COMPILE_AS_CMDS
|
|---|
| 145 | $(TOOL_GCC4MACH_AS) -c\
|
|---|
| 146 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 147 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 148 | -o $(obj)\
|
|---|
| 149 | $(call ABSPATH,$(source))
|
|---|
| 150 | endef
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 | ## Link library
|
|---|
| 154 | # @param $(target) Normalized main target name.
|
|---|
| 155 | # @param $(out) Library name.
|
|---|
| 156 | # @param $(objs) Object files to put in the library.
|
|---|
| 157 | # @param $(flags) Flags.
|
|---|
| 158 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 159 | # @param $(deps) Other dependencies.
|
|---|
| 160 | # @param $(othersrc) Unhandled sources.
|
|---|
| 161 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 162 | TOOL_GCC4MACH_LINK_LIBRARY_OUTPUT =
|
|---|
| 163 | TOOL_GCC4MACH_LINK_LIBRARY_DEPEND = $(filter %.a %.lib %.def %.imp,$(othersrc))
|
|---|
| 164 | TOOL_GCC4MACH_LINK_LIBRARY_DEPORD =
|
|---|
| 165 | define TOOL_GCC4MACH_LINK_LIBRARY_CMDS
|
|---|
| 166 | $(TOOL_GCC4MACH_AR) $(flags) $(out) $(objs) $(filter %.a %.lib, $(othersrc))
|
|---|
| 167 | endef
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 | ## Link program
|
|---|
| 171 | # @param $(target) Normalized main target name.
|
|---|
| 172 | # @param $(out) Program name.
|
|---|
| 173 | # @param $(objs) Object files to link together.
|
|---|
| 174 | # @param $(libs) Libraries to search.
|
|---|
| 175 | # @param $(libpath) Library search paths.
|
|---|
| 176 | # @param $(flags) Flags.
|
|---|
| 177 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 178 | # @param $(deps) Other dependencies.
|
|---|
| 179 | # @param $(othersrc) Unhandled sources.
|
|---|
| 180 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 181 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 182 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 183 | TOOL_GCC4MACH_LINK_PROGRAM_OUTPUT = $(outbase).map
|
|---|
| 184 | TOOL_GCC4MACH_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 185 | TOOL_GCC4MACH_LINK_PROGRAM_DEPORD =
|
|---|
| 186 | define TOOL_GCC4MACH_LINK_PROGRAM_CMDS
|
|---|
| 187 | $(TOOL_GCC4MACH_LD) $(flags) -o $(out) $(objs)\
|
|---|
| 188 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 189 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 190 | $(call TOOL_GCC4MACH_LD_MAP,$(outbase).map)
|
|---|
| 191 | endef
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 | ## Link DLL
|
|---|
| 195 | # @param $(target) Normalized main target name.
|
|---|
| 196 | # @param $(out) Program name.
|
|---|
| 197 | # @param $(objs) Object files to link together.
|
|---|
| 198 | # @param $(libs) Libraries to search.
|
|---|
| 199 | # @param $(libpath) Library search paths.
|
|---|
| 200 | # @param $(flags) Flags.
|
|---|
| 201 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 202 | # @param $(deps) Other dependencies.
|
|---|
| 203 | # @param $(othersrc) Unhandled sources.
|
|---|
| 204 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 205 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 206 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 207 | TOOL_GCC4MACH_LINK_DLL_OUTPUT = $(outbase).map
|
|---|
| 208 | TOOL_GCC4MACH_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 209 | TOOL_GCC4MACH_LINK_DLL_DEPORD =
|
|---|
| 210 | define TOOL_GCC4MACH_LINK_DLL_CMDS
|
|---|
| 211 | $(TOOL_GCC4MACH_LD) $(TOOL_GCC4MACH_LDFLAGS.dll) $(flags) -o $(out)\
|
|---|
| 212 | $(if $(filter-out win32 os2, $(BUILD_TARGET)),$(call TOOL_GCC4MACH_LD_SONAME,$(target),$(out)))\
|
|---|
| 213 | $(objs)\
|
|---|
| 214 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 215 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 216 | $(call TOOL_GCC4MACH_LD_MAP,$(outbase).map)
|
|---|
| 217 | endef
|
|---|
| 218 |
|
|---|
| 219 |
|
|---|
| 220 | ## Link system module (windows aka driver, linux aka kernel module)
|
|---|
| 221 | # @param $(target) Normalized main target name.
|
|---|
| 222 | # @param $(out) System module name.
|
|---|
| 223 | # @param $(objs) Object files to link together.
|
|---|
| 224 | # @param $(libs) Libraries to search.
|
|---|
| 225 | # @param $(libpath) Library search paths.
|
|---|
| 226 | # @param $(flags) Flags.
|
|---|
| 227 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 228 | # @param $(deps) Other dependencies.
|
|---|
| 229 | # @param $(othersrc) Unhandled sources.
|
|---|
| 230 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 231 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 232 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 233 | TOOL_GCC4MACH_LINK_SYSMOD_OUTPUT = $(outbase).map
|
|---|
| 234 | TOOL_GCC4MACH_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 235 | TOOL_GCC4MACH_LINK_SYSMOD_DEPORD =
|
|---|
| 236 | define TOOL_GCC4MACH_LINK_SYSMOD_CMDS
|
|---|
| 237 | $(TOOL_GCC4MACH_LD_SYSMOD) $(TOOL_GCC4MACH_LDFLAGS.sysmod) $(flags) -o $(out) $(objs)\
|
|---|
| 238 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 239 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))\
|
|---|
| 240 | $(call TOOL_GCC4MACH_LD_SYSMOD_MAP,$(outbase).map)
|
|---|
| 241 | endef
|
|---|
| 242 |
|
|---|