| 1 | # $Id: GCC3.kmk 94 2004-06-08 14:48:28Z 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 | TOOL_GCC3 := Generic GCC v3
|
|---|
| 28 |
|
|---|
| 29 | TOOL_GCC3_CC := gcc$(HOSTSUFF_EXE)
|
|---|
| 30 | TOOL_GCC3_COBJSUFF := .o
|
|---|
| 31 | TOOL_GCC3_CFLAGS := -g
|
|---|
| 32 | TOOL_GCC3_CFLAGS.debug := -O0
|
|---|
| 33 | TOOL_GCC3_CFLAGS.release := -O2
|
|---|
| 34 | TOOL_GCC3_CFLAGS.profile := -pg
|
|---|
| 35 | TOOL_GCC3_CINCS :=
|
|---|
| 36 | TOOL_GCC3_CDEFS :=
|
|---|
| 37 |
|
|---|
| 38 | TOOL_GCC3_CXX := g++$(HOSTSUFF_EXE)
|
|---|
| 39 | TOOL_GCC3_CXXOBJSUFF := .o
|
|---|
| 40 | TOOL_GCC3_CXXOBJSUFF := .o
|
|---|
| 41 | TOOL_GCC3_CXXFLAGS := -g
|
|---|
| 42 | TOOL_GCC3_CXXFLAGS.debug := -O0
|
|---|
| 43 | TOOL_GCC3_CXXFLAGS.release := -O2
|
|---|
| 44 | TOOL_GCC3_CXXFLAGS.profile := -pg
|
|---|
| 45 | TOOL_GCC3_CXXINCS :=
|
|---|
| 46 | TOOL_GCC3_CXXDEFS :=
|
|---|
| 47 |
|
|---|
| 48 | TOOL_GCC3_AS := as$(HOSTSUFF_EXE)
|
|---|
| 49 | TOOL_GCC3_ASOBJSUFF := .o
|
|---|
| 50 |
|
|---|
| 51 | TOOL_GCC3_AR := ar$(HOSTSUFF_EXE)
|
|---|
| 52 | TOOL_GCC3_ARFLAGS := cr
|
|---|
| 53 | TOOL_GCC3_ARLIBSUFF := .a
|
|---|
| 54 |
|
|---|
| 55 | TOOL_GCC3_LD := g++$(HOSTSUFF_EXE)
|
|---|
| 56 | TOOL_GCC3_LDFLAGS :=
|
|---|
| 57 | TOOL_GCC3_LDFLAGS.debug := -g
|
|---|
| 58 | TOOL_GCC3_LDFLAGS.release := -s
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | ## Compile C source.
|
|---|
| 62 | # @param $(target) Normalized main target name.
|
|---|
| 63 | # @param $(source) Source filename (relative).
|
|---|
| 64 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 65 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 66 | # @param $(flags) Flags.
|
|---|
| 67 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 68 | # @param $(incs) Includes. No -I or something.
|
|---|
| 69 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 70 | #
|
|---|
| 71 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 72 | # @param $(objsuff) Object suffix.
|
|---|
| 73 | define TOOL_GCC3_COMPILE_C
|
|---|
| 74 | #$ (warning dbg: TOOL_GCC3_COMPILE_C: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
|---|
| 75 | $(obj): $(dirdep) $(PATH_CURRENT)/$(source)
|
|---|
| 76 | $(call MSG_L2,Compiling $$@ using GCC3)
|
|---|
| 77 | $(TOOL_GCC3_CC) -c\
|
|---|
| 78 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 79 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
|---|
| 80 | -o $$@\
|
|---|
| 81 | $(PATH_CURRENT)/$(source)
|
|---|
| 82 |
|
|---|
| 83 | endef
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 | ## Compile C++ source.
|
|---|
| 87 | # @param $(target) Normalized main target name.
|
|---|
| 88 | # @param $(source) Source filename (relative).
|
|---|
| 89 | # @param $(obj) Object file name. This shall be (re)created by the compilation.
|
|---|
| 90 | # @param $(dep) Dependcy file. This shall be (re)created by the compilation.
|
|---|
| 91 | # @param $(flags) Flags.
|
|---|
| 92 | # @param $(defs) Definitions. No -D or something.
|
|---|
| 93 | # @param $(incs) Includes. No -I or something.
|
|---|
| 94 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 95 | #
|
|---|
| 96 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 97 | # @param $(objsuff) Object suffix.
|
|---|
| 98 | define TOOL_GCC3_COMPILE_CXX
|
|---|
| 99 | #$ (warning dbg: TOOL_GCC3_COMPILE_CXX: target=$(target) source=$(source) obj=$(obj) dep=$(dep) flags=$(flags) defs=$(defs) incs=$(incs) dirdep=$(dirdep) outbase=$(outbase) objsuff=$(objsuff))
|
|---|
| 100 | $(obj): $(dirdep) $(PATH_CURRENT)/$(source)
|
|---|
| 101 | $(call MSG_L2,Compiling $$@ using GCC3)
|
|---|
| 102 | $(TOOL_GCC3_CXX) -c\
|
|---|
| 103 | $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
|
|---|
| 104 | -Wp,-MD,$(dep) -Wp,-MT,$$@ \
|
|---|
| 105 | -o $$@\
|
|---|
| 106 | $(PATH_CURRENT)/$(source)
|
|---|
| 107 |
|
|---|
| 108 | endef
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 | ## Link library
|
|---|
| 112 | # @param $(target) Normalized main target name.
|
|---|
| 113 | # @param $(lib) Library name.
|
|---|
| 114 | # @param $(objs) Object files to put in the library.
|
|---|
| 115 | # @param $(flags) Flags.
|
|---|
| 116 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 117 | # @param $(deps) Other dependencies.
|
|---|
| 118 | #
|
|---|
| 119 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 120 | define TOOL_GCC3_LINK_LIBRARY
|
|---|
| 121 | #$ (warning dbg: TOOL_GCC3_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
|
|---|
| 122 | $(lib): $(dirdep) $(objs) $(deps)
|
|---|
| 123 | $(call MSG_L1,Creating Library $$@)
|
|---|
| 124 | $(RM) -f $$@
|
|---|
| 125 | $(TOOL_GCC3_AR) $(flags) $$@ $(objs)
|
|---|
| 126 | $(MKDIR) -p $(PATH_LIB)
|
|---|
| 127 | $(CP) $$@ $(PATH_LIB)/
|
|---|
| 128 |
|
|---|
| 129 | endef
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 | ## Link program
|
|---|
| 133 | # @param $(target) Normalized main target name.
|
|---|
| 134 | # @param $(exe) Program name.
|
|---|
| 135 | # @param $(objs) Object files to link together.
|
|---|
| 136 | # @param $(libs) Libraries to search.
|
|---|
| 137 | # @param $(libpath) Library search paths.
|
|---|
| 138 | # @param $(flags) Flags.
|
|---|
| 139 | # @param $(dirdep) Directory creation dependency.
|
|---|
| 140 | # @param $(deps) Other dependencies.
|
|---|
| 141 | # @param $(deffile) Definition file. (optional, PC only)
|
|---|
| 142 | # @param $(custom_pre) Custom step invoked before linking.
|
|---|
| 143 | # @param $(custom_post) Custom step invoked after linking.
|
|---|
| 144 | #
|
|---|
| 145 | # @param $(outbase) Output basename (full). Use this for list files and such.
|
|---|
| 146 | define TOOL_GCC3_LINK_PROGRAM
|
|---|
| 147 | #$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
|
|---|
| 148 | $(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
|
|---|
| 149 | $(call MSG_L1,Creating Program $$@)
|
|---|
| 150 | ifneq ($(custom_pre),)
|
|---|
| 151 | $(eval $(custom_pre))
|
|---|
| 152 | endif
|
|---|
| 153 | $(TOOL_GCC3_LD) $(flags) -o $$@ $(objs) \
|
|---|
| 154 | $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
|
|---|
| 155 | ifneq ($(custom_post),)
|
|---|
| 156 | $(eval $(custom_post))
|
|---|
| 157 | endif
|
|---|
| 158 | $(MKDIR) -p $(PATH_BIN)
|
|---|
| 159 | $(CP) $$@ $(PATH_BIN)/
|
|---|
| 160 |
|
|---|
| 161 | endef
|
|---|
| 162 |
|
|---|