Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/build/v1/distribution.jam @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 6.1 KB
Line 
1# Copyright 2002 Rene Rivera
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
4
5##
6## Distribution module, contains rules for management of distributions.
7## Like management of version headers, packaging, etc.
8## All the rules here operate on a set of global target all of which
9## start with "dist", are NOTFILES, and can only be built from the
10## top-level.
11##
12
13# Add the version information for the given 'name' component, to the
14# given target header. Instructions are generated to construct a C header file
15# with the version information specified by 'target'.
16#
17# EXAMPLE:
18#
19# SEARCH on <module@>distribution.jam = $(BOOST_BUILD_PATH) ;
20# module distribution { include <module@>distribution.jam ; }
21#
22# distribution.version-header boost/version.hpp
23#     : Boost 1.27
24#     "//  boost version.hpp header file  -------------------------------------------//"
25#     ""
26#     "//  (C) Copyright boost.org 1999. Permission to copy, use, modify, sell"
27#     "//  and distribute this software is granted provided this copyright"
28#     "//  notice appears in all copies. This software is provided \"as is\" without"
29#     "//  express or implied warranty, and with no claim as to its suitability for"
30#     "//  any purpose."
31#     ""
32#     "//  See http://www.boost.org for most recent version including documentation."
33#     ;
34#
35# PRODUCES:
36#
37# [boost/version.hpp]
38#
39# //  boost version.hpp header file  -------------------------------------------//
40#
41# //  (C) Copyright boost.org 1999. Permission to copy, use, modify, sell
42# //  and distribute this software is granted provided this copyright
43# //  notice appears in all copies. This software is provided "as is" without
44# //  express or implied warranty, and with no claim as to its suitability for
45# //  any purpose.
46#
47# //  See http://www.boost.org for most recent version including documentation.
48#
49# #ifndef BOOST_VERSION_DEF
50# #define BOOST_VERSION_DEF
51# #define BOOST_VERSION_STRING  "Boost 1.27"
52# #define BOOST_VERSION_MAJOR  1
53# #define BOOST_VERSION_MINOR  27
54# #define BOOST_VERSION_SUBMINOR  0
55# #define BOOST_VERSION  102700
56# #endif
57#
58# IFF:
59#
60# [When at the root of the project.]
61# $shell> jam dist
62#
63rule version-header ( target : name version comment-text * )
64{
65    local target-dir =
66        [ tokens-to-simple-path [ top-relative-tokens [ directory-of $(target) ] ] ] ;
67    local target-id =
68        [ target-id-of $(target) ] ;
69
70    # Translat the name & version into the various version info definitions.
71    #
72    local s = " " ;
73    local target-suffix = [ MATCH .(.*) : $(target:S) ] ;
74    local target-tag = [ join  [ split-path $(target-dir) ] $(target:B) $(target-suffix) : "_" ] ;
75    target-tag = $(target-tag:U) ;
76    local name-tag = [ join [ split $(name:U) "\\." ] : "_" ] ;
77    local version-parts = ;
78    local t ;
79    t = [ MATCH ^(.*)\\.(.*) : $(version) ] ;
80    version-parts += $(t[1]) ;
81    t = [ MATCH ^(.*)\\.(.*)\\.* : $(version) ] ;
82    version-parts += $(t[2]) ;
83    t = [ MATCH ^(.*)\\.(.*)\\.(.*) : $(version) ] ;
84    version-parts += $(t[3]) ;
85    if ! $(version-parts[2]) { version-parts += 0 0 ; }
86    if ! $(version-parts[3]) { version-parts += 0 ; }
87    local version-id = $(version-parts[1]) ;
88    switch $(version-parts[2])
89    {
90        case ?   : version-id = $(version-id)00$(version-parts[2]) ;
91        case ??  : version-id = $(version-id)0$(version-parts[2]) ;
92        case ??? : version-id = $(version-id)$(version-parts[2]) ;
93        case *   : version-id = $(version-id)000 ;
94    }
95    switch $(version-parts[3])
96    {
97        case ?   : version-id = $(version-id)0$(version-parts[3]) ;
98        case ??  : version-id = $(version-id)$(version-parts[3]) ;
99        case *   : version-id = $(version-id)00 ;
100    }
101
102    # Set Jam variables to the version info definitions for use in things like
103    # sonaming, etc.
104    #
105    $(name:U)_VERSION ?= $(version) ;
106    $(name:U)_VERSION_MAJOR ?= $(version-parts[1]) ;
107    $(name:U)_VERSION_MINOR ?= $(version-parts[2]) ;
108    $(name:U)_VERSION_SUBMINOR ?= $(version-parts[3]) ;
109    $(name:U)_VERSION_STRING ?= $(name)$(s)$(version) ;
110
111    # Generate instructions to build the header file, but only if not in
112    # dependency stage.
113    #
114    if ! $(gIN_LIB_INCLUDE)
115    {
116        TARGET_TAG on $(target-id) =
117            $(target-tag) ;
118        VERSION($(name-tag)) on $(target-id) =
119            "$(name) $(version)"
120            $(version-parts[1]) $(version-parts[2]) $(version-parts[3])
121            $(version-id) ;
122        NOCARE $(name-tag) ;
123        NOTFILE $(name-tag) ;
124        MODE on $(target-id) = $(FILEMODE) ;
125        ALWAYS $(target-id) ;
126
127        MakeLocate $(target-id) : $(target-dir) ;
128        Clean dist-clean : $(target-id) ;
129        version-header-create $(target-id) ;
130        local comment-line-tag = COMMENT_TEXT_ ;
131        for local comment-line in $(comment-text)
132        {
133            comment-line-tag = $(comment-line-tag)% ;
134            NOCARE $(comment-line-tag) ;
135            NOTFILE $(comment-line-tag) ;
136            $(comment-line-tag) on $(target-id) = $(comment-line) ;
137            version-header-comment $(target-id) : $(comment-line-tag) ;
138        }
139        version-header-def $(target-id) : $(name-tag) ;
140    }
141
142    # Add the header to the top-level "dist" target.
143    #
144    if $($(gTOP)) = "."
145    {
146        declare-fake-targets dist : $(target-id) ;
147    }
148}
149
150# Creates initial empty version header, with correct permissions.
151#
152actions together version-header-create
153{
154    echo > $(<)
155    $(CHMOD) $(MODE) $(<)
156}
157
158# Append a single comment line to the header.
159#
160actions version-header-comment
161{
162    echo '$($(>))' >> $(<)
163}
164
165# Append the version info definitions of a single module to the header.
166#
167actions version-header-def
168{
169    echo >> $(<)
170    echo '#ifndef $(>)_VERSION_DEF' >> $(<)
171    echo '#define $(>)_VERSION_DEF' >> $(<)
172    echo '#define $(>)_VERSION_STRING "$(VERSION($(>))[1])"' >> $(<)
173    echo '#define $(>)_VERSION_MAJOR $(VERSION($(>))[2])' >> $(<)
174    echo '#define $(>)_VERSION_MINOR $(VERSION($(>))[3])' >> $(<)
175    echo '#define $(>)_VERSION_SUBMINOR $(VERSION($(>))[4])' >> $(<)
176    echo '#define $(>)_VERSION $(VERSION($(>))[5])' >> $(<)
177    echo "#endif" >> $(<)
178}
Note: See TracBrowser for help on using the repository browser.