| 1 | # $Id: MINGW32.kmk 1786 2008-09-14 22:19:14Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | # kBuild Tool Config - MinGW32 GCC v3.3+.
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2004-2008 knut st. osmundsen <bird-kBuild-spam@anduin.net>
|
|---|
| 8 | #
|
|---|
| 9 | #
|
|---|
| 10 | # This file is part of kBuild.
|
|---|
| 11 | #
|
|---|
| 12 | # kBuild is free software; you can redistribute it and/or modify
|
|---|
| 13 | # it under the terms of the GNU General Public License as published by
|
|---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
|---|
| 15 | # (at your option) any later version.
|
|---|
| 16 | #
|
|---|
| 17 | # kBuild is distributed in the hope that it will be useful,
|
|---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 20 | # GNU General Public License for more details.
|
|---|
| 21 | #
|
|---|
| 22 | # You should have received a copy of the GNU General Public License
|
|---|
| 23 | # along with kBuild; if not, write to the Free Software
|
|---|
| 24 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 25 | #
|
|---|
| 26 | #
|
|---|
| 27 | # As a special exception you are granted permission to include this file, via
|
|---|
| 28 | # the kmk include directive, as you wish without this in itself causing the
|
|---|
| 29 | # resulting makefile, program or whatever to be covered by the GPL license.
|
|---|
| 30 | # This exception does not however invalidate any other reasons why the makefile,
|
|---|
| 31 | # program, whatever should not be covered the GPL.
|
|---|
| 32 | #
|
|---|
| 33 | #
|
|---|
| 34 |
|
|---|
| 35 | ifdef TOOL_MINGW32
|
|---|
| 36 | $(error Already included (TOOL_MINGW32=$(TOOL_MINGW32)))
|
|---|
| 37 | endif
|
|---|
| 38 | TOOL_MINGW32 := MinGW32 GCC v3.3+.
|
|---|
| 39 |
|
|---|
| 40 | # Tool Specific Properties
|
|---|
| 41 | ifndef PATH_TOOL_MINGW32
|
|---|
| 42 | PATH_TOOL_MINGW32 := $(wildcard $(PATH_DEVTOOLS_BLD)/mingw32/v*.*)
|
|---|
| 43 | ifeq ($(PATH_TOOL_MINGW32),)
|
|---|
| 44 | PATH_TOOL_MINGW32 := $(wildcard $(PATH_DEVTOOLS)/win.x86/mingw32/v*.*)
|
|---|
| 45 | endif
|
|---|
| 46 | ifeq ($(PATH_TOOL_MINGW32),)
|
|---|
| 47 | PATH_TOOL_MINGW32 := $(wildcard $(PATH_DEVTOOLS)/x86.win32/mingw32/v*.*)
|
|---|
| 48 | endif
|
|---|
| 49 | ifneq ($(PATH_TOOL_MINGW32),)
|
|---|
| 50 | PATH_TOOL_MINGW32 := $(lastword $(sort $(PATH_TOOL_MINGW32)))
|
|---|
| 51 | endif
|
|---|
| 52 | else
|
|---|
| 53 | # Resolve any fancy stuff once and for all.
|
|---|
| 54 | PATH_TOOL_MINGW32 := $(PATH_TOOL_MINGW32)
|
|---|
| 55 | endif
|
|---|
| 56 |
|
|---|
| 57 | # figure out if it's native or needs a win32 launcher
|
|---|
| 58 | TOOL_MINGW32_HOSTSUFF_EXE ?= $(HOSTSUFF_EXE)
|
|---|
| 59 | ifndef TOOL_MINGW32_PREFIX
|
|---|
| 60 | ifneq ($(PATH_TOOL_MINGW32),)
|
|---|
| 61 | TOOL_MINGW32_PREFIX := $(PATH_TOOL_MINGW32)/bin/
|
|---|
| 62 | else
|
|---|
| 63 | TOOL_MINGW32_PREFIX :=
|
|---|
| 64 | endif
|
|---|
| 65 | ifneq ($(KBUILD_HOST),win)
|
|---|
| 66 | # we're cross compiling either using an emulator (wine/odin) or a cross compiler.
|
|---|
| 67 | ifneq ($(PATH_TOOL_MINGW32),$(subst /win.x86,,$(subst /x86.win,,$(PATH_TOOL_MINGW32))))
|
|---|
| 68 | TOOL_MINGW32_PREFIX := $(EXEC_X86_WIN32) $(TOOL_MINGW32_PREFIX)
|
|---|
| 69 | TOOL_MINGW32_HOSTSUFF_EXE := .exe
|
|---|
| 70 | else
|
|---|
| 71 | TOOL_MINGW32_PREFIX := $(TOOL_MINGW32_PREFIX)i386-mingw32msvc-
|
|---|
| 72 | TOOL_MINGW32_HOSTSUFF_EXE :=
|
|---|
| 73 | TOOL_MINGW32_XCOMPILE := 1
|
|---|
| 74 | endif
|
|---|
| 75 | endif
|
|---|
| 76 | else
|
|---|
| 77 | # Resolve any fancy stuff once and for all.
|
|---|
| 78 | TOOL_MINGW32_PREFIX := $(TOOL_MINGW32_PREFIX)
|
|---|
| 79 | endif
|
|---|
| 80 |
|
|---|
| 81 | TOOL_MINGW32_CC ?= $(TOOL_MINGW32_PREFIX)gcc$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 82 | TOOL_MINGW32_CXX ?= $(TOOL_MINGW32_PREFIX)g++$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 83 | TOOL_MINGW32_AS ?= $(TOOL_MINGW32_PREFIX)gcc$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 84 | TOOL_MINGW32_AR ?= $(TOOL_MINGW32_PREFIX)ar$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 85 | ifndef TOOL_MINGW32_XCOMPILE# The gentoo package doesn't have g++.
|
|---|
| 86 | TOOL_MINGW32_LD ?= $(TOOL_MINGW32_PREFIX)g++$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 87 | else
|
|---|
| 88 | TOOL_MINGW32_LD ?= $(TOOL_MINGW32_PREFIX)gcc$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 89 | endif
|
|---|
| 90 | TOOL_MINGW32_DLLWRAP ?= $(TOOL_MINGW32_PREFIX)dllwrap$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 91 | TOOL_MINGW32_DLLTOOL ?= $(TOOL_MINGW32_PREFIX)dlltool$(TOOL_MINGW32_HOSTSUFF_EXE)
|
|---|
| 92 |
|
|---|
| 93 | # General Properties used by kBuild
|
|---|
| 94 | TOOL_MINGW32_COBJSUFF ?= .o
|
|---|
| 95 | TOOL_MINGW32_CFLAGS ?= -g
|
|---|
| 96 | TOOL_MINGW32_CFLAGS.debug ?= -O0
|
|---|
| 97 | TOOL_MINGW32_CFLAGS.release ?= -O2
|
|---|
| 98 | TOOL_MINGW32_CFLAGS.profile ?= -O2 #-pg
|
|---|
| 99 | TOOL_MINGW32_CINCS ?=
|
|---|
| 100 | TOOL_MINGW32_CDEFS ?=
|
|---|
| 101 |
|
|---|
| 102 | TOOL_MINGW32_CXXOBJSUFF ?= .o
|
|---|
| 103 | TOOL_MINGW32_CXXOBJSUFF ?= .o
|
|---|
| 104 | TOOL_MINGW32_CXXFLAGS ?= -g
|
|---|
| 105 | TOOL_MINGW32_CXXFLAGS.debug ?= -O0
|
|---|
| 106 | TOOL_MINGW32_CXXFLAGS.release ?= -O2
|
|---|
| 107 | TOOL_MINGW32_CXXFLAGS.profile ?= -O2 #-pg
|
|---|
| 108 | TOOL_MINGW32_CXXINCS ?=
|
|---|
| 109 | TOOL_MINGW32_CXXDEFS ?=
|
|---|
| 110 |
|
|---|
| 111 | TOOL_MINGW32_ASFLAGS ?= -g -x assembler-with-cpp
|
|---|
| 112 | TOOL_MINGW32_ASOBJSUFF ?= .o
|
|---|
| 113 |
|
|---|
| 114 | TOOL_MINGW32_ARFLAGS ?= cr
|
|---|
| 115 | TOOL_MINGW32_ARLIBSUFF ?= .a
|
|---|
| 116 |
|
|---|
| 117 | TOOL_MINGW32_LDFLAGS ?=
|
|---|
| 118 | TOOL_MINGW32_LDFLAGS.debug ?= -g
|
|---|
| 119 | TOOL_MINGW32_LDFLAGS.release ?= -s
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 | ## Compile C source.
|
|---|
| 123 | # @param $(target) Normalized main target name.
|
|---|
| 124 | # @param $(source) Source filename (relative).
|
|---|
| 125 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 126 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 127 | # @param $(flags) Flags.
|
|---|
| 128 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 129 | # @param $(incs) Includes. No -I or something.
|
|---|
| 130 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 131 | # @param $(deps) Other dependencies.
|
|---|
| 132 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 133 | # @param $(objsuff) Object suffix.
|
|---|
| 134 | TOOL_MINGW32_COMPILE_C_OUTPUT =
|
|---|
| 135 | TOOL_MINGW32_COMPILE_C_DEPEND =
|
|---|
| 136 | TOOL_MINGW32_COMPILE_C_DEPORD =
|
|---|
| 137 | define TOOL_MINGW32_COMPILE_C_CMDS
|
|---|
| 138 | $(QUIET)$(TOOL_MINGW32_CC) -c\
|
|---|
| 139 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 140 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 141 | -o $(obj)\
|
|---|
| 142 | $(abspath $(source))
|
|---|
| 143 | endef
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 | ## Compile C++ source.
|
|---|
| 147 | # @param $(target) Normalized main target name.
|
|---|
| 148 | # @param $(source) Source filename (relative).
|
|---|
| 149 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 150 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 151 | # @param $(flags) Flags.
|
|---|
| 152 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 153 | # @param $(incs) Includes. No -I or something.
|
|---|
| 154 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 155 | # @param $(deps) Other dependencies.
|
|---|
| 156 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 157 | # @param $(objsuff) Object suffix.
|
|---|
| 158 | TOOL_MINGW32_COMPILE_CXX_OUTPUT =
|
|---|
| 159 | TOOL_MINGW32_COMPILE_CXX_DEPEND =
|
|---|
| 160 | TOOL_MINGW32_COMPILE_CXX_DEPORD =
|
|---|
| 161 | define TOOL_MINGW32_COMPILE_CXX_CMDS
|
|---|
| 162 | $(QUIET)$(TOOL_MINGW32_CXX) -c\
|
|---|
| 163 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 164 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 165 | -o $(obj)\
|
|---|
| 166 | $(abspath $(source))
|
|---|
| 167 | endef
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 | ## Compile Assembly source.
|
|---|
| 171 | # @param $(target) Normalized main target name.
|
|---|
| 172 | # @param $(source) Source filename (relative).
|
|---|
| 173 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 174 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 175 | # @param $(flags) Flags.
|
|---|
| 176 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 177 | # @param $(incs) Includes. No -I or something.
|
|---|
| 178 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 179 | # @param $(deps) Other dependencies.
|
|---|
| 180 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 181 | # @param $(objsuff) Object suffix.
|
|---|
| 182 | #
|
|---|
| 183 | TOOL_MINGW32_COMPILE_AS_OUTPUT =
|
|---|
| 184 | TOOL_MINGW32_COMPILE_AS_DEPEND =
|
|---|
| 185 | TOOL_MINGW32_COMPILE_AS_DEPORD =
|
|---|
| 186 | define TOOL_MINGW32_COMPILE_AS_CMDS
|
|---|
| 187 | $(QUIET)$(TOOL_MINGW32_AS) -c\
|
|---|
| 188 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 189 | -Wp,-MD,$(dep) -Wp,-MT,$(obj) -Wp,-MP\
|
|---|
| 190 | -o $(obj)\
|
|---|
| 191 | $(abspath $(source))
|
|---|
| 192 | endef
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | ## Link library
|
|---|
| 196 | # @param $(target) Normalized main target name.
|
|---|
| 197 | # @param $(out) Library name.
|
|---|
| 198 | # @param $(objs) Object files to put in the library.
|
|---|
| 199 | # @param $(flags) Flags.
|
|---|
| 200 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 201 | # @param $(deps) Other dependencies.
|
|---|
| 202 | #
|
|---|
| 203 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 204 | TOOL_MINGW32_LINK_LIBRARY_OUTPUT = $(out).ar-script
|
|---|
| 205 | TOOL_MINGW32_LINK_LIBRARY_DEPEND = $(othersrc)
|
|---|
| 206 | TOOL_MINGW32_LINK_LIBRARY_DEPORD =
|
|---|
| 207 | define TOOL_MINGW32_LINK_LIBRARY_CMDS
|
|---|
| 208 | $(QUIET)$(APPEND) $(out).ar-script 'CREATE $(out)'
|
|---|
| 209 | $(QUIET)$(APPEND) -n $(out).ar-script \
|
|---|
| 210 | $(foreach o,$(objs), 'ADDMOD $(o)') \
|
|---|
| 211 | $(foreach o,$(othersrc), 'ADDLIB $(o)')
|
|---|
| 212 | $(QUIET)$(APPEND) $(out).ar-script 'SAVE'
|
|---|
| 213 | $(QUIET)$(APPEND) $(out).ar-script 'END'
|
|---|
| 214 | $(QUIET)$(TOOL_MINGW32_AR) -M < $(out).ar-script
|
|---|
| 215 | endef
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 | ## Link program
|
|---|
| 220 | # @param $(target) Normalized main target name.
|
|---|
| 221 | # @param $(out) Program name.
|
|---|
| 222 | # @param $(objs) Object files to link together.
|
|---|
| 223 | # @param $(libs) Libraries to search.
|
|---|
| 224 | # @param $(libpath) Library search paths.
|
|---|
| 225 | # @param $(flags) Flags.
|
|---|
| 226 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 227 | # @param $(deps) Other dependencies.
|
|---|
| 228 | # @param $(othersrc) Unhandled sources.
|
|---|
| 229 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 230 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 231 | #
|
|---|
| 232 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 233 | TOOL_MINGW32_LINK_PROGRAM_OUTPUT =
|
|---|
| 234 | TOOL_MINGW32_LINK_PROGRAM_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
|
|---|
| 235 | TOOL_MINGW32_LINK_PROGRAM_DEPORD =
|
|---|
| 236 | define TOOL_MINGW32_LINK_PROGRAM_CMDS
|
|---|
| 237 | $(QUIET)$(TOOL_MINGW32_LD) $(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 | endef
|
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 | ## Link DLL.
|
|---|
| 244 | # @param $(target) Normalized main target name.
|
|---|
| 245 | # @param $(out) DLL name.
|
|---|
| 246 | # @param $(objs) Object files to link together.
|
|---|
| 247 | # @param $(libs) Libraries to search.
|
|---|
| 248 | # @param $(libpath) Library search paths.
|
|---|
| 249 | # @param $(flags) Flags.
|
|---|
| 250 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 251 | # @param $(deps) Other dependencies.
|
|---|
| 252 | # @param $(othersrc) Unhandled sources.
|
|---|
| 253 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 254 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 255 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 256 | TOOL_MINGW32_LINK_DLL_OUTPUT =
|
|---|
| 257 | TOOL_MINGW32_LINK_DLL_OUTPUT_MAYBE = $(outbase).a $(outbase).exp $(PATH_LIB)/$(notdir $(outbase)).exp $(PATH_LIB)/$(notdir $(outbase)).a
|
|---|
| 258 | ## @todo Find a better solution for installing the extra files (.a, .exp, .pdb, etc).
|
|---|
| 259 | TOOL_MINGW32_LINK_DLL_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))\
|
|---|
| 260 | $(filter %.def %.res,$(othersrc))
|
|---|
| 261 | TOOL_MINGW32_LINK_DLL_DEPORD = $(call DIRDEP,$(PATH_LIB))
|
|---|
| 262 | define TOOL_MINGW32_LINK_DLL_CMDS
|
|---|
| 263 | $(QUIET)$(TOOL_MINGW32_DLLWRAP) $(flags)\
|
|---|
| 264 | --dllname=$(out)\
|
|---|
| 265 | --output-exp=$(outbase).exp\
|
|---|
| 266 | --output-lib=$(outbase).a\
|
|---|
| 267 | $(foreach def,$(filter %.def,$(othersrc)), --def $(def))\
|
|---|
| 268 | $(filter %.res,$(othersrc))\
|
|---|
| 269 | $(objs)\
|
|---|
| 270 | $(foreach p,$(libpath), -L$(p))\
|
|---|
| 271 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 272 | $(QUIET)$(CP) $(outbase).exp $(outbase).a $(PATH_LIB)/
|
|---|
| 273 | endef
|
|---|
| 274 | ## @todo separate install stuff!
|
|---|