source: branches/kmk/Config.kmk @ 308

Last change on this file since 308 was 308, checked in by dmik, 12 years ago

branches/kmk: Enhanced GCC tools to support the resource compiler.

File size: 11.0 KB
Line 
1## @file
2# Global Project Configuration File
3#
4
5#------------------------------------------------------------------------------
6# Global definitions
7#------------------------------------------------------------------------------
8
9#
10# Lucide version string
11#
12VERSION          = 1.30 beta1
13
14#------------------------------------------------------------------------------
15# General Stuff
16#------------------------------------------------------------------------------
17
18#
19# Lucide C Compiler template
20#
21TEMPLATE_LucideC                         = Lucide C Compiler
22TEMPLATE_LucideC_TOOL            = GCC3OMF
23TEMPLATE_LucideC_CFLAGS          =
24TEMPLATE_LucideC_DEFS            = OS2
25
26#
27# Lucide C++ Compiler template
28#
29TEMPLATE_LucideCxx                       = Lucide C++ Compiler
30TEMPLATE_LucideCxx_TOOL          = GXX3OMF
31TEMPLATE_LucideCxx_CXXFLAGS      =
32TEMPLATE_LucideCxx_DEFS          = OS2
33
34
35#------------------------------------------------------------------------------
36# GCC Stuff
37#------------------------------------------------------------------------------
38
39#
40# Add RC support to GXX3OMF and GCC3OMF
41# (@todo create a new tool as extension to reuse the existing LINK commands)
42#
43
44TOOL_GXX3OMF_RC                                 ?= rc$(HOST_SUFF_EXE)
45TOOL_GXX3OMF_RCOBJSUFF                  ?= .res
46
47TOOL_GXX3OMF_COMPILE_RC_DEPEND   =
48TOOL_GXX3OMF_COMPILE_RC_DEPORD   =
49TOOL_GXX3OMF_COMPILE_RC_OUTPUT   =
50TOOL_GXX3OMF_COMPILE_RC_OUTPUT_MAYBE     =
51define TOOL_GXX3OMF_COMPILE_RC_CMDS
52        $(QUIET)$(TOOL_GXX3OMF_RC) -n -r\
53                $(flags) $(addprefix -i , $(incs)) $(addprefix -D, $(defs))\
54                $(source) $(obj) 1>nul 2>&1
55endef
56
57override define TOOL_GXX3OMF_LINK_DLL_CMDS
58        $(QUIET)$(APPEND) -n $(outbase).rsp\
59                $(TOOL_GXX3OMF_LDFLAGS.dll)\
60                $(flags)\
61                -o $(out)\
62                $(filter-out %.res,$(objs))\
63                $(foreach p,$(libpath), -L$(p))\
64                $(othersrc)\
65                $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
66                -Zmap=$(outbase).map
67        $(QUIET)$(TOOL_GXX3OMF_LD) @$(outbase).rsp
68        $(if $(filter %.res,$(objs)), \
69                $(QUIET)$(TOOL_GXX3OMF_RC) $(filter %.res,$(objs)) $(out) 1>nul 2>&1)
70endef
71
72override define TOOL_GXX3OMF_LINK_PROGRAM_CMDS
73        $(QUIET)$(APPEND) -n $(outbase).rsp\
74                $(flags)\
75                -o $(out)\
76                $(filter-out %.res,$(objs))\
77                $(foreach p,$(libpath), -L$(p))\
78                $(othersrc)\
79                $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
80                -Zmap=$(outbase).map
81        $(QUIET)$(TOOL_GXX3OMF_LD) @$(outbase).rsp
82        $(if $(filter %.res,$(objs)), \
83                $(QUIET)$(TOOL_GXX3OMF_RC) $(filter %.res,$(objs)) $(out) 1>nul 2>&1)
84endef
85
86TOOL_GCC3OMF_RC                                 ?= $(TOOL_GXX3OMF_RC)
87TOOL_GCC3OMF_RCOBJSUFF                  ?= $(TOOL_GXX3OMF_RCOBJSUFF)
88
89TOOL_GCC3OMF_COMPILE_RC_DEPEND                   = $(TOOL_GXX3OMF_COMPILE_RC_DEPEND)
90TOOL_GCC3OMF_COMPILE_RC_DEPORD                   = $(TOOL_GXX3OMF_COMPILE_RC_DEPORD)
91TOOL_GCC3OMF_COMPILE_RC_OUTPUT                   = $(TOOL_GXX3OMF_COMPILE_RC_OUTPUT)
92TOOL_GCC3OMF_COMPILE_RC_OUTPUT_MAYBE     = $(TOOL_GXX3OMF_COMPILE_RC_OUTPUT_MAYBE)
93TOOL_GCC3OMF_COMPILE_RC_CMDS                     = $(TOOL_GXX3OMF_COMPILE_RC_CMDS)
94
95override define TOOL_GCC3OMF_LINK_DLL_CMDS
96        $(QUIET)$(APPEND) -n $(outbase).rsp\
97                $(TOOL_GCC3OMF_LDFLAGS.dll)\
98                $(flags)\
99                -o $(out)\
100                $(filter-out %.res,$(objs))\
101                $(foreach p,$(libpath), -L$(p))\
102                $(othersrc)\
103                $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
104                -Zmap=$(outbase).map
105        $(QUIET)$(TOOL_GCC3OMF_LD) @$(outbase).rsp
106        $(if $(filter %.res,$(objs)), \
107                $(QUIET)$(TOOL_GCC3OMF_RC) $(filter %.res,$(objs)) $(out) 1>nul 2>&1)
108endef
109
110override define TOOL_GCC3OMF_LINK_PROGRAM_CMDS
111        $(QUIET)$(APPEND) -n $(outbase).rsp\
112                $(flags)\
113                -o $(out)\
114                $(filter-out %.res,$(objs))\
115                $(foreach p,$(libpath), -L$(p))\
116                $(othersrc)\
117                $(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(lib)), $(lib)))\
118                -Zmap=$(outbase).map
119        $(QUIET)$(TOOL_GCC3OMF_LD) @$(outbase).rsp
120        $(if $(filter %.res,$(objs)), \
121                $(QUIET)$(TOOL_GCC3OMF_RC) $(filter %.res,$(objs)) $(out) 1>nul 2>&1)
122endef
123
124#------------------------------------------------------------------------------
125# SOM Stuff
126#------------------------------------------------------------------------------
127
128# Paths: SOM SDK
129PATH_SDK_SOM                            ?= D:/Dev/OS2TK45/som
130ifeq ($(PATH_SDK_SOM),)
131$(error PATH_SDK_SOM is not set!)
132endif
133PATH_SDK_SOM_INCS                       ?= $(PATH_SDK_SOM)/include
134PATH_SDK_SOM_LIBPATH            ?= $(PATH_SDK_SOM)/lib
135
136# Paths: SOM Tool
137PATH_TOOL_SOM_BIN                       ?= $(PATH_SDK_SOM)/bin
138
139#
140# SOM SDK
141#
142SDK_SOM                                         := System Object Model Toolkit
143SDK_SOM_INCS                            ?= $(PATH_SDK_SOM_INCS)
144SDK_SOM_LIBPATH                         ?= $(PATH_SDK_SOM_LIBPATH)
145SDK_SOM_LIBS                            ?= somtk
146
147#
148# SOM Tool
149#
150# Notes: A valud value of the -s option must always be specified in IDLFLAGS;
151# the output of the first emitter is taken as the main output file and will be
152# sent to the compiler. All generated output go to $(dir $(outbase)) except the
153# output files ecplicitly listed in $(target)_IDLSOURCES which stay where they
154# are.
155#
156TOOL_SOM                                        := System Object Model Tooklit
157TOOL_SOM_IDL                            ?= $(PATH_TOOL_SOM_BIN)/sc$(HOST_SUFF_EXE)
158TOOL_SOM_IDLFLAGS           ?=
159TOOL_SOM_IDL_OUTPUT                      = $(addprefix $(outbase).,$(wordlist 2,1000,$(TOOL_SOM_IDL_EMITTERS)))
160TOOL_SOM_IDL_OUTPUT_MAYBE        =
161TOOL_SOM_IDL_DEPEND                      =
162TOOL_SOM_IDL_DEPORD                      =
163# IDL-specific properties
164TOOL_SOM_IDL_OUT                         = $(outbase).$(if $(filter xc,$(firstword $(TOOL_SOM_IDL_EMITTERS))),cpp,$(firstword $(TOOL_SOM_IDL_EMITTERS)))
165# SOM-specific properties
166TOOL_SOM_IDL_EMITTERS            = $(subst ;, ,$(patsubst -s"%",%,$(filter -s"%",$(flags))))
167
168## Compile an IDL file.
169#
170# @param    $(target)   Normalized main target name.
171# @param    $(source)   Source filename (relative).
172# @param    $(out)      Object file name. This shall be (re)created by the compilation.
173# @param    $(dep)      Dependcy file. This may be (re)created by the compilation.
174# @param    $(flags)    Flags.
175# @param    $(defs)     Definitions.
176# @param    $(incs)     Includes.
177# @param    $(outbase)  Output basename (full). Use this for list files and such.
178#
179define TOOL_SOM_IDL_CMDS
180        $(QUIET)$(TOOL_SOM_IDL) $(flags) \
181        $(addprefix -I, $(incs)) \
182        $(addprefix -D, $(defs)) \
183        -d $(dir $(outbase)) $(source)
184endef
185
186#
187# SOM Unit
188#
189
190# Add our target properties
191PROPS_TOOLS += IDLTOOL
192PROPS_SINGLE += IDLTOOL
193PROPS_ACCUMULATE_R += IDLFLAGS
194
195# Add ourselves to the default source handlers
196KBUILD_SRC_HANDLERS += \
197  .idl:def_src_handler_idl_idl
198
199# wrapper the compile command dependency check.
200ifndef NO_COMPILE_CMDS_DEPS
201 _UNIT_SOM_IDL_CMDS_DEP = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_SOM_IDL_CMDS_PREV_),$$(commands $(out)),FORCE)
202else
203 _UNIT_SOM_IDL_CMDS_DEP =
204endif
205
206##
207# Generates the rules for running IDL comiler on a specific source file.
208#
209# @param    lots
210#
211define def_idl_rule
212
213$(out) + $(output) +| $(output_maybe) : \
214                $(deps) \
215                $(value _UNIT_SOM_IDL_CMDS_DEP) \
216                | \
217                $(orderdeps)
218        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
219        $$(QUIET)$$(RM) -f -- $(dep) $(out) $(output) $(output_maybe)
220        $(foreach f,$(out) $(output) $(output_maybe),\
221                $(if $(findstring $(notdir $f),$(notdir $($(target)_IDLSOURCES))),\
222                        $$(QUIET)$(CP) --ignore-non-existing $(filter %$(notdir $f),$($(target)_IDLSOURCES)) $f))
223
224$(cmds)
225
226        $(foreach f,$(out) $(output) $(output_maybe),\
227                $(if $(findstring $(notdir $f),$(notdir $($(target)_IDLSOURCES))),\
228                        $$(QUIET)$(CP) --changed $f $(filter %$(notdir $f),$($(target)_IDLSOURCES))))
229
230ifndef NO_COMPILE_CMDS_DEPS
231        %$$(QUIET2)$$(APPEND) '$(dep)'
232        %$$(QUIET2)$$(APPEND) '$(dep)' 'define $(target)_$(subst :,_,$(source))_SOM_IDL_CMDS_PREV_'
233        %$$(QUIET2)$$(APPEND) -c '$(dep)' '$(out)'
234        %$$(QUIET2)$$(APPEND) '$(dep)' 'endef'
235endif
236
237# if the generated file is listed in IDLSOURCES, add it to _GEN_SOURCES_ from
238# there (we did a copy trick for it), otherwise add it only of it's $(out)
239$(foreach f,$(out) $(output) $(output_maybe),\
240        $(if $(findstring $(notdir $f),$(notdir $($(target)_IDLSOURCES))),\
241                $(eval $(target)_GEN_SOURCES_ += $(filter %$(notdir $f),$($(target)_IDLSOURCES))),\
242                $(if $(findstring $f,$(out)),$(eval $(target)_GEN_SOURCES_ += $f))))
243
244# update globals and target properties.
245_OUT_FILES += $(out) $(output) $(output_maybe)
246#$(target)_GEN_SOURCES_ += $(out)
247$(target)_INTERMEDIATES += $(intermediates)
248
249endef # def_idl_rule
250
251##
252# Handler for .idl files listed in the SOURCES properties.
253#
254# .idl files are transformed into C/C++ header files and maybe to source files
255# compiled by the compiler.
256#
257# @param    target      The target file.
258# @param    source      The source file.
259# @param    lots more
260# @returns  quite a bit.
261#
262define def_src_handler_idl_idl
263
264local type      := IDL
265
266# Figure out all the props.
267local tool      := $(kb-src-tool dummy_var)
268ifeq ($(tool),)
269$(error kBuild: $(target) / $(sources) does not have IDLTOOL defined!)
270endif
271ifndef TOOL_$(tool)_IDL_CMDS
272$(error kBuild: TOOL_$(tool)_IDL_CMDS isn't defined! target=$(target) source=$(source))
273endif
274local outbase   := $(kb-obj-base outbase)
275local flags             := $(kb-src-prop IDLFLAGS,dummy_var,left-to-right,) # rest depends on flags
276local out               := $(TOOL_$(tool)_IDL_OUT)
277ifeq ($(out),)
278$(error kBuild: TOOL_$(tool)_IDL_OUT isn't defined! target=$(target) source=$(source))
279endif
280local incs              := $(kb-src-prop INCS,dummy_var,left-to-right,$(defpath))
281local defs              := $(kb-src-prop DEFS,dummy_var,left-to-right,)
282local deps              := $(kb-src-prop DEPS,dummy_var,left-to-right,$(defpath))
283local orderdeps := $(call DIRDEP,$(dir $(outbase))) $(kb-src-prop ORDERDEPS,dummy_var,left-to-right)
284
285# default path + source dep.
286ifneq ($(defpath),)
287local source    := $(abspathex $(source),$(defpath))
288endif
289local deps      += $(source)
290
291# dependency file.
292local dep               := $(out)$(SUFF_DEP)
293ifndef NO_COMPILE_CMDS_DEPS
294 _DEPFILES_INCLUDED += $(dep)
295 $(eval includedep $(dep))
296endif
297
298# Call the tool.
299local cmds                      := $(TOOL_$(tool)_IDL_CMDS)
300local output            := $(TOOL_$(tool)_IDL_OUTPUT)
301local output_maybe      := $(TOOL_$(tool)_IDL_OUTPUT_MAYBE)
302local deps                      += $(TOOL_$(tool)_IDL_DEPEND)
303local orderdeps         += $(TOOL_$(tool)_IDL_DEPORD)
304
305# Whether it generates a header file depends on flags.
306local intermediates := $(filter %.xh %.xih,$(output))
307
308# Let the target include the generated files.
309$(target)_INCS          += $(dir $(outbase))
310
311# Generate the rule.
312$(eval $(def_idl_rule))
313
314endef # def_src_handler_idl_idl
315
316#
317# Lucide SOM class DLL template
318#
319TEMPLATE_SomDll              = Lucide SOM class DLL
320TEMPLATE_SomDll_EXTENDS          = LucideCxx
321TEMPLATE_SomDll_EXTENDS_BY       = appending
322TEMPLATE_SomDll_CXXFLAGS         = -Wno-write-strings # SOM compiler is loose here
323TEMPLATE_SomDll_DEFS             = SOMLINK=_System
324TEMPLATE_SomDll_SDKS             = SOM
325TEMPLATE_SomDll_IDLTOOL          = SOM
326TEMPLATE_SomDll_IDLFLAGS         = -c -s"xc;xh;xih"
327
328#------------------------------------------------------------------------------
329# Other Stuff
330#------------------------------------------------------------------------------
331
332#
333# Include a site-specific config for local overrides
334#
335ifndef LOCALCFG
336 LOCALCFG := $(wildcard $(PATH_ROOT)/LocalConfig.kmk)
337 ifneq ($(LOCALCFG),)
338  include $(LOCALCFG)
339 endif
340endif
341
Note: See TracBrowser for help on using the repository browser.