7 # Copyright (c) 2005-2008 knut st. osmundsen <bird-src-spam@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 # The OS and Architecture indicators.
96 DEFS.darwin
+= KBUILD_OS_DARWIN
97 DEFS.freebsd
+= KBUILD_OS_FREEBSD
98 DEFS.linux
+= KBUILD_OS_LINUX
99 DEFS.netbsd
+= KBUILD_OS_NETBSD
100 DEFS.openbsd
+= KBUILD_OS_OPENBSD
101 DEFS.os2
+= KBUILD_OS_OS2
102 DEFS.solaris
+= KBUILD_OS_SOLARIS
103 DEFS.win
+= KBUILD_OS_WINDOWS
105 DEFS.x86
+= KBUILD_ARCH_X86
106 DEFS.amd64
+= KBUILD_ARCH_AMD64
110 # Check if we're building a *nix installation.
112 ifdef NIX_INSTALL_DIR
113 NIX_INSTALL_DIR_BIN
:= $(patsubst /%,%,$(NIX_INSTALL_DIR
))/bin
114 NIX_INSTALL_DIR_SHARE
:= $(patsubst /%,%,$(NIX_INSTALL_DIR
))/share
/kBuild
116 KBUILD_PATH
=\"/$(NIX_INSTALL_DIR_SHARE
)\" \
117 KBUILD_BIN_PATH
=\"/$(NIX_INSTALL_DIR_BIN
)\"
121 # Where to fine the GNU Make stuff (for FreeBSD and Windows).
123 PATH_GNUMAKE_SRC ?
= $(PATH_ROOT
)/src
/kmk
127 # Template for building commandline tools.
129 TEMPLATE_BIN
= Commandline binary
131 TEMPLATE_BIN_INCS
= $(PATH_ROOT
)/src
/lib
132 TEMPLATE_BIN_DEFS.profile
= NDEBUG
133 TEMPLATE_BIN_DEFS.release
= NDEBUG
134 if defined
(NIX_INSTALL_DIR
) && !defined
(KBUILD_BOOTSTRAP
)
135 TEMPLATE_BIN_INST
= $(NIX_INSTALL_DIR_BIN
)/
137 TEMPLATE_BIN_INST
= kBuild
/bin
/$(KBUILD_TARGET
).
$(KBUILD_TARGET_ARCH
)/
140 ifeq ($(KBUILD_TARGET
),os2
)
141 TEMPLATE_BIN_TOOL
= GCC3OMF
142 TEMPLATE_BIN_CFLAGS
= -g
143 TEMPLATE_BIN_CFLAGS.profile
= -pg
144 TEMPLATE_BIN_CFLAGS.release
= -O3
145 TEMPLATE_BIN_LDFLAGS
= -Zhigh-mem
-Zstack
=1024 -g
148 ifeq ($(KBUILD_TARGET
),darwin
)
149 ifndef KBUILD_MACOSX_VERSION
150 export KBUILD_MACOSX_VERSION
:= $(firstword $(subst .
, ,$(shell uname
-r
)))
152 KBUILD_MACOSX_SDK ?
= /Developer
/SDKs
/MacOSX10.4u.sdk
153 TEMPLATE_BIN_TOOL
= GCC4MACHO
154 TEMPLATE_BIN_CFLAGS
= -g
-mmacosx-version-min
=10.4 -isysroot
$(KBUILD_MACOSX_SDK
)
156 TEMPLATE_BIN_CFLAGS
+= -Wall
-Wextra
-pedantic
-Wno-unused-parameter
157 TEMPLATE_BIN_DEFS
+= NO_ENUM_BITFIELDS
159 TEMPLATE_BIN_CFLAGS.profile
= -O3
-pg
160 TEMPLATE_BIN_CFLAGS.release
= -O3
161 TEMPLATE_BIN_LDFLAGS
= -g
-mmacosx-version-min
=10.4 -Wl
,-syslibroot
,$(KBUILD_MACOSX_SDK
)
162 ifneq ($(int-ge
$(KBUILD_MACOSX_VERSION
),9),) # >= 10.5
163 TEMPLATE_BIN_LDFLAGS
+= -classic_ld
165 TEMPLATE_BIN_LDFLAGS.profile
= -pg
168 ifeq ($(filter-out win nt
,$(KBUILD_TARGET
)),)
169 ifeq ($(KBUILD_TARGET_ARCH
),x86
)
170 include $(KBUILD_PATH
)/tools
/VCC70.kmk
# fixme! template expanding does something bad to _LIBS /me thinks.
171 TEMPLATE_BIN_TOOL
= VCC70
172 TEMPLATE_BIN_DEFS
= WINDOWS32 _CONSOLE __WIN__ WIN32 __WIN32__
173 else ifeq ($(KBUILD_TARGET_ARCH
),amd64
)
174 TEMPLATE_BIN_TOOL
= VCC80AMD64
175 TEMPLATE_BIN_DEFS
= WINDOWS32 _CONSOLE __WIN__ WIN32 __WIN32__ __WIN64__ WIN64 \
176 _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_WARNINGS
178 TEMPLATE_BIN_CFLAGS
= -W3
-Zi
-Zl
179 TEMPLATE_BIN_CFLAGS.release
= -O2
180 TEMPLATE_BIN_CFLAGS.profile
= -O2
-GH
-Gh
181 TEMPLATE_BIN_INCS
+= \
183 $(PATH_GNUMAKE_SRC
)/w32
/include \
184 $(PATH_GNUMAKE_SRC
)/glob
185 TEMPLATE_BIN_LDFLAGS
= /SUBSYSTEM
:console
/INCREMENTAL
:no
/NOD
/DEBUG
186 ifeq ($(KBUILD_TYPE
),profile
)
187 TEMPLATE_BIN_SDKS
= WINPSDKINCS
188 TEMPLATE_BIN_CFLAGS
+= -MT
189 TEMPLATE_BIN_LIBS
= \
190 D
:/coding
/kStuff
/svn
/trunk
/out
/win.
$(KBUILD_TARGET_ARCH
)/release
/kStuff
/lib
/kPrf2.lib \
191 D
:/coding
/kStuff
/svn
/trunk
/out
/win.
$(KBUILD_TARGET_ARCH
)/release
/kStuff
/lib
/kPrf2WinApiWrappersImp.lib \
192 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/oldnames.lib \
193 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/libcmt.lib \
194 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/libcpmt.lib \
195 D
:/coding
/kStuff
/svn
/trunk
/out
/win.
$(KBUILD_TARGET_ARCH
)/release
/kStuff
/lib
/kPrf2WinApiWrappersImp.lib \
196 $(PATH_SDK_WINPSDKINCS_LIB
)/AdvAPI32.lib \
197 $(PATH_SDK_WINPSDKINCS_LIB
)/User32.lib
199 TEMPLATE_BIN_SDKS
= WINPSDK
200 TEMPLATE_BIN_CFLAGS
+= -MD
201 TEMPLATE_BIN_LIBS
= \
202 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/oldnames.lib \
203 $(PATH_TOOL_
$(TEMPLATE_BIN_TOOL
)_LIB
)/msvcrt.lib
204 # $(PATH_TOOL_$(TEMPLATE_BIN_TOOL)_LIB)/msvcprt.lib - avoid this to save space!
208 ifndef TEMPLATE_BIN_TOOL
209 # Use GCC3 when we're certain that the system is using GNU ld and ar.
210 ifeq ($(filter-out linux freebsd openbsd netbsd
,$(KBUILD_TARGET
)),)
211 TEMPLATE_BIN_TOOL
= GCC3
213 TEMPLATE_BIN_TOOL
= GCC3PLAIN
215 TEMPLATE_BIN_CFLAGS
= -g
217 TEMPLATE_BIN_CFLAGS
+= -Wall
-Wextra
-pedantic
-Wno-unused-parameter
218 TEMPLATE_BIN_DEFS
+= NO_ENUM_BITFIELDS
220 TEMPLATE_BIN_LDFLAGS
= -g
221 TEMPLATE_BIN_LDFLAGS.profile
= -pg
-p
222 TEMPLATE_BIN_CFLAGS.release
= -O3
223 TEMPLATE_BIN_CFLAGS.profile
= -O3
-pg
-p
224 ifeq ($(KBUILD_TARGET
),freebsd
)
225 TEMPLATE_BIN_INCS
+= $(PATH_GNUMAKE_SRC
)/glob
/usr
/local
/include
227 ifeq ($(KBUILD_TARGET
),linux
)
228 TEMPLATE_BIN_LIBS
+= rt
230 TEMPLATE_BIN_CFLAGS.x86
+= -m32
231 TEMPLATE_BIN_CFLAGS.sparc32
+= -m32
232 TEMPLATE_BIN_CFLAGS.amd64
+= -m64
233 TEMPLATE_BIN_CFLAGS.sparc64
+= -m64
234 TEMPLATE_BIN_CXXFLAGS.x86
+= -m32
235 TEMPLATE_BIN_CXXFLAGS.sparc32
+= -m32
236 TEMPLATE_BIN_CXXFLAGS.amd64
+= -m64
237 TEMPLATE_BIN_CXXFLAGS.sparc64
+= -m64
238 TEMPLATE_BIN_LDFLAGS.x86
+= -m32
239 TEMPLATE_BIN_LDFLAGS.sparc32
+= -m32
240 TEMPLATE_BIN_LDFLAGS.amd64
+= -m64
241 TEMPLATE_BIN_LDFLAGS.sparc64
+= -m64
242 ifeq ($(KBUILD_TARGET
),solaris
)
243 TEMPLATE_BIN_LIBS
+= rt
244 TEMPLATE_BIN_LDFLAGS
+= -Wl
,-i
249 # Template for building libraries for the tools.
251 TEMPLATE_LIB
= Library for Commandline binary
252 TEMPLATE_LIB_EXTENDS
= BIN
253 TEMPLATE_LIB_INST
= lib
/
255 TEMPLATE_LIB_TOOL
= $(TEMPLATE_BIN_TOOL
)
258 LIB_KDEP
= $(PATH_OBJ
)/kDep
/$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBPREF
)kDep
$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBSUFF
)
259 LIB_KUTIL
= $(PATH_OBJ
)/kUtil
/$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBPREF
)kUtil
$(TOOL_
$(TEMPLATE_LIB_TOOL
)_ARLIBSUFF
)