| 1 | # $Id: GCC.kmk 130 2004-06-29 17:30:14Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | #
|
|---|
| 4 | # kBuild Tool Config - Generic GCC.
|
|---|
| 5 | #
|
|---|
| 6 | # Copyright (c) 2004 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 := -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 := -pg
|
|---|
| 46 | TOOL_GCC_CXXINCS :=
|
|---|
| 47 | TOOL_GCC_CXXDEFS :=
|
|---|
| 48 |
|
|---|
| 49 | TOOL_GCC_AS := as$(HOSTSUFF_EXE)
|
|---|
| 50 | TOOL_GCC_ASOBJSUFF := .o
|
|---|
| 51 |
|
|---|
| 52 | TOOL_GCC_AR := ar$(HOSTSUFF_EXE)
|
|---|
| 53 | TOOL_GCC_ARFLAGS := cr
|
|---|
| 54 | TOOL_GCC_ARLIBSUFF := .a
|
|---|
| 55 |
|
|---|
| 56 | TOOL_GCC_LD := g++$(HOSTSUFF_EXE)
|
|---|
| 57 | TOOL_GCC_LDFLAGS :=
|
|---|
| 58 | TOOL_GCC_LDFLAGS.debug := -g
|
|---|
| 59 | TOOL_GCC_LDFLAGS.release := -s
|
|---|
| 60 | TOOL_GCC_LDFLAGS.dll.os2 := -Zdll
|
|---|
| 61 | ifndef TOOL_GCC_LDFLAGS.$(BUILD_TARGET)
|
|---|
| 62 | TOOL_GCC_LDFLAGS.dll := -shared
|
|---|
| 63 | else
|
|---|
| 64 | TOOL_GCC_LDFLAGS.dll := $(TOOL_GCC_LDFLAGS.$(BUILD_TARGET))
|
|---|
| 65 | endif
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | ## Compile C source.
|
|---|
| 69 | # @param $(target) Normalized main target name.
|
|---|
| 70 | # @param $(source) Source filename (relative).
|
|---|
| 71 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 72 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 73 | # @param $(flags) Flags.
|
|---|
| 74 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 75 | # @param $(incs) Includes. No -I or something.
|
|---|
| 76 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 77 | #
|
|---|
| 78 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 79 | # @param $(objsuff) Object suffix.
|
|---|
| 80 | define TOOL_GCC_COMPILE_C
|
|---|
| 81 | #$ (warning dbg: TOOL_GCC_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
|---|
| 82 | $(obj): $(dirdep) $(PATH_CURRENT)/$(source)
|
|---|
| 83 | $(call MSG_L2,Compiling $$@ using GCC)
|
|---|
| 84 | $(TOOL_GCC_CC) -c\
|
|---|
| 85 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 86 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
|---|
| 87 | -o $$@\
|
|---|
| 88 | $(call ABSPATH,$(source))
|
|---|
| 89 |
|
|---|
| 90 | endef
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | ## Compile C++ source.
|
|---|
| 94 | # @param $(target) Normalized main target name.
|
|---|
| 95 | # @param $(source) Source filename (relative).
|
|---|
| 96 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 97 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 98 | # @param $(flags) Flags.
|
|---|
| 99 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 100 | # @param $(incs) Includes. No -I or something.
|
|---|
| 101 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 102 | #
|
|---|
| 103 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 104 | # @param $(objsuff) Object suffix.
|
|---|
| 105 | define TOOL_GCC_COMPILE_CXX
|
|---|
| 106 | #$ (warning dbg: TOOL_GCC_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
|---|
| 107 | $(obj): $(dirdep) $(source)
|
|---|
| 108 | $(call MSG_L2,Compiling $$@ using GCC)
|
|---|
| 109 | $(TOOL_GCC_CXX) -c\
|
|---|
| 110 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 111 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
|---|
| 112 | -o $$@\
|
|---|
| 113 | $(call ABSPATH,$(source))
|
|---|
| 114 |
|
|---|
| 115 | endef
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | ## Link library
|
|---|
| 119 | # @param $(target) Normalized main target name.
|
|---|
| 120 | # @param $(lib) Library name.
|
|---|
| 121 | # @param $(objs) Object files to put in the library.
|
|---|
| 122 | # @param $(flags) Flags.
|
|---|
| 123 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 124 | # @param $(deps) Other dependencies.
|
|---|
| 125 | #
|
|---|
| 126 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 127 | define TOOL_GCC_LINK_LIBRARY
|
|---|
| 128 | #$ (warning dbg: TOOL_GCC_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
|
|---|
| 129 | $(lib): $(dirdep) $(objs) $(deps)
|
|---|
| 130 | $(call MSG_L1,Creating Library $$@)
|
|---|
| 131 | $(RM) -f $$@
|
|---|
| 132 | $(TOOL_GCC_AR) $(flags) $$@ $(objs)
|
|---|
| 133 |
|
|---|
| 134 | endef
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | ## Link program
|
|---|
| 138 | # @param $(target) Normalized main target name.
|
|---|
| 139 | # @param $(exe) Program name.
|
|---|
| 140 | # @param $(objs) Object files to link together.
|
|---|
| 141 | # @param $(libs) Libraries to search.
|
|---|
| 142 | # @param $(libpath) Library search paths.
|
|---|
| 143 | # @param $(flags) Flags.
|
|---|
| 144 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 145 | # @param $(deps) Other dependencies.
|
|---|
| 146 | # @param $(othersrc) Unhandled sources.
|
|---|
| 147 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 148 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 149 | #
|
|---|
| 150 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 151 | define TOOL_GCC_LINK_PROGRAM
|
|---|
| 152 | #$ (warning dbg: TOOL_GCC_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
|---|
| 153 | $(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
|
|---|
| 154 | $(call MSG_L1,Creating Program $$@)
|
|---|
| 155 | ifneq ($(custom_pre),)
|
|---|
| 156 | $(eval $(custom_pre))
|
|---|
| 157 | endif
|
|---|
| 158 | $(TOOL_GCC_LD) $(flags) -o $$@ $(objs) \
|
|---|
| 159 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 160 | ifneq ($(custom_post),)
|
|---|
| 161 | $(eval $(custom_post))
|
|---|
| 162 | endif
|
|---|
| 163 |
|
|---|
| 164 | endef
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 | ## Link program
|
|---|
| 168 | # @param $(target) Normalized main target name.
|
|---|
| 169 | # @param $(exe) Program name.
|
|---|
| 170 | # @param $(objs) Object files to link together.
|
|---|
| 171 | # @param $(libs) Libraries to search.
|
|---|
| 172 | # @param $(libpath) Library search paths.
|
|---|
| 173 | # @param $(flags) Flags.
|
|---|
| 174 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 175 | # @param $(deps) Other dependencies.
|
|---|
| 176 | # @param $(othersrc) Unhandled sources.
|
|---|
| 177 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 178 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 179 | #
|
|---|
| 180 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 181 | define TOOL_GCC_LINK_DLL
|
|---|
| 182 | #$ (warning dbg: TOOL_GCC_LINK_DLL: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
|---|
| 183 | $(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
|
|---|
| 184 | $(call MSG_L1,Creating Program $$@)
|
|---|
| 185 | ifneq ($(custom_pre),)
|
|---|
| 186 | $(eval $(custom_pre))
|
|---|
| 187 | endif
|
|---|
| 188 | $(TOOL_GCC_LD) $(TOOL_GCC_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
|
|---|
| 189 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 190 | ifneq ($(custom_post),)
|
|---|
| 191 | $(eval $(custom_post))
|
|---|
| 192 | endif
|
|---|
| 193 |
|
|---|
| 194 | endef
|
|---|
| 195 |
|
|---|