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

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

DLL

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1# $Id: GCC3.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
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
59ifndef TOOL_GCC3_LDFLAGS.$(BUILD_TARGET)
60TOOL_GCC3_LDFLAGS.dll := -shared
61else
62TOOL_GCC3_LDFLAGS.dll := $(TOOL_GCC3_LDFLAGS.$(BUILD_TARGET))
63endif
64
65
66## Compile C source.
67# @param $(target) Normalized main target name.
68# @param $(source) Source filename (relative).
69# @param $(obj) Object file name. This shall be (re)created by the compilation.
70# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
71# @param $(flags) Flags.
72# @param $(defs) Definitions. No -D or something.
73# @param $(incs) Includes. No -I or something.
74# @param $(dirdep) Directory creation dependency.
75#
76# @param $(outbase) Output basename (full). Use this for list files and such.
77# @param $(objsuff) Object suffix.
78define TOOL_GCC3_COMPILE_C
79#$ (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))
80$(obj): $(dirdep) $(source)
81 $(call MSG_L2,Compiling $$@ using GCC3)
82 $(TOOL_GCC3_CC) -c\
83 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
84 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
85 -o $$@\
86 $(call ABSPATH,$(source))
87
88endef
89
90
91## Compile C++ source.
92# @param $(target) Normalized main target name.
93# @param $(source) Source filename (relative).
94# @param $(obj) Object file name. This shall be (re)created by the compilation.
95# @param $(dep) Dependcy file. This shall be (re)created by the compilation.
96# @param $(flags) Flags.
97# @param $(defs) Definitions. No -D or something.
98# @param $(incs) Includes. No -I or something.
99# @param $(dirdep) Directory creation dependency.
100#
101# @param $(outbase) Output basename (full). Use this for list files and such.
102# @param $(objsuff) Object suffix.
103define TOOL_GCC3_COMPILE_CXX
104#$ (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))
105$(obj): $(dirdep) $(source)
106 $(call MSG_L2,Compiling $$@ using GCC3)
107 $(TOOL_GCC3_CXX) -c\
108 $(flags) $(addprefix -I, $(incs)) $(addprefix -D, $(defs))\
109 -Wp,-MD,$(dep) -Wp,-MT,$$@ \
110 -o $$@\
111 $(call ABSPATH,$(source))
112
113endef
114
115
116## Link library
117# @param $(target) Normalized main target name.
118# @param $(lib) Library name.
119# @param $(objs) Object files to put in the library.
120# @param $(flags) Flags.
121# @param $(dirdep) Directory creation dependency.
122# @param $(deps) Other dependencies.
123#
124# @param $(outbase) Output basename (full). Use this for list files and such.
125define TOOL_GCC3_LINK_LIBRARY
126#$ (warning dbg: TOOL_GCC3_LINK_LIBRARY: target=$(target) lib=$(lib) objs=$(objs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) outbase=$(outbase))
127$(lib): $(dirdep) $(objs) $(deps)
128 $(call MSG_L1,Creating Library $$@)
129 $(RM) -f $$@
130 $(TOOL_GCC3_AR) $(flags) $$@ $(objs)
131
132endef
133
134
135## Link program
136# @param $(target) Normalized main target name.
137# @param $(exe) Program name.
138# @param $(objs) Object files to link together.
139# @param $(libs) Libraries to search.
140# @param $(libpath) Library search paths.
141# @param $(flags) Flags.
142# @param $(dirdep) Directory creation dependency.
143# @param $(deps) Other dependencies.
144# @param $(othersrc) Unhandled sources.
145# @param $(custom_pre) Custom step invoked before linking.
146# @param $(custom_post) Custom step invoked after linking.
147#
148# @param $(outbase) Output basename (full). Use this for list files and such.
149define TOOL_GCC3_LINK_PROGRAM
150#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) exe=$(exe) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
151$(exe): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
152 $(call MSG_L1,Creating Program $$@)
153ifneq ($(custom_pre),)
154 $(eval $(custom_pre))
155endif
156 $(TOOL_GCC3_LD) $(flags) -o $$@ $(objs) \
157 $(foreach p,$(libpath), -L$(p)) \
158 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
159ifneq ($(custom_post),)
160 $(eval $(custom_post))
161endif
162
163endef
164
165
166## Link DLL
167# @param $(target) Normalized main target name.
168# @param $(dll) Program name.
169# @param $(objs) Object files to link together.
170# @param $(libs) Libraries to search.
171# @param $(libpath) Library search paths.
172# @param $(flags) Flags.
173# @param $(dirdep) Directory creation dependency.
174# @param $(deps) Other dependencies.
175# @param $(othersrc) Unhandled sources.
176# @param $(custom_pre) Custom step invoked before linking.
177# @param $(custom_post) Custom step invoked after linking.
178#
179# @param $(outbase) Output basename (full). Use this for list files and such.
180define TOOL_GCC3_LINK_DLL
181#$ (warning dbg: TOOL_GCC3_LINK_PROGRAM: target=$(target) dll=$(dll) objs=$(objs) libs=$(libs) deps=$(deps) flags=$(flags) dirdep=$(dirdep) deffile=$(deffile) outbase=$(outbase))
182$(dll): $(dirdep) $(objs) $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib))) $(deps)
183 $(call MSG_L1,Creating Program $$@)
184ifneq ($(custom_pre),)
185 $(eval $(custom_pre))
186endif
187 $(TOOL_GCC3_LD) $(TOOL_GCC3_LDFLAGS.dll) $(flags) -o $$@ $(objs) \
188 $(foreach p,$(libpath), -L$(p)) \
189 $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
190ifneq ($(custom_post),)
191 $(eval $(custom_post))
192endif
193
194endef
195
Note: See TracBrowser for help on using the repository browser.