| 1 | # $Id: GCC.kmk 77 2004-05-31 08:53:24Z 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 |
|
|---|
| 61 |
|
|---|
| 62 | ## Compile C source.
|
|---|
| 63 | # @param $(target) Normalized main target name.
|
|---|
| 64 | # @param $(source) Source filename (relative).
|
|---|
| 65 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 66 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 67 | # @param $(flags) Flags.
|
|---|
| 68 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 69 | # @param $(incs) Includes. No -I or something.
|
|---|
| 70 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 71 | #
|
|---|
| 72 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 73 | # @param $(objsuff) Object suffix.
|
|---|
| 74 | define TOOL_GCC_COMPILE_C
|
|---|
| 75 | #$ (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))
|
|---|
| 76 | $(obj): $(dirdep) $(PATH_CURRENT)/$(source)
|
|---|
| 77 | $(call MSG_L2,Compiling $$@ using GCC)
|
|---|
| 78 | $(TOOL_GCC_CC) -c\
|
|---|
| 79 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 80 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
|---|
| 81 | -o $$@\
|
|---|
| 82 | $(PATH_CURRENT)/$(source)
|
|---|
| 83 |
|
|---|
| 84 | endef
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | ## Compile C++ source.
|
|---|
| 88 | # @param $(target) Normalized main target name.
|
|---|
| 89 | # @param $(source) Source filename (relative).
|
|---|
| 90 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 91 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 92 | # @param $(flags) Flags.
|
|---|
| 93 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 94 | # @param $(incs) Includes. No -I or something.
|
|---|
| 95 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 96 | #
|
|---|
| 97 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 98 | # @param $(objsuff) Object suffix.
|
|---|
| 99 | define TOOL_GCC_COMPILE_CXX
|
|---|
| 100 | #$ (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))
|
|---|
| 101 | $(obj): $(dirdep) $(PATH_CURRENT)/$(source)
|
|---|
| 102 | $(call MSG_L2,Compiling $$@ using GCC)
|
|---|
| 103 | $(TOOL_GCC_CXX) -c\
|
|---|
| 104 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 105 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
|---|
| 106 | -o $$@\
|
|---|
| 107 | $(PATH_CURRENT)/$(source)
|
|---|
| 108 |
|
|---|
| 109 | endef
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | ## Link library
|
|---|
| 113 | # @param $(target) Normalized main target name.
|
|---|
| 114 | # @param $(lib) Library name.
|
|---|
| 115 | # @param $(objs) Object files to put in the library.
|
|---|
| 116 | # @param $(flags) Flags.
|
|---|
| 117 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 118 | # @param $(deps) Other dependencies.
|
|---|
| 119 | #
|
|---|
| 120 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 121 | define TOOL_GCC_LINK_LIBRARY
|
|---|
| 122 | #$ (warning dbg: TOOL_GCC_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
|
|---|
| 123 | $(lib): $(dirdep) $(objs) $(deps)
|
|---|
| 124 | $(call MSG_L1,Creating Library $$@)
|
|---|
| 125 | $(RM) -f $$@
|
|---|
| 126 | $(TOOL_GCC_AR) $(flags) $$@ $(objs)
|
|---|
| 127 |
|
|---|
| 128 | endef
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 | ## Link program
|
|---|
| 132 | # @param $(target) Normalized main target name.
|
|---|
| 133 | # @param $(exe) Program name.
|
|---|
| 134 | # @param $(objs) Object files to link together.
|
|---|
| 135 | # @param $(libs) Libraries to search.
|
|---|
| 136 | # @param $(libpath) Library search paths.
|
|---|
| 137 | # @param $(flags) Flags.
|
|---|
| 138 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 139 | # @param $(deps) Other dependencies.
|
|---|
| 140 | # @param $(deffile) Definition file. (optional, PC only)
|
|---|
| 141 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 142 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 143 | #
|
|---|
| 144 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 145 | define TOOL_GCC_LINK_PROGRAM
|
|---|
| 146 | #$ (warning dbg: TOOL_GCC_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
|---|
| 147 | $(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
|
|---|
| 148 | $(call MSG_L1,Creating Program $$@)
|
|---|
| 149 | ifneq ($(custom_pre),)
|
|---|
| 150 | $(eval $(custom_pre))
|
|---|
| 151 | endif
|
|---|
| 152 | $(TOOL_GCC_LD) $(flags) -o $$@ $(objs) \
|
|---|
| 153 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 154 | ifneq ($(custom_post),)
|
|---|
| 155 | $(eval $(custom_post))
|
|---|
| 156 | endif
|
|---|
| 157 |
|
|---|
| 158 | endef
|
|---|
| 159 |
|
|---|