source: trunk/kBuild/tools/GCC3.kmk@ 129

Last change on this file since 129 was 129, checked in by bird, 21 years ago

ABSPATH and no need for CYGPATHMIXED.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1# $Id: GCC3.kmk 129 2004-06-29 11:55:07Z 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
27TOOL_GCC3 := Generic GCC v3
28
29TOOL_GCC3_CC := gcc$(HOSTSUFF_EXE)
30TOOL_GCC3_COBJSUFF := .o
31TOOL_GCC3_CFLAGS := -g
32TOOL_GCC3_CFLAGS.debug := -O0
33TOOL_GCC3_CFLAGS.release := -O2
34TOOL_GCC3_CFLAGS.profile := -pg
35TOOL_GCC3_CINCS :=
36TOOL_GCC3_CDEFS :=
37
38TOOL_GCC3_CXX := g++$(HOSTSUFF_EXE)
39TOOL_GCC3_CXXOBJSUFF := .o
40TOOL_GCC3_CXXOBJSUFF := .o
41TOOL_GCC3_CXXFLAGS := -g
42TOOL_GCC3_CXXFLAGS.debug := -O0
43TOOL_GCC3_CXXFLAGS.release := -O2
44TOOL_GCC3_CXXFLAGS.profile := -pg
45TOOL_GCC3_CXXINCS :=
46TOOL_GCC3_CXXDEFS :=
47
48TOOL_GCC3_AS := as$(HOSTSUFF_EXE)
49TOOL_GCC3_ASOBJSUFF := .o
50
51TOOL_GCC3_AR := ar$(HOSTSUFF_EXE)
52TOOL_GCC3_ARFLAGS := cr
53TOOL_GCC3_ARLIBSUFF := .a
54
55TOOL_GCC3_LD := g++$(HOSTSUFF_EXE)
56TOOL_GCC3_LDFLAGS :=
57TOOL_GCC3_LDFLAGS.debug := -g
58TOOL_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.
73define 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) $(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 $(call ABSPATH,$(source))
82
83endef
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.
98define 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) $(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 $(call ABSPATH,$(source))
107
108endef
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.
120define 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
127endef
128
129
130## Link program
131# @param $(target) Normalized main target name.
132# @param $(exe) Program name.
133# @param $(objs) Object files to link together.
134# @param $(libs) Libraries to search.
135# @param $(libpath) Library search paths.
136# @param $(flags) Flags.
137# @param $(dirdep) Directory creation dependency.
138# @param $(deps) Other dependencies.
139# @param $(deffile) Definition file. (optional, PC only)
140# @param $(custom_pre) Custom step invoked before linking.
141# @param $(custom_post) Custom step invoked after linking.
142#
143# @param $(outbase) Output basename (full). Use this for list files and such.
144define TOOL_GCC3_LINK_PROGRAM
145#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
146$(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
147 $(call MSG_L1,Creating Program $$@)
148ifneq ($(custom_pre),)
149 $(eval $(custom_pre))
150endif
151 $(TOOL_GCC3_LD) $(flags) -o $$@ $(objs) \
152 $(foreach p,$(libpath), -L$(p)) \
153 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
154ifneq ($(custom_post),)
155 $(eval $(custom_post))
156endif
157 $(MKDIR) -p $(PATH_BIN)
158 $(CP) $$@ $(PATH_BIN)/
159
160endef
161
Note: See TracBrowser for help on using the repository browser.