7 # Copyright (c) 2005-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
9 # This file is part of kBuild.
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 3 of the License, or
14 # (at your option) any later version.
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.
21 # You should have received a copy of the GNU General Public License
22 # along with kBuild. If not, see <http://www.gnu.org/licenses/>
26 # Enable automatic installation of what's built.
27 KBUILD_DO_AUTO_INSTALL
:= 1
33 KBUILD_VERSION_MAJOR
= 0
34 KBUILD_VERSION_MINOR
= 1
35 KBUILD_VERSION_PATCH
= 5
36 KBUILD_VERSION
= 0.1.5
38 KBUILD_VERSION_MAJOR
=$(KBUILD_VERSION_MAJOR
) \
39 KBUILD_VERSION_MINOR
=$(KBUILD_VERSION_MINOR
) \
40 KBUILD_VERSION_PATCH
=$(KBUILD_VERSION_PATCH
)
43 # Get the svn version.
44 # This is shipped with the tarballs in a SvnInfo.kmk in the root.
46 ifneq ($(wildcard $(PATH_ROOT
)/SvnInfo.kmk
),)
48 KBUILD_SVN_INFO_KMK
:= $(PATH_ROOT
)/SvnInfo.kmk
49 KBUILD_SVN_INFO_DEP
:= $(KBUILD_SVN_INFO_KMK
)
51 else ifneq ($(wildcard $(PATH_ROOT
)/.svn
/entries
),)
52 # Generate from svn info
53 KBUILD_SVN_INFO_KMK
:= $(PATH_OBJ
)/SvnInfo.kmk
54 KBUILD_SVN_INFO_DEP
:= $(KBUILD_SVN_INFO_KMK
)
56 $(PATH_OBJ
)/SvnInfo.ts
+|
$(KBUILD_SVN_INFO_KMK
): $(wildcard $(PATH_ROOT
)/.svn
$(PATH_ROOT
)/.svn
/entries
$(PATH_ROOT
)/.svn
/all-wcprops
$(PATH_ROOT
)/.svn
/format
$(PATH_ROOT
)/.svn
/props
$(PATH_ROOT
)/.svn
/prop-base
)
57 $(call MSG_GENERATE
,,$(KBUILD_SVN_INFO_KMK
))
60 @
$(REDIRECT
) -o
$@.tmp
-E
'LC_ALL=C' -- svn
info $(DEPTH
)
62 -e
's/URL: */KBUILD_SVN_URL := /' \
63 -e
's/Revision: */KBUILD_SVN_REV := /' \
64 -e
'/KBUILD_SVN_/!d' \
68 @
$(CP
) --changed
-fv
$@
$(KBUILD_SVN_INFO_KMK
)
71 OTHER_CLEAN
+= $(KBUILD_SVN_INFO_KMK
) $(PATH_OBJ
)/SvnInfo.ts
75 # Some incomplete source export...
76 KBUILD_SVN_INFO_KMK
:= $(PATH_OBJ
)/SvnInfo.kmk
77 KBUILD_SVN_INFO_DEP
:= $(KBUILD_SVN_INFO_KMK
)
78 $(warning Neither SvnInfo nor .svn
/* was found in the root. Will have to cook up something too keep the build happy.
)
79 $(KBUILD_SVN_INFO_KMK
):
82 $(APPEND
) $@
'KBUILD_SVN_REV := 0'
83 $(APPEND
) $@
'KBUILD_SVN_URL := /dev/null'
86 OTHER_CLEAN
+= $(KBUILD_SVN_INFO_KMK
)
90 include $(KBUILD_SVN_INFO_KMK
)
94 # Where to fine the GNU Make stuff (for FreeBSD and Windows).
96 PATH_GNUMAKE_SRC ?
= $(PATH_ROOT
)/src
/kmk
100 # The OS and Architecture indicators.
102 DEFS.darwin
+= KBUILD_OS_DARWIN
103 DEFS.freebsd
+= KBUILD_OS_FREEBSD
104 DEFS.linux
+= KBUILD_OS_LINUX
105 DEFS.netbsd
+= KBUILD_OS_NETBSD
106 DEFS.openbsd
+= KBUILD_OS_OPENBSD
107 DEFS.os2
+= KBUILD_OS_OS2
108 DEFS.solaris
+= KBUILD_OS_SOLARIS
109 DEFS.win
+= KBUILD_OS_WINDOWS
111 DEFS.x86
+= KBUILD_ARCH_X86
112 DEFS.amd64
+= KBUILD_ARCH_AMD64
116 # Check if we're building a *nix installation.
118 # There are a few optional overrides here for customizing the install location
119 # and how it is installed:
120 # MY_INST_BIN - the bin/ directory (the trailing slash is mandatory).
121 # MY_INST_DATA - the share/kBuild/ directory (the trailing slash is mandatory).
122 # MY_INST_DOC - the share/doc/kBuild-x.y.z/ directory (the trailing slash is mandatory).
123 # MY_INST_UID - the default install UID or user name.
124 # MY_INST_GID - the default install GID or group name.
125 # MY_INST_MODE - the default install mode mask, ",a+x" is added for executables and files.
126 # MY_INST_DATA_UID - data specialization.
127 # MY_INST_DATA_GID - data specialization.
128 # MY_INST_DATA_MODE - data specialization.
129 # MY_INST_DOC_UID - doc specialization.
130 # MY_INST_DOC_GID - doc specialization.
131 # MY_INST_DOC_MODE - doc specialization.
132 # MY_INST_BIN_UID - binary (executable) specialization.
133 # MY_INST_BIN_GID - binary (executable) specialization.
134 # MY_INST_BIN_MODE - binary (executable) specialization.
136 # When running kmk install, you can use PATH_INS like you use DESTDIR in other makefile
137 # systems. (These things will be improved in 0.2.x btw, so will be possible to enable a
138 # mode where PREFIX and DESTDIR will.)
141 ifdef NIX_INSTALL_DIR
142 MY_INST_ROOT
:= $(patsubst /%,%,$(NIX_INSTALL_DIR
))/
144 MY_INST_BIN
:= $(MY_INST_ROOT
)bin
/
147 MY_INST_DATA
:= $(MY_INST_ROOT
)share
/kBuild
/
150 MY_INST_DOC
:= $(MY_INST_ROOT
)share
/doc
/kBuild-
$(KBUILD_VERSION
)/
152 if
!defined
(MY_INST_BIN_MODE
) && defined
(MY_INST_MODE
)
153 MY_INST_BIN_MODE
:= $(MY_INST_MODE
),a
+x
157 KBUILD_PATH
=\"/$(patsubst %/,%,$(MY_INST_DATA
))\" \
158 KBUILD_BIN_PATH
=\"/$(patsubst %/,%,$(MY_INST_BIN
))\"
163 # Templates for installing docs and make scripts.
165 TEMPLATE_DATA
= Data installation template.
166 TEMPLATE_DATA_INST
= $(MY_INST_DATA
)
167 TEMPLATE_DATA_MODE ?
= $(firstword $(MY_INST_DATA_MODE
) $(MY_INST_MODE
) a
+r
)
168 TEMPLATE_DATA_UID ?
= $(firstword $(MY_INST_DATA_UID
) $(MY_INST_UID
))
169 TEMPLATE_DATA_GID ?
= $(firstword $(MY_INST_DATA_GID
) $(MY_INST_GID
))
171 TEMPLATE_DOC
= Documentation installation template.
172 TEMPLATE_DOC_INST
= $(MY_INST_DOC
)
173 TEMPLATE_DOC_MODE ?
= $(firstword $(MY_INST_DOC_MODE
) $(MY_INST_MODE
) a
+r
)
174 TEMPLATE_DOC_UID ?
= $(firstword $(MY_INST_DOC_UID
) $(MY_INST_UID
))
175 TEMPLATE_DOC_GID ?
= $(firstword $(MY_INST_DOC_GID
) $(MY_INST_GID
))
179 # Template for building commandline tools.
181 TEMPLATE_BIN
= Commandline binary
183 TEMPLATE_BIN_INCS
= $(PATH_ROOT
)/src
/lib
184 TEMPLATE_BIN_DEFS.profile
= NDEBUG
185 TEMPLATE_BIN_DEFS.release
= NDEBUG
186 if defined
(NIX_INSTALL_DIR
) && !defined
(KBUILD_BOOTSTRAP
)
187 TEMPLATE_BIN_INST
= $(MY_INST_BIN
)
188 TEMPLATE_BIN_MODE ?
= $(firstword $(MY_INST_BIN_MODE
) a
+rx
)
189 TEMPLATE_BIN_UID ?
= $(firstword $(MY_INST_BIN_UID
) $(MY_INST_UID
))
190 TEMPLATE_BIN_GID ?
= $(firstword $(MY_INST_BIN_GID
) $(MY_INST_GID
))
192 TEMPLATE_BIN_INST
= kBuild
/bin
/$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)/
196 ifeq ($(KBUILD_TARGET
),os2
)
197 TEMPLATE_BIN_TOOL
= GCC3OMF
198 TEMPLATE_BIN_CFLAGS
= -g
199 TEMPLATE_BIN_CFLAGS.profile
= -pg
200 TEMPLATE_BIN_CFLAGS.release
= -O3
201 TEMPLATE_BIN_LDFLAGS
= -Zhigh-mem
-Zstack
=1024 -g
204 ifeq ($(KBUILD_TARGET
),darwin
)
205 ifndef KBUILD_MACOSX_VERSION
206 export KBUILD_MACOSX_VERSION
:= $(firstword $(subst .
, ,$(shell uname
-r
)))
208 KBUILD_MACOSX_SDK ?
= /Developer
/SDKs
/MacOSX10.4u.sdk
209 TEMPLATE_BIN_TOOL
= GCC4MACHO
210 TEMPLATE_BIN_CFLAGS
= -g
-mmacosx-version-min
=10.4 -isysroot
$(KBUILD_MACOSX_SDK
)
212 TEMPLATE_BIN_CFLAGS
+= -Wall
-Wextra
-pedantic
-Wno-unused-parameter
213 TEMPLATE_BIN_DEFS
+= NO_ENUM_BITFIELDS
215 TEMPLATE_BIN_CFLAGS.profile
= -O3
-pg
216 TEMPLATE_BIN_CFLAGS.release
= -O3
217 TEMPLATE_BIN_LDFLAGS
= -g
-mmacosx-version-min
=10.4 -Wl
,-syslibroot
,$(KBUILD_MACOSX_SDK
)
218 ifneq ($(int-ge
$(KBUILD_MACOSX_VERSION
),9),) # >= 10.5
219 TEMPLATE_BIN_LDFLAGS
+= -classic_ld
221 TEMPLATE_BIN_LDFLAGS.profile
= -pg
224 ifeq ($(filter-out win nt
,$(KBUILD_TARGET
)),)
225 ifeq ($(KBUILD_TARGET_ARCH
),x86
)
226 include $(KBUILD_PATH
)/tools
/VCC70.kmk
# fixme! template expanding does something bad to _LIBS /me thinks.
227 TEMPLATE_BIN_TOOL
= VCC70
228 TEMPLATE_BIN_DEFS
= WINDOWS32 _CONSOLE __WIN__ WIN32 __WIN32__
229 else ifeq ($(KBUILD_TARGET_ARCH
),amd64
)
230 TEMPLATE_BIN_TOOL
= VCC80AMD64
231 TEMPLATE_BIN_DEFS
= WINDOWS32 _CONSOLE __WIN__ WIN32 __WIN32__ __WIN64__ WIN64 \
232 _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS
234 TEMPLATE_BIN_CFLAGS
= -W3
-Zi
-Zl
235 TEMPLATE_BIN_CFLAGS.release
= -O2
236 TEMPLATE_BIN_CFLAGS.profile
= -O2
-GH
-Gh
237 TEMPLATE_BIN_INCS
+= \
239 $(PATH_GNUMAKE_SRC
)/w32
/include \
240 $(PATH_GNUMAKE_SRC
)/glob
241 TEMPLATE_BIN_LDFLAGS
= /SUBSYSTEM
:console
/INCREMENTAL
:no
/NOD
/DEBUG
242 ifeq ($(KBUILD_TYPE
),profile
)
243 TEMPLATE_BIN_SDKS
= WINPSDKINCS
244 TEMPLATE_BIN_CFLAGS
+= -MT
245 TEMPLATE_BIN_LIBS
= \
246 D
:/coding
/kStuff
/svn
/trunk
/out
/win.
$(KBUILD_TARGET_ARCH
)/release
/kStuff
/lib
/kPrf2.lib \
247 D
:/coding
/kStuff
/svn
/trunk
/out
/win.
$(KBUILD_TARGET_ARCH
)/release
/kStuff
/lib
/kPrf2WinApiWrappersImp.lib \
248 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/oldnames.lib \
249 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/libcmt.lib \
250 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/libcpmt.lib \
251 D
:/coding
/kStuff
/svn
/trunk
/out
/win.
$(KBUILD_TARGET_ARCH
)/release
/kStuff
/lib
/kPrf2WinApiWrappersImp.lib \
252 $(PATH_SDK_WINPSDKINCS_LIB
)/AdvAPI32.lib \
253 $(PATH_SDK_WINPSDKINCS_LIB
)/User32.lib
255 TEMPLATE_BIN_SDKS
= WINPSDK
256 TEMPLATE_BIN_CFLAGS
+= -MD
257 TEMPLATE_BIN_LIBS
= \
258 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/oldnames.lib \
259 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/msvcrt.lib
260 # $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/msvcprt.lib - avoid this to save space!
264 ifndef TEMPLATE_BIN_TOOL
265 # Use GCC3 when we're certain that the system is using GNU ld and ar.
266 ifeq ($(filter-out linux freebsd openbsd netbsd
,$(KBUILD_TARGET
)),)
267 TEMPLATE_BIN_TOOL
= GCC3
269 TEMPLATE_BIN_TOOL
= GCC3PLAIN
271 TEMPLATE_BIN_CFLAGS
= -g
273 TEMPLATE_BIN_CFLAGS
+= -Wall
-Wextra
-pedantic
-Wno-unused-parameter
274 TEMPLATE_BIN_DEFS
+= NO_ENUM_BITFIELDS
276 TEMPLATE_BIN_LDFLAGS
= -g
277 TEMPLATE_BIN_LDFLAGS.profile
= -pg
-p
278 TEMPLATE_BIN_CFLAGS.release
= -O3
279 TEMPLATE_BIN_CFLAGS.profile
= -O3
-pg
-p
280 ifeq ($(KBUILD_TARGET
),freebsd
)
281 TEMPLATE_BIN_INCS
+= $(PATH_GNUMAKE_SRC
)/glob
/usr
/local
/include
283 ifeq ($(KBUILD_TARGET
),linux
)
284 TEMPLATE_BIN_LIBS
+= rt
286 TEMPLATE_BIN_CFLAGS.x86
+= -m32
287 TEMPLATE_BIN_CFLAGS.sparc32
+= -m32
288 TEMPLATE_BIN_CFLAGS.amd64
+= -m64
289 TEMPLATE_BIN_CFLAGS.sparc64
+= -m64
290 TEMPLATE_BIN_CXXFLAGS.x86
+= -m32
291 TEMPLATE_BIN_CXXFLAGS.sparc32
+= -m32
292 TEMPLATE_BIN_CXXFLAGS.amd64
+= -m64
293 TEMPLATE_BIN_CXXFLAGS.sparc64
+= -m64
294 TEMPLATE_BIN_LDFLAGS.x86
+= -m32
295 TEMPLATE_BIN_LDFLAGS.sparc32
+= -m32
296 TEMPLATE_BIN_LDFLAGS.amd64
+= -m64
297 TEMPLATE_BIN_LDFLAGS.sparc64
+= -m64
298 ifeq ($(KBUILD_TARGET
),solaris
)
299 TEMPLATE_BIN_LIBS
+= rt
300 TEMPLATE_BIN_LDFLAGS
+= -Wl
,-i
305 # Template for building libraries for the tools.
307 TEMPLATE_LIB
= Library for Commandline binary
308 TEMPLATE_LIB_EXTENDS
= BIN
309 TEMPLATE_LIB_INST
= lib
/
311 TEMPLATE_LIB_TOOL
= $(TEMPLATE_BIN_TOOL
)
314 LIB_KDEP
= $(PATH_OBJ
)/kDep
/$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBPREF
)kDep
$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBSUFF
)
315 LIB_KUTIL
= $(PATH_OBJ
)/kUtil
/$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBPREF
)kUtil
$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBSUFF
)