Changeset 588 for CMT/HEAD


Ignore:
Timestamp:
Nov 27, 2011, 4:36:15 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 465

Location:
CMT/HEAD
Files:
4 added
41 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r586 r588  
     12011-11-27    <rybkin@lal.in2p3.fr> 465
     2
     3        * source/cmt_system.cxx: In function CmtSystem::remove_file, do not use
     4        custom error message
     5        * source/cmt_symbol.h: In class Symbol, add const qualifier to
     6        check_tag_used function argument, to resolve_macro_value function
     7        * source/cmt_symbol.cxx: idem, add same actions for
     8        action_build_broadcast_config as for action_build_constituents_config,
     9        action_build_constituent_config
     10        * source/cmt_use.h: In class Use, introduce absolute_library_path,
     11        remove_library_links functions
     12        * source/cmt_use.cxx: Implement introduced functions, in install_library
     13        helper function, check return value of called functions, set error (rather
     14        than print error message) as appropriate, implement uninstall_library
     15        helper function, refactor build_library_links function to use
     16        absolute_library_path
     17        * source/cmt_deps_builder.h: Make m_filter member of class
     18        DepsBuilder::HeaderFilter to be owned by class and cleared accordingly
     19        * source/cmt_deps_builder.cxx: In header_file_action, build_deps functions
     20        check return value of read function, set error as appropriate, also set
     21        error if path specified for dependencies calculation not found. In class
     22        DepsBuilder, run function, pass $(app_$(CONSTITUENT)_cppflags),
     23        $(lib_$(CONSTITUENT)_cppflags) to external dependencies generator specified
     24        via preprocessor_command macro, if any
     25        * source/cmt_generators.h: In classes DocumentGenerator, LibraryGenerator,
     26        in function build, introduce argument bool& dependencies, in class
     27        DocumentGenerator, introduce members Variable m_FILEEXTENSION,
     28        FragmentHandle dependency_fragment, in class LibraryGenerator, declare
     29        specific function fill_names_outputs. Introduce class
     30        PackagesMakefileGenerator, rewrite class DependencyGenerator
     31        * source/cmt_generators.cxx: In class LibraryGenerator, implement
     32        fill_names_outputs, in class DocumentGenerator function build, add
     33        dependency_fragment for each source file with additional template
     34        FILEEXTENSION (also added for fragment) so that
     35        ${CONSTITUENT}_dependencies.make gets rebuilt whenever source file OR its
     36        dependencies change. Implement class PackagesMakefileGenerator used to
     37        build BCAST mode Makefile. In class DependencyGenerator, re-implement
     38        function build (const CmtSystem::cmt_string_vector&) so that it makes use
     39        of files and includes from CLI input, if any, enhance its algorithm,
     40        enhance function prepare_header_file_filters so that it makes use of input
     41        file dependencies[_CONSTITUENT].in without CMT
     42        * source/cmt_generator.h: In class CmtGenerator, remove prepare_use_context
     43        function, m_deps_builder member. In class Generator, introduce argument
     44        bool& dependencies in build_constituent_makefile function, declare
     45        build_library_links_infile, build_dependencies_infile,
     46        build_packages_makefile functions
     47        * source/cmt_generator.cxx: In class CmtGenerator function reset, reset
     48        m_bin, m_output_file_name, m_output_file, m_constituent members, in class
     49        Generator, implement build_library_links_infile, build_dependencies_infile,
     50        build_packages_makefile functions, in class InGenerator constructor, add
     51        document dependency fragment
     52        * source/cmt_constituent.h: In class Constituent, change add_for_action
     53        function signature
     54        * source/cmt_constituent.cxx: In class Constituent, in function parse,
     55        do not treat action_value variable definition specially, in function
     56        add_for_action, do not assign target_<name> tag to document corresponding
     57        to action by default but only if this tag is used somewhere
     58        * source/cmt_commands.cxx: In class ArgParser, in function do_build,
     59        introduce broadcast_config command and its options processing, enhance
     60        dependencies command options processing so that it makes use of files and
     61        includes from CLI input and can have global options specified mixed with
     62        its options. In class CommandHelp, in constructor, add help info for
     63        broadcast_config, dependencies commands
     64        * source/cmt_parser.h: In enumeration ActionType, add value
     65        action_build_broadcast_config
     66        * source/cmt_parser.cxx: In class Cmt, in function do_broadcast, unset
     67        CMTBCAST variable in environment of command(s) being broadcast to avoid
     68        looping, in function do_build_constituent_config, generate dependencies
     69        infile if needed only, incorporate call to do_check_configuration into
     70        function do_build_constituents_config so as not to invoke
     71        cmt check configuration command in Makefile, as part of
     72        do_build_constituents_config, generate library_links infile, and
     73        dependencies infile for constituents without target tag, implement function
     74        do_build_broadcast_config to generate broadcast Makefile, and broadcast
     75        specific macros Makefile, enhance do_build_library_links function to work
     76        with generated library_links infile, make function do_check_configuration
     77        set error if non-constant cmtpath_pattern found for package outside CMTPATH
     78        - cannot be applied, re-implement do_remove_library_links function making
     79        use of remove_library_links from class Use. In function
     80        fill_for_all_constituents of class StandardMacroBuilder, print warning
     81        message if package requested for import cannot be imported for constituent
     82        without target tag during cmt build constituents_config, otherwise during
     83        cmt build constituent_config
     84        * source/cmt_cmtpath_pattern.h: In class CmtPathPattern, introduce function
     85        is_constant
     86        * source/cmt_cmtpath_pattern.cxx: Implement is_constant function
     87        * source/cmt.h: In class Cmt, introduce function do_build_broadcast_config
     88        * mgr/fragments/package: Introduce fragment for broadcast Makefile
     89        generation
     90        * mgr/fragments/packages_header: idem
     91        * mgr/fragments/packages_trailer: idem
     92        * mgr/fragments/dependency: Introduce fragment for document Makefile
     93        generation
     94        * mgr/fragments/dependencies: Use $(build_dependencies) command with
     95        dependencies infile and include directories and source files supplied
     96        via CLI
     97        * mgr/fragments/constituent: In QUICK mode, rebuild constituent Makefile if
     98        any requirements file changes. Make constituent uninstall targets
     99        independent of constituent Makefile (so that no rebuild happens before
     100        uninstall), make remove_library_links dependent on constituent uninstall
     101        targets to ensure library links uninstallation order
     102        * mgr/fragments/constituent_lock: idem
     103        * mgr/fragments/constituents_header:  In QUICK mode, run
     104        $(build_library_links) command with library_links infile, if any
     105        requirements file changes, keep .DEFAULT target if PEDANTIC is undefined,
     106        specify explicit (with empty command) rules for requirements files for
     107        optimisation
     108        * mgr/fragments/constituents_trailer: In QUICK mode, run
     109        $(remove_library_links) command with library_links infile,  make uninstall
     110        target (rather than clean target) dependent on remove_library_links target
     111        to ensure library links uninstallation
     112        * mgr/fragments/make_header: Define dependencies infile for use with
     113        $(build_dependencies) command
     114        * mgr/fragments/cpp: Add explicit dependency on source file to
     115        ${CONSTITUENT}_dependencies.make
     116        * mgr/fragments/cpp_library: idem
     117        * mgr/fragments/c: idem
     118        * mgr/fragments/c_library: idem
     119        * mgr/fragments/fortran: idem
     120        * mgr/fragments/fortran_library: idem
     121        * mgr/fragments/lex: idem
     122        * mgr/fragments/lex_library: idem
     123        * mgr/fragments/yacc: idem
     124        * mgr/fragments/yacc_library: idem
     125        * mgr/requirements: Declare fragments package, packages_header,
     126        packages_trailer, dependency
     127        * src/Makefile.core: Add .in to known suffixes
     128        * src/Makefile.header: Introduce and implement BCAST mode, making use of
     129        cmt build broadcast_config command. In QUICK mode, rebuild constituents or
     130        broadcast Makefile and corresponding macros files if any requirements file
     131        changes, specify explicit (with empty command) rules for requirements files
     132        for optimisation, implement dynamic help messages on targets available for
     133        BCAST mode
     134        * src/setup.csh: Set MAKEFLAGS, if unset, to set number of job slots to
     135        number of processors, and enable CMT QUICK mode
     136        * src/setup.sh: idem. Use only shell parameter expansion to determine
     137        whether shell is intercative.
     138
    11392011-07-06    <rybkin@lal.in2p3.fr> 464
    2140
  • CMT/HEAD/mgr/fragments/c

    r487 r588  
    2020$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
    2121
     22$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
     23
    2224$(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
    2325endif
  • CMT/HEAD/mgr/fragments/c_library

    r487 r588  
    2020$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
    2121
     22$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
     23
    2224$(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
    2325endif
  • CMT/HEAD/mgr/fragments/constituent

    r561 r588  
    4444endif
    4545
     46not_${CONSTITUENT}_dependencies = { n=0; for p in $?; do m=0; for d in $(${CONSTITUENT}_dependencies); do if [ $$p = $$d ]; then m=1; break; fi; done; if [ $$m -eq 0 ]; then n=1; break; fi; done; [ $$n -eq 1 ]; }
     47
    4648ifdef STRUCTURED_OUTPUT
    4749${CONSTITUENT}dirs :
     
    7375          $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
    7476else
    75 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
    76         if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
    77           [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     77$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(use_requirements)
     78        @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
     79          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \
     80          $(not_${CONSTITUENT}_dependencies) ; then \
    7881          test -z "$(cmtmsg)" || \
    7982          echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \
     
    8992          $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
    9093else
    91 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
    92         if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
    93           [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     94$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(bin)${CONSTITUENT}.in
     95        @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
     96          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \
     97          $(not_${CONSTITUENT}_dependencies) ; then \
    9498          test -z "$(cmtmsg)" || \
    9599          echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \
     
    104108${CONSTITUENT} :: $(${CONSTITUENT}_dependencies) $(cmt_local_${CONSTITUENT}_makefile) dirs ${CONSTITUENT}dirs
    105109        $(echo) "(constituents.make) Starting ${CONSTITUENT}"
    106         @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
     110        @if test -f $(cmt_local_${CONSTITUENT}_makefile); then \
     111          $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \
     112          fi
     113#       @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
    107114        $(echo) "(constituents.make) ${CONSTITUENT} done"
    108115
     
    126133        $(echo) "(constituents.make) install ${CONSTITUENT} done"
    127134
    128 uninstall :: ${CONSTITUENT}uninstall
     135uninstall : ${CONSTITUENT}uninstall
    129136
    130137$(foreach d,$(${CONSTITUENT}_dependencies),$(eval $(d)uninstall_dependencies += ${CONSTITUENT}uninstall))
    131138
    132 ${CONSTITUENT}uninstall :: $(${CONSTITUENT}uninstall_dependencies) $(cmt_local_${CONSTITUENT}_makefile)
     139${CONSTITUENT}uninstall : $(${CONSTITUENT}uninstall_dependencies) ##$(cmt_local_${CONSTITUENT}_makefile)
    133140        $(echo) "(constituents.make) Starting uninstall ${CONSTITUENT}"
    134         @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall
     141        @if test -f $(cmt_local_${CONSTITUENT}_makefile); then \
     142          $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall; \
     143          fi
     144#       @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall
    135145        $(echo) "(constituents.make) uninstall ${CONSTITUENT} done"
     146
     147remove_library_links :: ${CONSTITUENT}uninstall
    136148
    137149ifndef PEDANTIC
  • CMT/HEAD/mgr/fragments/constituent_lock

    r561 r588  
    4444endif
    4545
     46not_${CONSTITUENT}_dependencies = { n=0; for p in $?; do m=0; for d in $(${CONSTITUENT}_dependencies); do if [ $$p = $$d ]; then m=1; break; fi; done; if [ $$m -eq 0 ]; then n=1; break; fi; done; [ $$n -eq 1 ]; }
     47
    4648ifdef STRUCTURED_OUTPUT
    4749${CONSTITUENT}dirs :
     
    7375          $(cmtexe) -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_config -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
    7476else
    75 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
    76         if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
    77           [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     77$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(use_requirements)
     78        @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
     79          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \
     80          $(not_${CONSTITUENT}_dependencies) ; then \
    7881          test -z "$(cmtmsg)" || \
    7982          echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \
     
    8992          $(cmtexe) -f=$(bin)${CONSTITUENT}.in -tag=$(tags) $(${CONSTITUENT}_extratags) build constituent_makefile -without_cmt -out=$(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}
    9093else
    91 $(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies)
    92         if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
    93           [ ! -f $(cmt_final_setup_${CONSTITUENT}) ]; then \
     94$(cmt_local_${CONSTITUENT}_makefile) : $(${CONSTITUENT}_dependencies) $(cmt_build_library_linksstamp) $(bin)${CONSTITUENT}.in
     95        @if [ ! -f $@ ] || [ ! -f $(cmt_local_tagfile_${CONSTITUENT}) ] || \
     96          [ ! -f $(cmt_final_setup_${CONSTITUENT}) ] || \
     97          $(not_${CONSTITUENT}_dependencies) ; then \
    9498          test -z "$(cmtmsg)" || \
    9599          echo "$(CMTMSGPREFIX)" "(constituents.make) Building ${CONSTITUENT}.make"; \
     
    107111          retval=$$?; \
    108112          trap '${unlock_command} ${CONSTITUENT}${lock_suffix}; exit $${retval}' 1 2 15; \
     113          if test -f $(cmt_local_${CONSTITUENT}_makefile); then \
    109114          $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) ${CONSTITUENT}; \
     115          fi; \
    110116          retval=$$?; ${unlock_command} ${CONSTITUENT}${lock_suffix}; exit $${retval}
    111117        $(echo) "(constituents.make) ${CONSTITUENT} done"
     
    130136        $(echo) "(constituents.make) install ${CONSTITUENT} done"
    131137
    132 uninstall :: ${CONSTITUENT}uninstall
     138uninstall : ${CONSTITUENT}uninstall
    133139
    134140$(foreach d,$(${CONSTITUENT}_dependencies),$(eval $(d)uninstall_dependencies += ${CONSTITUENT}uninstall))
    135141
    136 ${CONSTITUENT}uninstall :: $(${CONSTITUENT}uninstall_dependencies) $(cmt_local_${CONSTITUENT}_makefile)
     142${CONSTITUENT}uninstall : $(${CONSTITUENT}uninstall_dependencies) ##$(cmt_local_${CONSTITUENT}_makefile)
    137143        $(echo) "(constituents.make) Starting uninstall ${CONSTITUENT}"
    138         @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall
     144        @if test -f $(cmt_local_${CONSTITUENT}_makefile); then \
     145          $(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall; \
     146          fi
     147#       @$(MAKE) -f $(cmt_local_${CONSTITUENT}_makefile) uninstall
    139148        $(echo) "(constituents.make) uninstall ${CONSTITUENT} done"
     149
     150remove_library_links :: ${CONSTITUENT}uninstall
    140151
    141152ifndef PEDANTIC
  • CMT/HEAD/mgr/fragments/constituents_header

    r488 r588  
    2626#cmt_final_setup = $(bin)$(package)setup.make
    2727
     28cmt_build_library_linksstamp = $(bin)cmt_build_library_links.stamp
    2829#--------------------------------------------------------
    2930
     
    7374
    7475ifndef QUICK
    75 all :: build_library_links
    76         $(echo) "(constituents.make) all done"
     76all :: build_library_links ;
     77else
     78all :: $(cmt_build_library_linksstamp) ;
    7779endif
    7880
     
    8890#         if test ! -d $(bin) ; then $(mkdir) -p $(bin) ; fi
    8991
    90 requirements :
    91         @if test ! -r requirements ; then echo "No requirements file" ; fi
     92#requirements :
     93#       @if test ! -r requirements ; then echo "No requirements file" ; fi
    9294
    9395build_library_links : dirs
     
    9799#       $(build_library_links)
    98100
     101$(cmt_build_library_linksstamp) : $(cmt_final_setup) $(cmt_local_tagfile) $(bin)library_links.in
     102        $(echo) "(constituents.make) Rebuilding library links"; \
     103         $(build_library_links) -f=$(bin)library_links.in -without_cmt
     104        $(silent) \touch $@
     105
    99106makefiles : ;
    100107
     108ifndef PEDANTIC
    101109.DEFAULT ::
     110#.DEFAULT :
    102111        $(echo) "(constituents.make) $@: No rule for such target" >&2
    103 #       @echo "#CMT> Warning: $@: Using default commands" >&2; exit
     112endif
    104113
    105 #       @if test "$@" = "$(cmt_lock_setup)"; then \
    106         #  /bin/rm -f $(cmt_lock_setup); \
    107          # touch $(cmt_lock_setup); \
    108         #fi
     114${CMTROOT}/src/Makefile.core : ;
     115ifdef use_requirements
     116$(use_requirements) : ;
     117endif
    109118
    110119#-- end of constituents_header ------
  • CMT/HEAD/mgr/fragments/constituents_trailer

    r487 r588  
    11#-- start of constituents_trailer ------
    22
    3 clean :: remove_library_links
     3uninstall : remove_library_links ;
     4clean ::
     5        $(cleanup_echo) $(cmt_build_library_linksstamp)
     6        -$(cleanup_silent) \rm -f $(cmt_build_library_linksstamp)
     7#clean :: remove_library_links
    48
    59remove_library_links ::
     10ifndef QUICK
    611        $(echo) "(constituents.make) Removing library links"; \
    712          $(remove_library_links)
     13else
     14        $(echo) "(constituents.make) Removing library links"; \
     15          $(remove_library_links) -f=$(bin)library_links.in -without_cmt
     16endif
    817
    918makefilesclean ::
     
    1524clean :: makefilesclean
    1625
    17 binclean :: clean
    18         $(echo) "(constituents.make) Removing binary directory $(bin)"
    19         @if test ! "$(bin)" = "./"; then \
    20           /bin/rm -rf $(bin); \
    21         fi
    22 
    2326#-- end of constituents_trailer ------
  • CMT/HEAD/mgr/fragments/cpp

    r487 r588  
    2020$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
    2121
     22$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
     23
    2224$(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
    2325endif
  • CMT/HEAD/mgr/fragments/cpp_library

    r487 r588  
    2020$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
    2121
     22$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
     23
    2224$(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
    2325endif
  • CMT/HEAD/mgr/fragments/dependencies

    r548 r588  
    1 #-- start of dependency ------------------
     1#-- start of dependencies ------------------
    22ifneq ($(MAKECMDGOALS),${CONSTITUENT}clean)
    33ifneq ($(MAKECMDGOALS),uninstall)
    44
    5 #$(bin)${CONSTITUENT}_dependencies.make :: dirs
    6 
    7 ifndef QUICK
    8 $(bin)${CONSTITUENT}_dependencies.make : ${LINE} $(use_requirements) $(cmt_final_setup_${CONSTITUENT})
    9 else
    10 $(bin)${CONSTITUENT}_dependencies.make :
    11 endif
     5$(bin)${CONSTITUENT}_dependencies.make : $(use_requirements) $(cmt_final_setup_${CONSTITUENT})
    126        $(echo) "(${CONSTITUENT}.make) Rebuilding $@"; \
    13           $(build_dependencies) ${CONSTITUENT} -all_sources -out=$@ ${LINE}
    14 
    15 #$(${CONSTITUENT}_dependencies)
     7          $(build_dependencies) -out=$@ -start_all ${LINE} -end_all $(includes) $(app_${CONSTITUENT}_cppflags) $(lib_${CONSTITUENT}_cppflags) ${CONSTITUENT} $? -f=$(cmt_dependencies_in_${CONSTITUENT}) -without_cmt
    168
    179-include $(bin)${CONSTITUENT}_dependencies.make
     
    1911endif
    2012endif
    21 #-- end of dependency -------------------
     13#-- end of dependencies -------------------
  • CMT/HEAD/mgr/fragments/fortran

    r469 r588  
    22
    33$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
     4
     5$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
    46 
    57$(bin)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
  • CMT/HEAD/mgr/fragments/fortran_library

    r469 r588  
    22
    33$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
     4
     5$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
    46 
    57$(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
  • CMT/HEAD/mgr/fragments/lex

    r436 r588  
    22
    33$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
     4
     5$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
    46
    57$(bin)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
  • CMT/HEAD/mgr/fragments/lex_library

    r436 r588  
    22
    33$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
     4
     5$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
    46
    57$(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
  • CMT/HEAD/mgr/fragments/make_header

    r487 r588  
    4646
    4747cmt_final_setup_${CONSTITUENT} = $(bin)setup_${CONSTITUENT}.make
     48cmt_dependencies_in_${CONSTITUENT} = $(bin)dependencies_${CONSTITUENT}.in
    4849#cmt_final_setup_${CONSTITUENT} = $(bin)${PACKAGE}_${CONSTITUENT}setup.make
    4950cmt_local_${CONSTITUENT}_makefile = $(bin)${CONSTITUENT}.make
     
    5253
    5354cmt_final_setup_${CONSTITUENT} = $(bin)setup.make
     55cmt_dependencies_in_${CONSTITUENT} = $(bin)dependencies.in
    5456#cmt_final_setup_${CONSTITUENT} = $(bin)${PACKAGE}setup.make
    5557cmt_local_${CONSTITUENT}_makefile = $(bin)${CONSTITUENT}.make
     
    8385endif
    8486
     87${CMTROOT}/src/Makefile.core : ;
    8588ifdef use_requirements
    8689$(use_requirements) : ;
  • CMT/HEAD/mgr/fragments/yacc

    r436 r588  
    22
    33$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
     4
     5$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
    46
    57$(bin)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
  • CMT/HEAD/mgr/fragments/yacc_library

    r436 r588  
    22
    33$(bin)${CONSTITUENT}_dependencies.make : $(${NAME}_${FILESUFFIX}_dependencies)
     4
     5$(bin)${CONSTITUENT}_dependencies.make : ${FULLNAME}
    46
    57$(bin)$(binobj)${NAME}${CONSTITUENTSUFFIX}.o : $(${NAME}_${FILESUFFIX}_dependencies)
  • CMT/HEAD/mgr/requirements

    r561 r588  
    588588make_fragment constituents_trailer
    589589
     590make_fragment packages_header
     591make_fragment package
     592make_fragment packages_trailer
     593
    590594make_fragment dependencies
    591595make_fragment dependencies_and_triggers
     596make_fragment dependency
    592597
    593598make_fragment readme_header
  • CMT/HEAD/source/cmt.h

    r565 r588  
    111111  static void do_build_constituents_makefile (const ArgParser& ap);
    112112  static void do_build_constituents_config (const ArgParser& ap);
     113  static void do_build_broadcast_config (const ArgParser& ap);
    113114  static void do_build_dependencies (const ArgParser& ap,
    114115                                     int argc,
  • CMT/HEAD/source/cmt_cmtpath_pattern.cxx

    r400 r588  
    278278}
    279279
     280bool CmtPathPattern::is_constant () const
     281{
     282  return ((line.find ("<path>") == cmt_string::npos) &&
     283          (line.find ("<project>") == cmt_string::npos));
     284}
  • CMT/HEAD/source/cmt_cmtpath_pattern.h

    r283 r588  
    3535  void apply () const;
    3636  void expand (cmt_string& line, const cmt_string& path, const cmt_string& project) const;
     37  bool is_constant () const;
    3738
    3839  cmt_string line;
  • CMT/HEAD/source/cmt_commands.cxx

    r568 r588  
    694694            }
    695695        }
     696      else if (arg == "broadcast_config")
     697        {
     698          cmt.m_action = action_build_broadcast_config;
     699
     700          if (cmt.m_scope_filtering_mode == default_filtering_mode)
     701            {
     702              cmt.m_scope_filtering_mode = reach_private_uses;
     703            }
     704
     705          while (argc > 0)
     706            {
     707              cmt_string arg(argv[0]);
     708              if (arg.substr (0, 5) == "-out=")
     709                {
     710                  fill_one_argument ();
     711                }
     712              else
     713                {
     714                  help_action = action_help;
     715                  CmtError::set (CmtError::syntax_error, arg + ": wrong argument");
     716                  break;
     717                }
     718            }
     719        }
    696720      else if (arg == "dependencies")
    697721        {
    698722          if (argc > 0)
    699723            {
    700               fill_arguments ();
     724              //              fill_arguments ();
     725              while (argc > 0)
     726                {
     727                  cmt_string arg(argv[0]);
     728                  if (arg.substr (0, 3) == "-f=")
     729                    {
     730                      shift ();
     731                      extra_file = arg.substr (3);
     732                    }
     733                  else if (arg.substr (0, 3) == "-e=")
     734                    {
     735                      shift ();
     736                      extra_line = arg.substr (3);
     737                    }
     738                  else if (arg == "-with_cmt")
     739                    {
     740                      shift ();
     741                      cmt.m_use_cmt = true;
     742                    }
     743                  else if (arg == "-without_cmt")
     744                    {
     745                      shift ();
     746                      cmt.m_use_cmt = false;
     747                    }
     748                  else
     749                    {
     750                      fill_one_argument ();
     751                    }
     752                } 
    701753              cmt.m_action = action_build_dependencies;
    702754            }
    703755          else
    704756            {
    705               CmtMessage::error ("syntax: arguments missing");
     757              //CmtMessage::error ("syntax: arguments missing");
    706758              //              if (!cmt.m_quiet) cerr << "#CMT> syntax error : arguments missing " << endl;
     759              CmtError::set (CmtError::syntax_error, "arguments missing");
    707760              help_action = action_help;
    708761              cmt.m_action = action_build_dependencies;
     
    23092362void CommandHelp::show (ActionType action)
    23102363{
    2311   //cerr << "CommandHelp::show> action = " << action << endl;
     2364  //  cerr << "CommandHelp::show> action = " << action << endl;
    23122365
    23132366  static HelpTexts& help_texts = get_help_texts ();
     
    23752428  help_texts.add () =  "build constituents_makefile [-out=<path>] : generate constituents Makefile";
    23762429  help_texts.add () =  "build constituents_config [-out=<path>] [-with_cmt] [-without_cmt] : generate constituents Makefile, tag specific Makefile, and setup definitions file, also input requirements file for constituent(s) without associated tag";
    2377   help_texts.add () =  "build dependencies      : generate dependencies";
     2430  help_texts.add () =  "build broadcast_config [-out=<path>] : generate broadcast Makefile, and broadcast specific macros Makefile";
     2431  help_texts.add () =  "build dependencies [-out=<path>] [-all_sources] [-no_stamps] [-I<directory>]... [-start_all FILE... -end_all] NAME FILE... : generate dependencies for FILEs of constituent NAME";
    23782432  help_texts.add () =  "build library_links     : build symbolic links towards all imported libraries";
    23792433  help_texts.add () =  "build make_setup        : build a compiled version of setup scripts";
     
    24772531  help.add (action_build_constituents_makefile, help_texts[action_build_constituents_makefile]);
    24782532  help.add (action_build_constituents_config, help_texts[action_build_constituents_config]);
     2533  help.add (action_build_broadcast_config, help_texts[action_build_broadcast_config]);
    24792534  help.add (action_build_dependencies, help_texts[action_build_dependencies]);
    24802535  help.add (action_build_library_links, help_texts[action_build_library_links]);
  • CMT/HEAD/source/cmt_constituent.cxx

    r561 r588  
    4747      if (symbol.type != Symbol::SymbolAction) continue;
    4848
     49      /*
    4950      if (symbol.value_lists.size () < 1) continue;
    5051
     
    5556          add_for_action (symbol.name);
    5657        }
     58      */
     59      add_for_action (symbol);
    5760    }
    5861
     
    368371      //cerr << "Constituent " << name << " Analyzing module " << ew << endl;
    369372
    370       if (ew.substr (0, 13) == "action_value=")
    371         {
    372           it.set (ew);
    373         }
    374       else
    375         {
     373//       if (ew.substr (0, 13) == "action_value=")
     374//      {
     375//           it.set (ew);
     376//      }
     377//       else
     378//      {
    376379          CmtSystem::split (ew, " \t", ws);
    377380
     
    383386              it.set (w);
    384387            }
    385         }
     388//      }
    386389    }
    387390
     
    417420
    418421//----------------------------------------------------------
    419 Constituent* Constituent::add_for_action (const cmt_string& name)
    420 {
    421   Constituent* constituent;
    422 
    423   constituent = add (Document, name, "cmt_action_runner");
     422Constituent* Constituent::add_for_action (const Symbol& symbol)
     423//Constituent* Constituent::add_for_action (const cmt_string& name)
     424{
     425  Constituent* constituent (0);
     426  if (symbol.value_lists.size () < 1) return constituent;
     427
     428  const Tag* tag = Tag::find ("target_" + symbol.name);
     429  const bool target_tag_used
     430    (Tag::check_tag_used (tag) || Symbol::check_tag_used (tag));
     431
     432  cmt_string value = symbol.build_macro_value ();
     433  if ( "" == value && !target_tag_used) return constituent;
     434
     435  constituent = add (Document, symbol.name, "cmt_action_runner");
    424436
    425437  constituent->group = Group::add ("cmt_actions");
    426   constituent->has_target_tag = true;
     438
     439  // Do NOT assign target_<name> by default
     440  // but only if this tag is used somewhere
     441  if (target_tag_used)
     442    constituent->has_target_tag = true;
    427443
    428444  cmt_string& p1 = constituent->parameters.add ();
    429445  p1 = "action_value=";
    430   p1 += "$(";
    431   p1 += name;
    432   p1 += ")";
     446  Symbol::expand (value);
     447  // quote since split will later be applied
     448  // - in parse
     449  p1 += CmtSystem::quote (value, " \t");
     450//   p1 += "$(";
     451//   p1 += symbol.name;
     452//   p1 += ")";
    433453
    434454  return (constituent);
     
    549569  if (!simulation)
    550570    {
    551       Generator::build_constituent_makefile (*this);
     571      bool dependencies (false);
     572      Generator::build_constituent_makefile (*this, dependencies);
    552573    }
    553574}
  • CMT/HEAD/source/cmt_constituent.h

    r561 r588  
    2323                           const cmt_string& name,
    2424                           const cmt_string& generator);
    25   static Constituent* add_for_action (const cmt_string& name);
     25  static Constituent* add_for_action (const Symbol& action);
     26  //static Constituent* add_for_action (const cmt_string& name);
    2627  static void show (const cmt_string& name);
    2728  static void parse_all ();
  • CMT/HEAD/source/cmt_deps_builder.cxx

    r427 r588  
    1111#include "cmt_symbol.h"
    1212#include "cmt_log.h"
     13#include "cmt_error.h"
    1314
    1415//
     
    9293        {
    9394          cmt_string stamp_file;
     95          log << "|header_file_action> header " << header_file_path << " against stamp " << stamp_file << log_endl;
    9496          if (header_filters[i].use_stamp (header_file_path, stamp_file))
    9597            {
     
    113115///////////////////////////////////////////////////////////////////////////////////////////////////////
    114116  cmt_string text;
    115   text.read (header_file_path);
     117  if (!text.read (header_file_path))
     118    {
     119      CmtError::set (CmtError::file_access_error, header_file_path);
     120      return;
     121    }
    116122  char* ptr = &text[0];
    117123  cmt_string new_dir;
     
    725731    {
    726732      cmt_string text;
    727       text.read (full_name);
     733      if (!text.read (full_name))
     734        {
     735          CmtError::set (CmtError::file_access_error, full_name);
     736          return -2;
     737        }
    728738      char* ptr = &text[0];
    729739      cmt_string new_dir;
     
    746756    {
    747757      log << "CMT> build_deps3" << log_endl;
     758      CmtError::set (CmtError::path_not_found, name);
    748759    }
    749760  return path_index;
     
    811822
    812823//--------------------------------------------------------------------------
     824DepsBuilder::DepsBuilder ()
     825{ }
     826
     827//--------------------------------------------------------------------------
     828DepsBuilder::~DepsBuilder ()
     829{
     830  clear ();
     831}
     832
     833//--------------------------------------------------------------------------
    813834void DepsBuilder::clear ()
    814835{
     
    820841    }
    821842  m_header_filters.clear ();
     843  m_deps.clear ();
     844  m_all_deps.clear ();
    822845}
    823846
     
    829852      return;
    830853    }
     854
     855  cmt_string p = path;
    831856  if (path[path.size () - 1] == CmtSystem::file_separator ())
    832857    {
    833       cmt_string p = path;
    834       p.erase (path.size () - 1);
    835       m_include_paths.push_back (p);
    836     }
    837   else
    838     {
    839       m_include_paths.push_back (path);
    840     }
    841 
     858      p = path.substr(0, path.size () - 1);
     859    }
     860  for (int k = m_include_paths.size () - 1; k >= 0; k--)
     861    if (m_include_paths[k] == p)
     862      {
     863        return;
     864      }
     865 
     866  m_include_paths.push_back (p);
    842867  m_substitutions.push_back (substitution);
    843868}
     
    919944
    920945//--------------------------------------------------------------------------
    921 CmtSystem::cmt_string_vector& DepsBuilder::run (const cmt_string& file_name)
     946CmtSystem::cmt_string_vector& DepsBuilder::run (const cmt_string& file_name,
     947                                                const cmt_string& constituent_name)
    922948{
    923949  Log;
    924950
    925951  log << "Starting deps builder on " << file_name << log_endl;
     952  CmtMessage::info ("calculating dependencies for " + file_name);
    926953
    927954  m_deps.clear ();
     
    9741001      // missing)
    9751002      //
    976       preprocessor += " ";
    9771003      macro = Symbol::find ("includes");
    978       preprocessor += macro->resolve_macro_value ();
     1004      if (0 != macro)
     1005        {
     1006          preprocessor += " ";
     1007          preprocessor += macro->resolve_macro_value ();
     1008        }
     1009      macro = Symbol::find ("app_" + constituent_name + "_cppflags");
     1010      if (0 != macro)
     1011        {
     1012          preprocessor += " ";
     1013          preprocessor += macro->resolve_macro_value ();
     1014        }
     1015      macro = Symbol::find ("lib_" + constituent_name + "_cppflags");
     1016      if (0 != macro)
     1017        {
     1018          preprocessor += " ";
     1019          preprocessor += macro->resolve_macro_value ();
     1020        }
     1021     
    9791022      preprocessor += " ";
    9801023      preprocessor += file_name;
     
    9821025      cmt_string output;
    9831026     
    984       CmtSystem::execute (preprocessor, output);
     1027      int status = CmtSystem::execute (preprocessor, output);
     1028      if (0 != status)
     1029        {
     1030          CmtError::set (CmtError::execution_failed, preprocessor, status);
     1031          return m_deps;
     1032        }
    9851033
    9861034      //
     
    10411089
    10421090//--------------------------------------------------------------------------
    1043 void DepsBuilder::add_header_filter (const Use* use, const cmt_regexp* filter, const cmt_string& stamp)
     1091void DepsBuilder::add_header_filter (const Use* use, cmt_regexp* filter, const cmt_string& stamp)
    10441092{
    10451093  add_header_filter (HeaderFilter (use, filter, stamp));
  • CMT/HEAD/source/cmt_deps_builder.h

    r427 r588  
    2323      : m_use (0), m_filter (0) { }
    2424
    25     HeaderFilter (const Use* use, const cmt_regexp* filter, const cmt_string& stamp)
     25    HeaderFilter (const Use* use, cmt_regexp* filter, const cmt_string& stamp)
    2626      : m_use (use), m_filter (filter), m_stamp (stamp) { }
    2727
     
    3838      {
    3939        m_use = 0;
    40         if (m_filter) delete m_filter;
     40        if (m_filter)
     41          {
     42            m_filter->clear ();
     43            delete m_filter;
     44          }
    4145        m_filter = 0;
    4246        m_stamp = cmt_string ();
     
    4650
    4751    const Use* m_use;
    48     const cmt_regexp* m_filter;
     52    cmt_regexp* m_filter;
    4953    cmt_string m_stamp;
    5054  };
     
    5559  void add (const cmt_string& path, const cmt_string& substitution);
    5660  void add_includes (const Use& use);
    57   void add_header_filter (const Use* use, const cmt_regexp* filter, const cmt_string& stamp);
     61  void add_header_filter (const Use* use, cmt_regexp* filter, const cmt_string& stamp);
    5862  void add_header_filter (const HeaderFilter& hf);
    59   CmtSystem::cmt_string_vector& run (const cmt_string& file_name);
     63  CmtSystem::cmt_string_vector& run (const cmt_string& file_name,
     64                                     const cmt_string& constituent_name);
    6065
    61   DepsBuilder ()
    62     { }
     66  DepsBuilder ();
     67  ~DepsBuilder ();
    6368
    6469private:
    6570
    66   DepsBuilder (const DepsBuilder&)
    67     { }
     71  DepsBuilder (const DepsBuilder&);
     72  DepsBuilder& operator = (const DepsBuilder&);
    6873
    6974  CmtSystem::cmt_string_vector m_include_paths;
    7075  CmtSystem::cmt_string_vector m_substitutions;
    7176  HeaderFilters m_header_filters;
    72 
    7377  CmtSystem::cmt_string_vector m_deps;
    7478  CmtSystem::cmt_string_vector m_all_deps;
  • CMT/HEAD/source/cmt_generator.cxx

    r561 r588  
    1919#include "cmt_log.h"
    2020#include "cmt_error.h"
     21
     22#include "cmt_install_area.h"
    2123
    2224//------------------------------------------------------------------------
     
    143145
    144146  m_source_files.clear ();
     147  m_bin = "";
     148  m_output_file_name = "";
     149  m_output_file = 0;
     150  m_constituent = 0;
    145151
    146152  Language::setup_all_fragments ();
     
    350356      if (Cmt::get_debug ())
    351357        {
    352           cout << "CmtGenerator::fill_names_ outputs>" << endl;
     358          cout << "CmtGenerator::fill_names_outputs>" << endl;
    353359          cout << "name=" << name << " LINE=" << m_LINE << endl;
    354360          cout << "output=" << output << " OBJS=" << m_OBJS << endl;
     
    399405}
    400406
     407/*
    401408//--------------------------------------------------
    402409void CmtGenerator::prepare_use_context ()
     
    476483    }
    477484}
    478 
     485*/
    479486//--------------------------------------------------
    480487void CmtGenerator::filter_path (cmt_string& text)
     
    700707static MakeSetupGenerator MakeSetupContext;
    701708static ConstituentsMakefileGenerator ConstituentsMakefileContext;
     709static PackagesMakefileGenerator PackagesMakefileContext;
    702710static DependencyGenerator DependencyContext;
    703711
     
    813821
    814822//--------------------------------------------------
     823int Generator::build_library_links_infile (const cmt_string& outdir)
     824{
     825#ifndef WIN32
     826  cmt_string file ("library_links.in");
     827  if (outdir != "")
     828    {
     829      if (outdir [outdir.size () - 1] != CmtSystem::file_separator ())
     830        file = outdir + CmtSystem::file_separator () + file;
     831      else
     832        file = outdir + file;
     833    }
     834
     835  bool wrote (false);
     836  ostringstream ls;
     837
     838  Use::UsePtrVector& Uses = Use::get_ordered_uses ();
     839  Use& current_use = Use::current ();
     840  Use::UsePtrVector uses (Uses);
     841  uses.push_back (&Use::current ());
     842
     843  cmt_string shlibsuffix;
     844  {
     845    Symbol* macro = Symbol::find ("shlibsuffix");
     846    if (macro == 0)
     847      {
     848        CmtError::set(CmtError::configuration_error, "shlibsuffix undefined");
     849        return -1;
     850      }
     851    shlibsuffix = macro->build_macro_value ();
     852    Symbol::expand (shlibsuffix);
     853  }
     854
     855  for (int i = 0; i < uses.size (); i++)
     856    {
     857      Use* use = uses[i];
     858
     859      if (use == 0) continue;
     860      if (use->discarded) continue;
     861      if (use->m_hidden) continue;
     862
     863      if (use->get_package_name () == "CMT") continue;
     864      if (!use->located ()) continue;
     865      //use->remove_library_links (cmtinstallarea, tag, shlibsuffix, symunlinkcmd);
     866      cmt_string s (use->get_package_name ());
     867      s += "_libraries";
     868      const Symbol* libraries_macro = Symbol::find (s);
     869      if (libraries_macro == 0) continue;
     870      cmt_string libraries = libraries_macro->build_macro_value ();
     871      Symbol::expand (libraries);
     872      static CmtSystem::cmt_string_vector values;
     873     
     874      CmtSystem::split (libraries, " \t", values);
     875     
     876      for (int j = 0; j < values.size (); j++)
     877        {
     878          const cmt_string& library = values[j];
     879         
     880          static cmt_string libname;
     881          static cmt_string name;
     882         
     883          // Is it a simple name or a complete path?
     884         
     885          libname = library;
     886          Symbol::expand (libname);
     887          if (0 == libname.size ()) continue;
     888         
     889          CmtSystem::cmt_string_vector paths;
     890          use->absolute_library_path (libname,
     891                                      shlibsuffix,
     892                                      paths);
     893          for (int k = 0; k < paths.size (); k++)
     894            {
     895              cmt_string path (paths[k]);
     896              Symbol::expand (path);
     897              if (0 == path.size ()) continue;
     898              if (wrote) ls << " ";
     899              else wrote = true;
     900              ls << CmtSystem::quote (path, " \t");
     901            }
     902        }
     903    }
     904  ostringstream os;
     905  if (wrote)
     906    {
     907      os << "macro ";
     908      os << current_use.get_package_name () + "_libraries ";
     909      os << CmtSystem::quote (ls.str ().c_str (), " \t");
     910      os << "\n";
     911
     912      os << "macro shlibsuffix ";
     913      os << CmtSystem::quote (shlibsuffix, " \t");
     914      os << "\n";
     915
     916      cmt_string symlinkcmd;
     917      {
     918        Symbol* macro = Symbol::find ("library_install_command");
     919        if (macro != 0)
     920          {
     921            symlinkcmd = macro->build_macro_value ();
     922            Symbol::expand (symlinkcmd);
     923          }
     924      }
     925      os << "macro library_install_command ";
     926      os << CmtSystem::quote (symlinkcmd, " \t");
     927      os << "\n";
     928
     929      cmt_string symunlinkcmd;
     930      {
     931        Symbol* macro = Symbol::find ("symunlink");
     932        if (macro != 0)
     933          {
     934            symunlinkcmd = macro->build_macro_value ();
     935            Symbol::expand (symunlinkcmd);
     936          }
     937      }
     938      os << "macro symunlink ";
     939      os << CmtSystem::quote (symunlinkcmd, " \t");
     940      os << "\n";
     941
     942      if (current_use.get_strategy ("InstallArea"))
     943        {
     944          os << "build_strategy with_installarea\n";
     945
     946          const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
     947         
     948          cmt_string cmtinstallarea = ia_mgr.get_installarea ();
     949          {
     950            Symbol* symbol = Symbol::find ("CMTINSTALLAREA");
     951            if (symbol != 0)
     952              {
     953                cmtinstallarea = symbol->build_macro_value ();
     954                Symbol::expand (cmtinstallarea);
     955              }
     956          }
     957          os << "macro CMTINSTALLAREA ";
     958          os << CmtSystem::quote (cmtinstallarea, " \t");
     959          os << "\n";
     960
     961          cmt_string tag;
     962          {
     963            Symbol* macro = Symbol::find ("tag");
     964            if (macro != 0)
     965              {
     966                tag = macro->build_macro_value ();
     967                Symbol::expand (tag);
     968              }
     969          }
     970          os << "macro tag ";
     971          os << CmtSystem::quote (tag, " \t");
     972          os << "\n";
     973        }
     974      //      cerr << os.str ();
     975    }
     976
     977  // Write input requirements file
     978
     979  //  static InGenerator InGen (usecmt);
     980
     981  bool gen (true);
     982  //  ostringstream os;
     983  ofstream s;
     984  //  s.open (file);
     985  s.open (file, ios::in);
     986  if (s) // file already exists
     987    {
     988      //      InGen.build (constituent, os);
     989      ostringstream osn;
     990      osn << s.rdbuf ();
     991      if (os.str () == osn.str ())
     992        {
     993          //      cerr << file << " up-to-date" << endl;
     994          gen = false;
     995        }
     996    }
     997  s.clear ();
     998  s.close ();
     999  s.clear ();
     1000  if (gen)
     1001    {
     1002      s.open (file);
     1003      if (!s)
     1004        {
     1005          CmtError::set (CmtError::file_access_error, file);
     1006          return -1;
     1007        }
     1008      s.exceptions (ios::failbit | ios::badbit);
     1009      try
     1010        {
     1011          //      if (os.str ().size () != 0)
     1012          //        {
     1013              //  cerr << file << " contents already generated" << endl;
     1014              s << os.str ();
     1015              //            }
     1016              //          else
     1017              //            {
     1018              //              InGen.build (constituent, s);
     1019              //            }
     1020          s.close (); // ios_base::failbit
     1021        }
     1022      catch (const ios::failure& e)
     1023        {
     1024          CmtSystem::close_ostream (NULL, file + ": " + cmt_string (e.what ()));
     1025          return -1;
     1026        }
     1027    }
     1028
     1029#endif
     1030  return 0;
     1031}
     1032
     1033//--------------------------------------------------
     1034int Generator::build_dependencies_infile (const Constituent* pconstituent,
     1035                                          const cmt_string& outdir,
     1036                                          bool usecmt)
     1037{
     1038  cmt_string file ("dependencies");
     1039  if (0 != pconstituent)
     1040    file += "_" + pconstituent->name;
     1041  file += ".in";
     1042
     1043  if (outdir != "")
     1044    {
     1045      if (outdir [outdir.size () - 1] != CmtSystem::file_separator ())
     1046        file = outdir + CmtSystem::file_separator () + file;
     1047      else
     1048        file = outdir + file;
     1049    }
     1050
     1051  ostringstream os;
     1052 
     1053  cmt_string preprocessor;
     1054  Symbol* macro = Symbol::find ("preprocessor_command");
     1055  if (macro != 0)
     1056    {
     1057      preprocessor = macro->resolve_macro_value ();
     1058    }
     1059
     1060  if (preprocessor == "")
     1061    {
     1062      const Use* current_use = &Use::current ();
     1063      Use::UsePtrVector uses (Use::get_ordered_uses ());
     1064      uses.push_back (&Use::current ());
     1065     
     1066      if (current_use->include_path == "none")
     1067        os << "include_path none\n";
     1068
     1069      for (int i = uses.size () - 1; i >= 0; i--)
     1070        {
     1071          const Use* use = uses[i];
     1072          if (use->discarded) continue;
     1073          if (use->m_hidden) continue;
     1074          if (!use->located ()) continue;
     1075         
     1076          cmt_string package_name = use->get_package_name ();
     1077          if (package_name == "CMT") continue;
     1078         
     1079          const Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter");
     1080          if (filter_macro == 0) continue;
     1081         
     1082          const Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp");
     1083          cmt_string stamp;
     1084          if (stamp_macro != 0)
     1085            {
     1086              stamp = stamp_macro->resolve_macro_value ();
     1087            }
     1088          else
     1089            {
     1090              use->get_full_path (stamp);
     1091              switch (use->style)
     1092                {
     1093                case cmt_style:
     1094                  stamp += CmtSystem::file_separator ();
     1095                  stamp += "cmt";
     1096                  break;
     1097                case mgr_style:
     1098                  stamp += CmtSystem::file_separator ();
     1099                  stamp += "mgr";
     1100                  break;
     1101                }
     1102              stamp += CmtSystem::file_separator ();
     1103              stamp += "cmt_header_file.stamp";
     1104            }
     1105          if (!CmtSystem::test_file (stamp)) continue;
     1106
     1107          os << "macro " + package_name + "_header_file_filter ";
     1108          os << CmtSystem::quote (filter_macro->resolve_macro_value (), " \t");
     1109          os << "\n";
     1110          os << "macro " + package_name + "_header_file_stamp ";
     1111          os << CmtSystem::quote (stamp, " \t");
     1112          os << "\n";
     1113        }
     1114    }
     1115  else
     1116    {
     1117      os << "macro preprocessor_command ";
     1118      os << CmtSystem::quote (preprocessor, " \t");
     1119      os << "\n";
     1120      macro = Symbol::find ("includes");
     1121      if (0 != macro)
     1122        {
     1123          os << "macro includes ";
     1124          os << CmtSystem::quote (macro->resolve_macro_value (), " \t");
     1125          os << "\n";
     1126        }
     1127      if (0 == pconstituent)
     1128        {
     1129          const Constituent::ConstituentVector& constituents =
     1130            Constituent::constituents ();
     1131          for (int n = 0; n < constituents.size (); n++)
     1132            {
     1133              const Constituent& constituent = constituents[n];
     1134              if (constituent.has_target_tag) continue;
     1135              if (constituent.type == Document) continue;
     1136              cmt_string prefix;
     1137              switch (constituent.type)
     1138                {
     1139                case Application:
     1140                  prefix = "app_";
     1141                  break;
     1142                case Library:
     1143                  prefix = "lib_";
     1144                  break;
     1145                }
     1146              cmt_string macro_name (prefix + constituent.name + "_cppflags");
     1147              macro = Symbol::find (macro_name);
     1148              if (0 != macro)
     1149                {
     1150                  os << "macro_append " + macro_name + " ";
     1151                  os << CmtSystem::quote (macro->resolve_macro_value (), " \t");
     1152                  os << "\n";
     1153                }
     1154            }
     1155        }
     1156      else if (pconstituent->type != Document)
     1157        {
     1158          const Constituent& constituent = *pconstituent;
     1159          cmt_string prefix;
     1160          switch (constituent.type)
     1161            {
     1162            case Application:
     1163              prefix = "app_";
     1164              break;
     1165            case Library:
     1166              prefix = "lib_";
     1167              break;
     1168            }
     1169          cmt_string macro_name (prefix + constituent.name + "_cppflags");
     1170          macro = Symbol::find (macro_name);
     1171          if (0 != macro)
     1172            {
     1173              os << "macro_append " + macro_name + " ";
     1174              os << CmtSystem::quote (macro->resolve_macro_value (), " \t");
     1175              os << "\n";
     1176            }
     1177        }
     1178    }
     1179
     1180  // Write input requirements file
     1181
     1182  bool gen (true);
     1183  //  ostringstream os;
     1184  ofstream s;
     1185  //  s.open (file);
     1186  s.open (file, ios::in);
     1187  if (s) // file already exists
     1188    {
     1189      //      InGen.build (constituent, os);
     1190      ostringstream osn;
     1191      osn << s.rdbuf ();
     1192      if (os.str () == osn.str ())
     1193        {
     1194          //      cerr << file << " up-to-date" << endl;
     1195          gen = false;
     1196        }
     1197    }
     1198  s.clear ();
     1199  s.close ();
     1200  s.clear ();
     1201  if (gen)
     1202    {
     1203      s.open (file);
     1204      if (!s)
     1205        {
     1206          CmtError::set (CmtError::file_access_error, file);
     1207          return -1;
     1208        }
     1209      s.exceptions (ios::failbit | ios::badbit);
     1210      try
     1211        {
     1212          //      if (os.str ().size () != 0)
     1213          //        {
     1214              //  cerr << file << " contents already generated" << endl;
     1215              s << os.str ();
     1216              //            }
     1217              //          else
     1218              //            {
     1219              //              InGen.build (constituent, s);
     1220              //            }
     1221          s.close (); // ios_base::failbit
     1222        }
     1223      catch (const ios::failure& e)
     1224        {
     1225          CmtSystem::close_ostream (NULL, file + ": " + cmt_string (e.what ()));
     1226          return -1;
     1227        }
     1228    }
     1229
     1230  return 0;
     1231}
     1232
     1233//--------------------------------------------------
    8151234int Generator::build_constituent_makefile (const Constituent& constituent,
     1235                                           bool& dependencies,
    8161236                                           const cmt_string& file)
    8171237{
     
    8241244      //break;
    8251245    case Library:
    826       LibraryContext.build (package, constituent, file);
     1246      LibraryContext.build (package, constituent, dependencies, file);
    8271247      break;
    8281248    case Document:
    829       DocumentContext.build (package, constituent, file);
     1249      DocumentContext.build (package, constituent, dependencies, file);
    8301250      break;
    8311251    }
     
    8601280
    8611281  const Constituent* constituent = Constituent::find (name);
    862   if (constituent != 0) build_constituent_makefile (*constituent, file);
     1282  if (constituent != 0)
     1283    {
     1284      bool dependencies (false);
     1285      build_constituent_makefile (*constituent, dependencies, file);
     1286    }
    8631287}
    8641288
     
    8671291{
    8681292  DefaultMakefileContext.build ();
     1293}
     1294
     1295//--------------------------------------------------
     1296void Generator::build_packages_makefile (const cmt_string& package,
     1297                                         const cmt_string& file)
     1298{
     1299  PackagesMakefileContext.build (package, file);
     1300  //  UsesMakefileContext.build (package, file);
    8691301}
    8701302
     
    12131645  CmtSystem::cmt_string_vector document;
    12141646  document.push_back ("document_header");
     1647  document.push_back ("dependency");
    12151648  m_document.set_names (document);
    12161649  m_document.set_uses (usecmt);
  • CMT/HEAD/source/cmt_generator.h

    r561 r588  
    1212#include "cmt_language.h"
    1313#include "cmt_awk.h"
    14 #include "cmt_deps_builder.h"
    1514
    1615class Packager : public FAwk
     
    5958  void fill_outputs ();
    6059
    61   void prepare_use_context ();
     60  //  void prepare_use_context ();
    6261
    6362  void set_full_name (cmt_string& full_name, cmt_string& file);
     
    9695  cmt_string m_output_file_name;
    9796  FILE* m_output_file;
    98 
    99   DepsBuilder m_deps_builder;
    10097
    10198  Constituent* m_constituent;
     
    215212    // Build the makefile fragment for one constituent
    216213  static int build_constituent_makefile (const Constituent& constituent,
     214                                         bool& dependencies,
    217215                                         const cmt_string& file = "");
    218216  static void build_constituent_makefile (const CmtSystem::cmt_string_vector& arguments);
     
    221219                                       bool usecmt = true);
    222220
     221  static int build_library_links_infile (const cmt_string& outdir = "");
     222
     223  static int build_dependencies_infile (const Constituent* constituent,
     224                                        const cmt_string& outdir = "",
     225                                        bool usecmt = true);
     226
    223227  static void build_default_makefile ();
     228
     229    // Build the packages (N)Make file
     230  static void build_packages_makefile (const cmt_string& package,
     231                                       const cmt_string& file = "");
    224232
    225233    // Build the dependencies for one module
  • CMT/HEAD/source/cmt_generators.cxx

    r561 r588  
    1212#include "cmt_error.h"
    1313#include <assert.h>
     14#include "cmt_project.h"
    1415
    1516//--------------------------------------------------
     
    200201  if (Cmt::get_debug ())
    201202    {
    202       cout << "CmtGenerator::analyze_file> constituent=" <<
     203      cout << "LibraryGenerator::analyze_file> constituent=" <<
    203204        constituent.name <<
    204205        " obj=" << obj << endl;
     
    408409
    409410//--------------------------------------------------
     411void LibraryGenerator::fill_names_outputs ()
     412{
     413  bool l_first = true;
     414  bool o_first = true;
     415
     416  m_LINE = "";
     417  m_OBJS = "";
     418
     419  for (int i = 0; i < m_source_files.size (); i++)
     420    {
     421      const SourceFile& file = m_source_files[i];
     422      const cmt_string name = file.name ();
     423      const cmt_string output = file.output ();
     424      Language& language = file.language ();
     425
     426      if (output != "")
     427        {
     428          if (o_first)
     429            {
     430              o_first = false;
     431            }
     432          else
     433            {
     434              m_OBJS += " ";
     435            }
     436          m_OBJS += output;
     437
     438          if (language == Language::null () || !language.native_dependencies ())
     439            {
     440              if (l_first)
     441                {
     442                  l_first = false;
     443                }
     444              else
     445                {
     446                  m_LINE += " ";
     447                }
     448              m_LINE += name;
     449            }
     450        }
     451
     452      if (Cmt::get_debug ())
     453        {
     454          cout << "LibraryGenerator::fill_names_outputs>" << endl;
     455          cout << "name=" << name << " LINE=" << m_LINE << endl;
     456          cout << "output=" << output << " OBJS=" << m_OBJS << endl;
     457        }
     458    }
     459
     460  filter_path (m_LINE.value);
     461}
     462
     463//--------------------------------------------------
    410464void LibraryGenerator::build (const cmt_string& package,
    411465                              const Constituent& constituent,
     466                              bool& dependencies,
    412467                              const cmt_string& file_name)
    413468{
     
    735790        }
    736791    }
     792  dependencies = need_dependencies;
    737793
    738794  if (constituent.build_triggers)
     
    893949DocumentGenerator::DocumentGenerator ()
    894950{
     951  m_FILEEXTENSION.set ("FILEEXTENSION");
     952
    895953  document_header_fragment.set ("document_header");
     954  dependency_fragment.set ("dependency");
    896955}
    897956
     
    900959{
    901960  AnyDocumentGenerator::reset ();
     961  m_FILEEXTENSION = "";
     962
    902963  document_header_fragment.reset ();
     964  dependency_fragment.reset ();
    903965}
    904966
     
    906968void DocumentGenerator::build (const cmt_string& package,
    907969                               const Constituent& constituent,
     970                               bool& dependencies,
    908971                               const cmt_string& file_name)
    909972{
     
    10621125    }
    10631126
     1127  dependencies = fragment.need_dependencies ();
    10641128  if (fragment.need_dependencies ())
    10651129    {
     
    11231187      if (m_FILEPATH.value != "") m_FILEPATH.value += CmtSystem::file_separator ();
    11241188      filter_path (m_FILEPATH.value);
    1125       CmtSystem::basename (file_name, m_FILENAME.value);
    1126       CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value);
     1189      m_FILENAME.value = m_NAME.value + suffix;
     1190      //CmtSystem::basename (file_name, m_FILENAME.value);
     1191      m_FILESUFFIX.value = suffix;
     1192      //CmtSystem::get_dot_suffix (m_FILENAME.value, m_FILESUFFIX.value);
     1193      CmtSystem::get_suffix (m_FILENAME.value, m_FILEEXTENSION .value);
    11271194      /*
    11281195      if (!CmtSystem::test_file (file_name) && !CmtSystem::test_directory (file_name))
     
    11331200      filter_path (m_FULLNAME.value);
    11341201
    1135       fragment.copy (m_output_file, constituent.variables, 8,
     1202      if (fragment.need_dependencies ())
     1203        {
     1204          // ensure that ${CONSTITUENT}_dependencies.make gets rebuilt
     1205          // whenever source file OR its dependencies change
     1206          dependency_fragment.copy (m_output_file, constituent.variables, 9,
     1207                                    &m_FILEPATH,
     1208                                    &m_SUFFIX,
     1209                                    &m_CONSTITUENT,
     1210                                    &m_CONSTITUENTSUFFIX,
     1211                                    &m_FILENAME,
     1212                                    &m_NAME,
     1213                                    &m_FULLNAME,
     1214                                    &m_FILESUFFIX,
     1215                                    &m_FILEEXTENSION);
     1216        }
     1217     
     1218      fragment.copy (m_output_file, constituent.variables, 9,
    11361219                     &m_FILEPATH,
    11371220                     &m_SUFFIX,
     
    11411224                     &m_NAME,
    11421225                     &m_FULLNAME,
    1143                      &m_FILESUFFIX);
     1226                     &m_FILESUFFIX,
     1227                     &m_FILEEXTENSION);
    11441228    }
    11451229
     
    12011285}
    12021286
     1287//--------------------------------------------------
    12031288ReadmeGenerator::ReadmeGenerator ()
    12041289{
     
    27022787}
    27032788
    2704 
    2705 
     2789//--------------------------------------------------
     2790
     2791PackagesMakefileGenerator::PackagesMakefileGenerator ()
     2792{
     2793  m_DEPENDENCIES.set ("DEPENDENCIES");
     2794  m_PACKAGEMGRPATH.set ("PACKAGEMGRPATH");
     2795  m_PACKAGEFULLNAME.set ("PACKAGEFULLNAME");
     2796  m_ISLOCAL.set ("ISLOCAL");
     2797
     2798  packages_header_fragment.set ("packages_header");
     2799  packages_trailer_fragment.set ("packages_trailer");
     2800  package_fragment.set ("package");
     2801}
     2802
     2803void PackagesMakefileGenerator::reset ()
     2804{
     2805  CmtGenerator::reset ();
     2806  m_DEPENDENCIES = "";
     2807  m_PACKAGEMGRPATH = "";
     2808  m_PACKAGEFULLNAME = "";
     2809  m_ISLOCAL = "";
     2810
     2811  packages_header_fragment.reset ();
     2812  packages_trailer_fragment.reset ();
     2813  package_fragment.reset ();
     2814}
     2815
     2816//--------------------------------------------------
     2817void PackagesMakefileGenerator::build (const cmt_string& package,
     2818                                       const cmt_string& file)
     2819{
     2820  reset ();
     2821
     2822  cmt_string file_name (file);
     2823  if (file_name == "")
     2824    {
     2825      file_name = "packages.";
     2826
     2827      if (Cmt::build_nmake ())
     2828        {
     2829          file_name += "nmake";
     2830        }
     2831      else
     2832        {
     2833          file_name += "make";
     2834        }
     2835    }
     2836
     2837  cmt_string save_file_name = file_name;
     2838  save_file_name += "cmtsave";
     2839
     2840  if (CmtSystem::test_file (file_name))
     2841    {
     2842      rename (file_name, save_file_name);
     2843    }
     2844
     2845  cmt_string new_file_name = file_name;
     2846  new_file_name += "new";
     2847
     2848  m_output_file = fopen (new_file_name, "wb");
     2849  if (m_output_file != NULL)
     2850    {
     2851      m_PACKAGE = package;
     2852
     2853      packages_header_fragment.copy (m_output_file, 1, &m_PACKAGE);
     2854
     2855      Project* cur = Project::get_current ();
     2856      Use::UsePtrVector uses (Use::get_ordered_uses ());
     2857      uses.push_back (&Use::current ());
     2858      cmt_string temp;
     2859      for (int i = uses.size () - 1; i >= 0; i--)
     2860        {
     2861          Use* use = uses[i];
     2862          if (use->discarded) continue;
     2863          if (use->m_hidden) continue;
     2864          if (!use->located ()) continue;
     2865          if (use->get_package ()->is_cmt ()) continue;
     2866
     2867          if (use->get_project () == cur)
     2868            m_ISLOCAL = "is_local";
     2869          else
     2870            m_ISLOCAL = "is_not_local";
     2871
     2872          temp = use->get_full_path ();
     2873          switch (use->style)
     2874            {
     2875            case cmt_style:
     2876              temp += CmtSystem::file_separator ();
     2877              temp += "cmt";
     2878              break;
     2879            case mgr_style:
     2880              temp += CmtSystem::file_separator ();
     2881              temp += "mgr";
     2882              break;
     2883            }
     2884#ifdef WIN32
     2885          temp += " ";
     2886#endif
     2887          m_PACKAGEMGRPATH = temp;
     2888          //      fprintf (m_output_file, "%s\n", temp.c_str());
     2889
     2890          temp = "";
     2891          if (Symbol* s = Symbol::find (use->get_package_name () + "_offset"))
     2892            {
     2893              cmt_string o = s->build_macro_value ();
     2894              if (o != "")
     2895                {
     2896                  temp += o;
     2897                  temp += CmtSystem::file_separator ();
     2898                }
     2899            }
     2900          else
     2901            {
     2902              CmtMessage::warning
     2903                (CmtError::get_error_name (CmtError::symbol_not_found)
     2904                 + ": macro " + use->get_package_name () + "_offset");
     2905            }
     2906          temp += use->get_package_name ();
     2907          temp.replace_all (CmtSystem::file_separator (), "_");
     2908#ifdef WIN32
     2909          temp += " ";
     2910#endif
     2911          m_PACKAGEFULLNAME = temp;
     2912          //      fprintf (m_output_file, "%s\n", temp.c_str());
     2913
     2914          m_PACKAGE = use->get_package_name ();
     2915
     2916          Use::UsePtrVector subuses;
     2917          for (int i = 0; i < use->sub_uses.size (); i++)
     2918            {
     2919              if (use->sub_uses[i]->m_index >= 0 && !use->sub_uses[i]->discarded)
     2920                {
     2921                  if (use->sub_uses[i]->m_hidden) continue;
     2922                  subuses.push_back (use->sub_uses[i]);
     2923                }
     2924              else
     2925                {
     2926                  Use* au (Use::find_valid (use->sub_uses[i]->get_package_name ()));
     2927                  if (au)
     2928                    {
     2929                      subuses.push_back (au);
     2930                    }
     2931                }
     2932            }
     2933          m_DEPENDENCIES = "";
     2934          for (int i = 0; i < subuses.size (); i++)
     2935            {
     2936              if (i != 0)
     2937                {
     2938                  m_DEPENDENCIES += " " + subuses[i]->get_package_name ();
     2939                }
     2940              else
     2941                {
     2942                  m_DEPENDENCIES += subuses[i]->get_package_name ();
     2943                }
     2944            }
     2945
     2946          package_fragment.copy (m_output_file, 5, &m_PACKAGE, &m_DEPENDENCIES,
     2947                             &m_PACKAGEMGRPATH, &m_PACKAGEFULLNAME, &m_ISLOCAL);
     2948        }
     2949
     2950      if (Symbol* s = Symbol::find ("CMTINSTALLAREA"))
     2951        {
     2952          cmt_string o = s->build_macro_value ();
     2953          Symbol::expand (o);
     2954          if (o != "")
     2955            {
     2956              temp  = "CMTINSTALLAREA=";
     2957              temp += o;
     2958#ifdef WIN32
     2959              temp += " ";
     2960#endif
     2961              fprintf (m_output_file, "%s\n", temp.c_str());
     2962            }
     2963        }
     2964
     2965      packages_trailer_fragment.copy (m_output_file, 0);
     2966
     2967      CmtSystem::close_ostream (m_output_file, new_file_name);
     2968      //  fclose (m_output_file);
     2969
     2970      commit (new_file_name);
     2971    }
     2972  else
     2973    {
     2974      CmtError::set (CmtError::file_access_error, new_file_name);
     2975    }
     2976}
     2977
     2978//--------------------------------------------------
    27062979
    27072980/**
     
    27943067};
    27953068
     3069//--------------------------------------------------
     3070void DependencyGenerator::reset ()
     3071{
     3072  CmtGenerator::reset ();
     3073  m_deps_builder.clear ();
     3074  m_stamps = true;
     3075  m_name = "";
     3076}
     3077
     3078//--------------------------------------------------
     3079void DependencyGenerator::prepare_includes ()
     3080{
     3081  cmt_string path;
     3082  cmt_string substitution;
     3083
     3084  Use* use = &Use::current ();
     3085
     3086  //  m_deps_builder.clear ();
     3087
     3088  if (use->include_path != "none")
     3089    {
     3090      if (use->include_path == "")
     3091        {
     3092          m_deps_builder.add (incdir, "$(src)");
     3093        }
     3094      else
     3095        {
     3096          substitution = use->include_path;
     3097         
     3098          path = substitution;
     3099          Symbol::expand (path);
     3100         
     3101          CmtSystem::reduce_file_separators (path);
     3102
     3103          m_deps_builder.add (path, substitution);
     3104        }
     3105    }
     3106
     3107  m_deps_builder.add_includes (*use);
     3108
     3109  Use::UsePtrVector& uses = Use::get_ordered_uses ();
     3110
     3111  if (uses.size () > 0)
     3112    {
     3113      int number;
     3114
     3115      for (number = 0; number < uses.size (); number++)
     3116        {
     3117          use = uses[number];
     3118          if (use->discarded) continue;
     3119
     3120          if (use->real_path != "")
     3121            {
     3122              if (use->include_path != "none")
     3123                {
     3124                  if (use->include_path == "")
     3125                    {
     3126                      use->get_full_path (path);
     3127                      path += CmtSystem::file_separator ();
     3128                      path += "src";
     3129
     3130                      substitution = "$(";
     3131                      substitution += use->prefix;
     3132                      substitution += "ROOT)";
     3133                      substitution += CmtSystem::file_separator ();
     3134                      substitution += "src";
     3135                      substitution += CmtSystem::file_separator ();
     3136                    }
     3137                  else
     3138                    {
     3139                      substitution = use->include_path;
     3140
     3141                      path = substitution;
     3142                      Symbol::expand (path);
     3143
     3144                      CmtSystem::reduce_file_separators (path);
     3145                    }
     3146
     3147                  m_deps_builder.add (path, substitution);
     3148                }
     3149
     3150              m_deps_builder.add_includes (*use);
     3151            }
     3152        }
     3153    }
     3154}
     3155
     3156//--------------------------------------------------
     3157void DependencyGenerator::prepare_header_file_filters ()
     3158{
     3159  const Use* current_use = &Use::current ();
     3160  Use::UsePtrVector uses (Use::get_ordered_uses ());
     3161  uses.push_back (&Use::current ());
     3162  bool current_only (true);
     3163  for (int i = uses.size () - 1; i >= 0; i--)
     3164    {
     3165      const Use* use = uses[i];
     3166      //cerr << "prepare_header_file_filters(0)> " << use->get_package_name () << "[" << use->get_index () << "]\n";
     3167      if (use->discarded) continue;
     3168      if (use->m_hidden) continue;
     3169      if (!use->located ()) continue;
     3170
     3171      if (current_only && use != current_use)
     3172        current_only = false;
     3173
     3174      cmt_string package_name = use->get_package_name ();
     3175      if (package_name == "CMT") continue;
     3176
     3177      const Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter");
     3178      if (filter_macro == 0) continue;
     3179
     3180      const Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp");
     3181      cmt_string stamp;
     3182      if (stamp_macro != 0)
     3183        {
     3184          stamp = stamp_macro->resolve_macro_value ();
     3185        }
     3186      else
     3187        {
     3188          use->get_full_path (stamp);
     3189          switch (use->style)
     3190            {
     3191            case cmt_style:
     3192              stamp += CmtSystem::file_separator ();
     3193              stamp += "cmt";
     3194              break;
     3195            case mgr_style:
     3196              stamp += CmtSystem::file_separator ();
     3197              stamp += "mgr";
     3198              break;
     3199            }
     3200          stamp += CmtSystem::file_separator ();
     3201          stamp += "cmt_header_file.stamp";
     3202          //stamp += "cmt_all_headers.stamp";
     3203          //<package>/cmt/cmt_all_headers.stamp
     3204        }
     3205      if (!CmtSystem::test_file (stamp)) continue;
     3206
     3207      //cerr << "0: adding filter: " << use->get_package_name () << "[" << use->get_index () << "]\n";
     3208      cmt_regexp* filter = new cmt_regexp (filter_macro->resolve_macro_value ());
     3209      assert (filter != 0);
     3210
     3211      m_deps_builder.add_header_filter (use, filter, stamp);
     3212    }
     3213
     3214  if (current_only)
     3215    { // we are most likely reading dependencies[_CONSTITUENT].in without CMT
     3216      for (int number = 0; number < Symbol::symbol_number (); number++)
     3217        {
     3218          const Symbol& symbol = Symbol::symbol (number);
     3219          if (symbol.type != Symbol::SymbolMacro) continue;
     3220          int r = symbol.name.find_last_of ("_header_file_filter");
     3221          if (r == cmt_string::npos ||
     3222              (r + 19) != symbol.name.size () ||
     3223              r == 0) continue;
     3224
     3225          cmt_string package_name = symbol.name.substr(0, r);
     3226          const Use* use = Use::find (package_name);
     3227          if (use == current_use) continue;
     3228          if (0 != use && use->discarded) continue;
     3229          if (0 != use && use->m_hidden) continue;
     3230          if (0 != use && !use->located ()) continue;
     3231         
     3232          //Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter");
     3233          //if (filter_macro == 0) continue;
     3234         
     3235          const Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp");
     3236          cmt_string stamp;
     3237          if (stamp_macro != 0)
     3238            {
     3239              stamp = stamp_macro->resolve_macro_value ();
     3240            }
     3241          else if (0 != use)
     3242            {
     3243              use->get_full_path (stamp);
     3244              switch (use->style)
     3245                {
     3246                case cmt_style:
     3247                  stamp += CmtSystem::file_separator ();
     3248                  stamp += "cmt";
     3249                  break;
     3250                case mgr_style:
     3251                  stamp += CmtSystem::file_separator ();
     3252                  stamp += "mgr";
     3253                  break;
     3254                }
     3255              stamp += CmtSystem::file_separator ();
     3256              stamp += "cmt_header_file.stamp";
     3257            }
     3258          if (!CmtSystem::test_file (stamp)) continue;
     3259         
     3260          //cerr << "1: adding filter: " << package_name << "\n";
     3261          cmt_regexp* filter = new cmt_regexp (symbol.resolve_macro_value ());
     3262          assert (filter != 0);
     3263         
     3264          m_deps_builder.add_header_filter (use, filter, stamp);
     3265        }
     3266    }
     3267}
     3268
     3269//--------------------------------------------------
    27963270void DependencyGenerator::build (const CmtSystem::cmt_string_vector& arguments)
    27973271{
    27983272  reset ();
    2799   prepare_use_context ();
    2800 
    2801   prepare_header_file_filters ();
    2802 
    2803   const cmt_string& name = arguments[0];
    2804 
    2805   m_constituent = Constituent::find (name);
    2806   if (m_constituent == 0)
    2807     {
    2808       // Error : wrong constituent name...
    2809       return;
    2810     }
    2811 
    2812   const Constituent& constituent = *m_constituent;
    2813 
    2814   cmt_string file_name;
    2815   cmt_string full_name;
    2816   cmt_string compressed_name;
    2817   //  cmt_string suffix;
    2818   cmt_string dependencies;
    28193273
    28203274  //
    2821   // Scan the sources.
     3275  // Parse arguments first
    28223276  //
    2823 
    2824   //
    2825   //  We have to rebuild the dependencies for :
    2826   //
    2827   //   o all sources if the parameter -all_sources has been received
    2828   //   o otherwise,
    2829   //      + all source names provided in the argument list (if any)
    2830   //      + all source names missing from the existing dependency file (if any)
    2831   //
    2832 
    2833   const CmtSystem::cmt_string_vector& sources = constituent.modules;
    2834   const cmt_vector<cmt_regexp>& excludes = constituent.exclude_exprs;
    2835   const cmt_vector<cmt_regexp>& selects = constituent.select_exprs;
    2836 
    2837   m_stamps = true;
     3277  CmtSystem::cmt_string_vector cli_input, all;
    28383278  bool all_sources = false;
    2839 
    2840   int source_number = arguments.size ();
    2841   int i;
    2842 
    2843   //cerr << "source_number=" << source_number << endl;
    2844 
    2845   for (i = source_number-1; i >= 0; i--)
    2846     {
    2847       file_name = arguments[i];
    2848 
    2849       //cerr << "file_name=" << file_name << endl;
    2850 
    2851       // Get rid of files that may come from the makefile fragment
    2852       if (file_name.find ("requirements") != cmt_string::npos) source_number--;
    2853       else if (file_name.substr (0, 5) == "-out=" ||
    2854                file_name.substr (0, 5) == "-out:" ||
    2855                file_name.substr (0, 5) == "/out:" ||
    2856                file_name.substr (0, 5) == "/out=")
    2857         {
    2858           source_number--;
     3279  bool config_files (false);
     3280  bool start_all (false);
     3281
     3282  for (int i = 0; i < arguments.size (); i++)
     3283    {
     3284      cmt_string file_name = arguments[i];
     3285
     3286      //cerr << "i: " << i << " file_name=" << file_name << endl;
     3287
     3288      if (file_name.substr (0, 5) == "-out=" ||
     3289          file_name.substr (0, 5) == "-out:" ||
     3290          file_name.substr (0, 5) == "/out:" ||
     3291          file_name.substr (0, 5) == "/out=")
     3292        {
    28593293          file_name.erase (0, 5);
    28603294          m_output_file_name = file_name;
    28613295        }
    2862       else if (file_name.find (".make") != cmt_string::npos) source_number--;
    28633296      else if (file_name == "-all_sources" ||
    28643297               file_name == "/all_sources")
    28653298        {
    2866           source_number = sources.size ();
    28673299          all_sources = true;
    28683300        }
     
    28703302               file_name == "/no_stamps")
    28713303        {
    2872           source_number--;
    28733304          m_stamps = false;
    28743305        }
    2875     }
     3306      else if (file_name.substr (0, 2) == "-I" ||
     3307               file_name.substr (0, 2) == "/I")
     3308        {
     3309          file_name.erase (0, 2);
     3310          //cerr << "include: " << file_name << endl;
     3311          m_deps_builder.add (file_name, file_name);
     3312        }
     3313      else if (file_name  == "-start_all" ||
     3314               file_name  == "/start_all")
     3315        {
     3316          if (start_all)
     3317            {
     3318              CmtError::set(CmtError::syntax_error,
     3319                            "Unexpected option " + file_name);
     3320              return;
     3321            }
     3322          start_all = true;
     3323        }
     3324      else if (file_name == "-end_all" ||
     3325               file_name == "/end_all")
     3326        {
     3327          if (!start_all)
     3328            {
     3329              CmtMessage::warning
     3330                (CmtError::get_error_name (CmtError::syntax_error)
     3331                 + ": Unexpected option " + file_name);
     3332            }
     3333          start_all = false;
     3334        }
     3335      else if (file_name.substr (0, 1) == "-"
     3336#ifdef WIN32
     3337               || file_name.substr (0, 1) == "/"
     3338#endif
     3339               )
     3340        {
     3341          if (CmtMessage::active (Verbose))
     3342            CmtMessage::warning
     3343              (CmtError::get_error_name (CmtError::warning)
     3344               + ": Unknown option " + file_name);
     3345        }
     3346      else if (file_name.substr (file_name.size () - 12) == "requirements" ||
     3347               file_name.substr (file_name.size () - 5) == ".make" ||
     3348               file_name.substr (file_name.size () - 3) == ".mk" ||
     3349               file_name.substr (file_name.size () - 6) == ".nmake" ||
     3350               file_name.substr (file_name.size () - 3) == ".in" ||
     3351               file_name.substr (file_name.size () - 6) == ".stamp")
     3352        {
     3353          // Configuration changed,
     3354          // want to rebuild dependencies from scratch
     3355          if (!config_files) config_files = true;
     3356          if (!all_sources) all_sources = true;
     3357        }
     3358      else if (start_all)
     3359        {
     3360          all.push_back (file_name);
     3361        }
     3362      else if (m_name.size () != 0)
     3363        {
     3364          cli_input.push_back (file_name);
     3365        }
     3366      else
     3367        {
     3368          if (file_name.size () != 0)
     3369            m_name = file_name;
     3370        }
     3371    }
     3372 
     3373  if (start_all)
     3374    CmtMessage::warning
     3375      (CmtError::get_error_name (CmtError::syntax_error)
     3376       + ": Missing option -end_all");
     3377
     3378  //cerr << "m_name: " << m_name << endl;
     3379  if (m_name.size () == 0)
     3380    {
     3381      CmtError::set(CmtError::syntax_error,
     3382                    "Name missing as first argument");
     3383      return;
     3384    }
     3385
     3386  //cerr << "config_files: " << config_files << endl;
     3387
     3388  m_constituent = Constituent::find (m_name);
     3389
     3390  if (!config_files && 0 == cli_input.size () &&
     3391      0 == all.size () && 0 == m_constituent)
     3392    {
     3393      CmtError::set(CmtError::syntax_error,
     3394                    m_name + ": Files arguments missing");
     3395      return;
     3396    }
     3397  /*
     3398  cerr << "cli_input:";
     3399  for (int i = 0; i < cli_input.size (); i++)
     3400    cerr << " " << cli_input[i];
     3401  cerr << "\n";
     3402
     3403  cerr << "all:";
     3404  for (int i = 0; i < all.size (); i++)
     3405    cerr << " " << all[i];
     3406  cerr << "\n";
     3407  */
     3408  prepare_includes ();
     3409  prepare_header_file_filters ();
    28763410
    28773411  //
     
    29223456    {
    29233457      m_output_file_name = m_bin;
    2924       m_output_file_name += name;
     3458      m_output_file_name += m_name;
    29253459      m_output_file_name += "_";
    29263460      m_output_file_name += "dependencies.";
     
    29353469    }
    29363470
    2937   if (all_sources)
    2938     {
    2939       for (i = 0; i < sources.size (); i++)
    2940         {
    2941           file_name = sources[i];
    2942          
    2943           set_full_name (full_name, file_name);
    2944           if (full_name == "") continue;
    2945 
    2946           CmtSystem::compress_path (full_name, compressed_name);
    2947           full_name = compressed_name;
    2948          
    2949           static CmtSystem::cmt_string_vector files;
    2950 
    2951           get_all_files (full_name, excludes, selects, files);
    2952 
    2953           for (int j = 0; j < files.size (); j++)
    2954             {
    2955               const cmt_string& name = files[j];
    2956              
    2957               if (name != "")
    2958                 {
    2959                   const cmt_string& line = build (name);
    2960                  
    2961                   add_line_to_text (line, dependencies);
    2962                 }
    2963             }
    2964         }
    2965     }
    2966   else
    2967     {
    2968       //
    2969       // New read the existing dependency file if any and filter it to
    2970       // extract the source names
    2971       //
    2972       static DependencyFilter filter;
    2973       dependencies.read (m_output_file_name);
    2974       filter.run (dependencies);
    2975      
    2976       for (i = 1; i < source_number; i++)
    2977         {
    2978           file_name = arguments[i];
    2979 
    2980           set_full_name (full_name, file_name);
    2981           if (full_name == "") continue;
    2982 
    2983           CmtSystem::compress_path (full_name, compressed_name);
    2984           full_name = compressed_name;
    2985          
    2986           const cmt_string& line = build (full_name);
    2987                  
    2988           add_line_to_text (line, dependencies);
    2989 
    2990           filter.add_source (full_name);
    2991 
    2992         }
    2993 
    2994       // Now : are there still any missing source file in dependencies??
    2995 
    2996       for (i = 0; i < sources.size (); i++)
    2997         {
    2998           file_name = sources[i];
    2999          
    3000           set_full_name (full_name, file_name);
    3001           if (full_name == "") continue;
    3002          
    3003           CmtSystem::compress_path (full_name, compressed_name);
    3004           full_name = compressed_name;
    3005          
    3006           static CmtSystem::cmt_string_vector files;
    3007          
    3008           get_all_files (full_name, excludes, selects, files);
    3009 
    3010           for (int j = 0; j < files.size (); j++)
    3011             {
    3012               const cmt_string& name = files[j];
    3013               if (name != "")
    3014                 {
    3015                   if (!filter.has_source (name))
    3016                     {
    3017                       const cmt_string& line = build (name);
    3018                  
    3019                       add_line_to_text (line, dependencies);
    3020                     }
    3021                 }
    3022             }
    3023         }
    3024     }
     3471  //-------------------------------------------------------------------------------
     3472  //
     3473  // For Makefile, we need to select, from cli_input, source files only,
     3474  // there may be dependencies of source files (typically, header files) as well
     3475  //
     3476  cmt_string dependencies;
     3477  if (!all_sources)
     3478    {
     3479      // want to validate cli_input against
     3480      //   either
     3481      // o all cli sources
     3482      //   or
     3483      // o m_constituent sources
     3484      set_source_files (all);
     3485      if (0 == validate (cli_input))
     3486        {
     3487          // cli_input contains source files ONLY
     3488          // calculate dependencies for them ONLY
     3489          if (CmtSystem::test_file (m_output_file_name))
     3490            {
     3491              if (!dependencies.read (m_output_file_name))
     3492                {
     3493                  CmtError::set (CmtError::file_access_error, m_output_file_name);
     3494                  return;
     3495                }
     3496            }
     3497          fill_dependencies (dependencies, cli_input);
     3498        }
     3499      else
     3500        {
     3501          all_sources = true;
     3502          // calculate dependencies for
     3503          // all cli sources
     3504          // or
     3505          // m_constituent sources
     3506          fill_dependencies (dependencies);
     3507        }
     3508      /*
     3509      if (0 != all.size ())
     3510        {
     3511          // o all cli sources
     3512          int n_invalid = 0;
     3513          for (int i = 0; i < cli_input.size (); i++)
     3514            {
     3515              bool valid = false;
     3516              for (int j = 0; j < all.size (); j++)
     3517                if (cli_input[i] == all[j])
     3518                  {
     3519                    valid = true;
     3520                    break;
     3521                  }
     3522              if (!valid)
     3523                {
     3524                  n_invalid += 1;
     3525                  break;
     3526                }
     3527            }
     3528          if (0 == n_invalid)
     3529            {
     3530              // cli_input contains source files ONLY
     3531              // calculate dependencies for them ONLY
     3532              if (CmtSystem::test_file (m_output_file_name))
     3533                {
     3534                  if (!dependencies.read (m_output_file_name))
     3535                    {
     3536                      CmtError::set (CmtError::file_access_error, m_output_file_name);
     3537                      return;
     3538                    }
     3539                }
     3540              fill_dependencies (dependencies, cli_input);
     3541            }
     3542          else
     3543            {
     3544              all_sources = true;
     3545              // calculate dependencies for all (all cli sources)
     3546              fill_dependencies (dependencies, all);
     3547            }
     3548        }
     3549      else // 0 == all.size ()
     3550        {
     3551          //      set_source_files ();
     3552          if (int n = set_source_files ())
     3553            //    if (0 != m_source_files.size ())
     3554            {
     3555              // o m_constituent sources
     3556              int n_invalid = 0;
     3557              for (int i = 0; i < cli_input.size (); i++)
     3558                {
     3559                  bool valid = false;
     3560                  for (int j = 0; j < n; j++)
     3561                    if (cli_input[i] == m_source_files[j].name ())
     3562                      {
     3563                        valid = true;
     3564                        break;
     3565                      }
     3566                  if (!valid)
     3567                    {
     3568                      n_invalid += 1;
     3569                      break;
     3570                    }
     3571                }
     3572              if (0 == n_invalid)
     3573                {
     3574                  // cli_input contains source files ONLY
     3575                  // calculate dependencies for them ONLY
     3576                  if (CmtSystem::test_file (m_output_file_name))
     3577                    {
     3578                      if (!dependencies.read (m_output_file_name))
     3579                        {
     3580                          CmtError::set (CmtError::file_access_error, m_output_file_name);
     3581                          return;
     3582                        }
     3583                    }
     3584                  fill_dependencies (dependencies, cli_input);
     3585                }
     3586              else
     3587                {
     3588                  all_sources = true;
     3589                  // calculate dependencies for m_source_files
     3590                  // (m_constituent sources)
     3591                  fill_dependencies (dependencies);
     3592                }
     3593            }
     3594          else // 0 == m_source_files.size ())
     3595            {
     3596              // no source files to validate against
     3597              fill_dependencies (dependencies, cli_input);
     3598            }
     3599        }
     3600      */
     3601    }
     3602  else // all_sources = true
     3603    {
     3604      if (int n = set_source_files (all))
     3605        {
     3606          // calculate dependencies for m_source_files
     3607          //   either
     3608          // o all cli sources
     3609          //   or
     3610          // o m_constituent sources
     3611          //   if any existing
     3612          fill_dependencies (dependencies);
     3613        }
     3614      else
     3615        {
     3616          // calculate dependencies for all we have
     3617          fill_dependencies (dependencies, cli_input);
     3618        }
     3619      /*
     3620      if (0 != all.size ())
     3621        {
     3622          // calculate dependencies for all (all cli sources)
     3623          fill_dependencies (dependencies, all);
     3624        }
     3625      else
     3626        {
     3627          if (int n = set_source_files ())
     3628            {
     3629              // calculate dependencies for m_source_files (m_constituent sources)
     3630              fill_dependencies (dependencies);
     3631            }
     3632          else
     3633            {
     3634              // calculate dependencies for all we have
     3635              fill_dependencies (dependencies, cli_input);
     3636            }
     3637        }
     3638      */
     3639    }
     3640
     3641  if (CmtError::has_pending_error ())
     3642    {
     3643      if (CmtError::get_last_error_code () == CmtError::path_not_found ||
     3644          CmtError::get_last_error_code () == CmtError::file_access_error ||
     3645          CmtError::get_last_error_code () == CmtError::execution_failed)
     3646        return;
     3647    }
     3648  //-------------------------------------------------------------------------------
    30253649
    30263650  FILE* f = fopen (m_output_file_name.c_str (), "wb");
     
    30303654      dependencies.write (f);
    30313655      CmtSystem::close_ostream (f, m_output_file_name);
    3032       //          fclose (f);
    30333656    }
    30343657  else
    30353658    {
    30363659      CmtError::set (CmtError::file_access_error, m_output_file_name);
    3037       //      CmtMessage::error ("Cannot open " + m_output_file_name + " for write");
    30383660    }
    30393661
     
    30433665//--------------------------------------------------
    30443666//  o text contains lines with a pattern like :
    3045 //      key = xxxxx
    3046 //
     3667//      key = value
    30473668//  o line follows the same pattern
    30483669//
    3049 //   This function appends <line> to <text> only if the key found in
    3050 //  <line> is not found in <text>
     3670//  This function
     3671//    o if the key found in <line> is found in <text>, removes the first line in <text> with the key, if any
     3672//    o appends <line> to <text>
    30513673//--------------------------------------------------
    3052 void DependencyGenerator::add_line_to_text (const cmt_string& line, cmt_string& text)
     3674void DependencyGenerator::add_line_to_text (const cmt_string& line, cmt_string& text) const
    30533675{
    30543676  static const cmt_string empty;
     
    30913713}
    30923714
     3715//--------------------------------------------------
    30933716cmt_string DependencyGenerator::build (const cmt_string& file_name)
    30943717{
    30953718  Log;
    30963719
    3097   const Constituent& constituent = *m_constituent;
     3720  //  const Constituent& constituent = *m_constituent;
    30983721
    30993722  static cmt_string full_name;
     
    31053728  line = "";
    31063729
     3730  /*
    31073731  if (!CmtSystem::absolute_path (file_name))
    31083732    {
    31093733      full_name = srcdir;
    31103734    }
     3735  */
    31113736
    31123737  full_name += file_name;
     
    31163741  CmtSystem::get_suffix (full_name, suffix);
    31173742
    3118   if (name == "requirements") return (line);
    3119 
    3120   const CmtSystem::cmt_string_vector& deps = m_deps_builder.run (full_name);
     3743  //  if (name == "requirements") return (line);
     3744
     3745  const CmtSystem::cmt_string_vector& deps = m_deps_builder.run (full_name, m_name);
     3746  if (CmtError::has_pending_error ())
     3747    {
     3748      return line;
     3749    }
     3750  //      CmtError::set (CmtError::execution_failed, preprocessor, status);
     3751  //      CmtError::set (CmtError::file_access_error, header_file_path);
     3752  //      CmtError::set (CmtError::path_not_found, name);
    31213753
    31223754  line  = name;
     
    31573789  if (m_stamps)
    31583790    {
    3159       cmt_string stamp_output_base = constituent.name;
     3791      cmt_string stamp_output_base = m_name;
     3792      //      cmt_string stamp_output_base = constituent.name;
    31603793      stamp_output_base += "_deps";
    31613794
     
    31653798      if (!CmtSystem::mkdir (stamp_output))
    31663799        {
    3167           CmtMessage::error ("Cannot create the binary output directory for this constituent " + stamp_output);
    3168           //      cerr << "Cannot create the binary output directory for this constituent" << endl;
     3800          CmtError::set (CmtError::file_access_error,
     3801                         + "Cannot create directory " + stamp_output
     3802                         + " for " + m_name);
     3803          return line;
    31693804        }
    31703805
     
    31853820      if (CmtSystem::test_file (stamp_output))
    31863821        {
    3187           old_stamp.read (stamp_output);
    3188         }
    3189 
    3190       if (line != old_stamp)
    3191         {
    3192           line.write (stamp_output);
     3822          if (!old_stamp.read (stamp_output))
     3823            {
     3824              CmtError::set (CmtError::file_access_error, stamp_output);
     3825              return line;
     3826            }
     3827          //      old_stamp.read (stamp_output);
     3828        }
     3829
     3830      if (line != old_stamp.substr(0, old_stamp.size () - 1))
     3831        {
     3832          if (!(line + "\n").write (stamp_output))
     3833            {
     3834              CmtError::set (CmtError::file_access_error, stamp_output);
     3835              return line;
     3836            }
     3837          //      (line + "\n").write (stamp_output);
    31933838        }
    31943839    }
     
    31983843
    31993844//--------------------------------------------------
    3200 void DependencyGenerator::prepare_header_file_filters ()
    3201 {
    3202 //   Use::UsePtrVector& uses = Use::get_ordered_uses ();
    3203   Use::UsePtrVector uses (Use::get_ordered_uses ());
    3204   uses.push_back (&Use::current ());
    3205   for (int i = uses.size () - 1; i >= 0; i--)
    3206     {
    3207       Use* use = uses[i];
    3208       if (use->discarded) continue;
    3209       if (use->m_hidden) continue;
    3210       if (!use->located ()) continue;
    3211 
    3212       cmt_string package_name = use->get_package_name ();
    3213       if (package_name == "CMT") continue;
    3214 
    3215       Symbol* filter_macro = Symbol::find (package_name + "_header_file_filter");
    3216       if (filter_macro == 0) continue;
    3217 
    3218       Symbol* stamp_macro = Symbol::find (package_name + "_header_file_stamp");
    3219       cmt_string stamp;
    3220       if (stamp_macro != 0)
    3221         {
    3222           stamp = stamp_macro->resolve_macro_value ();
    3223         }
    3224       else
    3225         {
    3226           use->get_full_path (stamp);
    3227           stamp += CmtSystem::file_separator ();
    3228           if (use->style == mgr_style) stamp += "mgr";
    3229           else stamp += "cmt";
    3230           stamp += CmtSystem::file_separator ();
    3231           stamp += "cmt_header_file.stamp";
    3232           //stamp += "cmt_all_headers.stamp";
    3233           //<package>/cmt/cmt_all_headers.stamp
    3234         }
    3235       if (!CmtSystem::test_file (stamp)) continue;
    3236 
    3237       cmt_regexp* filter = new cmt_regexp (filter_macro->resolve_macro_value ());
    3238       assert (filter != 0);
    3239 
    3240       m_deps_builder.add_header_filter (use, filter, stamp);
    3241     }
    3242 }
     3845int DependencyGenerator::fill_dependencies (cmt_string& dependencies)
     3846{
     3847  CmtSystem::cmt_string_vector sources;
     3848  for (int i = 0; i < m_source_files.size (); i++)
     3849    {
     3850      const SourceFile& file = m_source_files[i];
     3851      sources.push_back (file.name ());
     3852    }
     3853  return fill_dependencies (dependencies, sources);
     3854}
     3855
     3856//--------------------------------------------------
     3857int DependencyGenerator::fill_dependencies (cmt_string& dependencies,
     3858                                            const CmtSystem::cmt_string_vector& sources)
     3859{
     3860  int retval (0);
     3861  cmt_string file_name;
     3862  cmt_string compressed_name;
     3863
     3864  for (int i = 0; i < sources.size (); i++)
     3865    {
     3866      file_name = sources[i];
     3867      //set_full_name (full_name, file_name);
     3868      CmtSystem::reduce_file_separators (file_name);
     3869      if (file_name == "") continue;
     3870      CmtSystem::compress_path (file_name, compressed_name);
     3871      file_name = compressed_name;
     3872      //cerr << "file_name: " << file_name << endl;     
     3873      if (file_name == "") continue;
     3874
     3875      const cmt_string& line = build (file_name);
     3876      if (CmtError::has_pending_error ())
     3877        {
     3878          //      if (CmtError::get_last_error_code () == CmtError::file_access_error)
     3879          return -1;
     3880        }
     3881     
     3882      //cerr << "line: " << line << endl;     
     3883      add_line_to_text (line, dependencies);
     3884      //cerr << "dependencies: " << dependencies << endl;     
     3885    }
     3886
     3887  return retval;
     3888}
     3889
     3890//--------------------------------------------------
     3891int DependencyGenerator::set_source_files (const CmtSystem::cmt_string_vector& files)
     3892{
     3893  m_source_files.clear ();
     3894
     3895  for (int j = 0; j < files.size (); j++)
     3896    {
     3897      const cmt_string& name = files[j];
     3898      if (name == "") continue;
     3899
     3900      bool included = false;
     3901      for (int k = m_source_files.size () - 1; k >= 0; k--)
     3902        if (m_source_files[k].name () == name)
     3903          {
     3904            included = true;
     3905            break;
     3906          }
     3907      if (included) continue;
     3908     
     3909      SourceFile& source = m_source_files.add ();
     3910      source.set (name, Language::null (), "");
     3911    }
     3912     
     3913  if (m_source_files.size ()) return m_source_files.size ();
     3914  else return set_source_files ();
     3915}
     3916
     3917//--------------------------------------------------
     3918int DependencyGenerator::set_source_files ()
     3919{
     3920  if (0 == m_constituent && 0 != m_name.size ())
     3921    m_constituent = Constituent::find (m_name);
     3922  if (0 == m_constituent) return 0;
     3923
     3924  m_source_files.clear ();
     3925
     3926  const CmtSystem::cmt_string_vector& sources = m_constituent->modules;
     3927  const cmt_vector<cmt_regexp>& excludes = m_constituent->exclude_exprs;
     3928  const cmt_vector<cmt_regexp>& selects = m_constituent->select_exprs;
     3929
     3930  cmt_string file_name, full_name;
     3931  cmt_string compressed_name;
     3932  cmt_string visited, token;
     3933
     3934  for (int i = 0; i < sources.size (); i++)
     3935    {
     3936      file_name = sources[i];
     3937      set_full_name (full_name, file_name);
     3938      if (full_name == "") continue;
     3939     
     3940      CmtSystem::compress_path (full_name, compressed_name);
     3941      full_name = compressed_name;
     3942     
     3943      static CmtSystem::cmt_string_vector files;
     3944     
     3945      get_all_files (full_name, excludes, selects, files);
     3946     
     3947      for (int j = 0; j < files.size (); j++)
     3948        {
     3949          const cmt_string& name = files[j];
     3950             
     3951          if (name == "") continue;
     3952         
     3953          cmt_string suffix;
     3954          CmtSystem::get_suffix (name, suffix);
     3955          Language& language = Language::find_with_suffix (suffix);
     3956
     3957          if ((m_constituent->type == Application || m_constituent->type == Library)
     3958              && language != Language::null () && language.native_dependencies ())
     3959            continue;
     3960
     3961          bool included = false;
     3962          for (int k = m_source_files.size () - 1; k >= 0; k--)
     3963            if (m_source_files[k].name () == name)
     3964              {
     3965                included = true;
     3966                break;
     3967              }
     3968          if (included) continue;
     3969         
     3970          SourceFile& source = m_source_files.add ();
     3971          source.set (name, language, "");
     3972        }
     3973    }
     3974  return m_source_files.size ();
     3975}
     3976
     3977//--------------------------------------------------
     3978/**
     3979 *  Returns 0, if each file in files is found in m_source_files,
     3980 *  otherwise returns 1
     3981 */
     3982//--------------------------------------------------
     3983int DependencyGenerator::validate (const CmtSystem::cmt_string_vector& files) const
     3984{
     3985  int n_invalid = 0;
     3986  for (int i = 0; i < files.size (); i++)
     3987    {
     3988      bool valid = false;
     3989      for (int j = 0; j < m_source_files.size (); j++)
     3990        if (files[i] == m_source_files[j].name ())
     3991          {
     3992            valid = true;
     3993            break;
     3994          }
     3995      if (!valid)
     3996        {
     3997          n_invalid += 1;
     3998          break;
     3999        }
     4000    }
     4001
     4002  return n_invalid;
     4003}
  • CMT/HEAD/source/cmt_generators.h

    r561 r588  
    1111#include "cmt_fragment.h"
    1212#include "cmt_generator.h"
     13#include "cmt_deps_builder.h"
    1314
    1415class AnyDocumentGenerator : public CmtGenerator
     
    3637  void build (const cmt_string& package,
    3738              const Constituent& constituent,
     39              bool& dependencies,
    3840              const cmt_string& file = "");
     41  // returned bool& value indicates whether dependencies_fragment added to makefile
    3942
    4043private:
     
    4447                     const cmt_string& output_suffix);
    4548
     49  Variable m_FILEEXTENSION;
     50
    4651  FragmentHandle document_header_fragment;
     52  FragmentHandle dependency_fragment;
    4753};
    4854
     
    5359  void build (const cmt_string& package,
    5460              const Constituent& constituent,
     61              bool& dependencies,
    5562              const cmt_string& file = "");
     63  // returned bool& value indicates whether dependencies_fragment added to makefile
    5664
    5765protected:
     
    6371  void prepare_proto_file (const cmt_string& file);
    6472  void module_file_action (SourceFile& file, const Constituent& constituent);
     73  void fill_names_outputs ();
    6574
    6675  FragmentHandle library_header_fragment;
     
    214223};
    215224
     225class PackagesMakefileGenerator : public CmtGenerator
     226{
     227public:
     228  PackagesMakefileGenerator ();
     229  void build (const cmt_string& package,
     230              const cmt_string& file);
     231  //          const CmtSystem::cmt_string_vector& arguments);
     232
     233private:
     234  void reset ();
     235
     236  Variable m_DEPENDENCIES;
     237  Variable m_PACKAGEMGRPATH;
     238  Variable m_PACKAGEFULLNAME;
     239  Variable m_ISLOCAL;
     240
     241  FragmentHandle packages_header_fragment;
     242  FragmentHandle packages_trailer_fragment;
     243  FragmentHandle package_fragment;
     244};
     245
    216246class DependencyGenerator : public CmtGenerator
    217247{
    218248public:
    219249  void build (const CmtSystem::cmt_string_vector& arguments);
     250  void prepare_includes ();
    220251  void prepare_header_file_filters ();
    221  
    222 private:
    223   void add_line_to_text (const cmt_string& line, cmt_string& text);
     252  void reset ();
     253
     254protected:
     255  int set_source_files ();
     256  int set_source_files (const CmtSystem::cmt_string_vector& files);
     257  int validate (const CmtSystem::cmt_string_vector& files) const;
     258
     259private:
     260  void add_line_to_text (const cmt_string& line, cmt_string& text) const;
    224261  cmt_string build (const cmt_string& file_name);
     262  int fill_dependencies (cmt_string& dependencies,
     263                         const CmtSystem::cmt_string_vector& source);
     264  int fill_dependencies (cmt_string& dependencies);
     265  DepsBuilder m_deps_builder;
    225266  bool m_stamps;
     267  cmt_string m_name;
    226268};
    227269
  • CMT/HEAD/source/cmt_parser.cxx

    r575 r588  
    18881888  Cmt::reset_all_sets_done ();
    18891889  Symbol::all_set ();
     1890  if (CmtSystem::testenv ("CMTBCAST"))
     1891    CmtSystem::putenv ("CMTBCAST", "");
    18901892
    18911893  for (i = 0; i < uses.size (); i++)
     
    21252127      return;
    21262128    }
    2127   Generator::build_constituent_makefile (*constituent, out);
     2129  bool dependencies (false);
     2130  Generator::build_constituent_makefile (*constituent, dependencies, out);
    21282131//   if (ap.arguments.size () > 0)
    21292132//     {
     
    21672170      return;
    21682171    }
    2169   Generator::build_constituent_makefile (*constituent, out);
    2170   if (!constituent->has_target_tag) return;
     2172  if (!constituent->has_target_tag)
     2173    {
     2174      bool dependencies (false);
     2175      Generator::build_constituent_makefile (*constituent, dependencies, out);
     2176      return;
     2177    }
    21712178  //  cerr << "constituent: " << name << endl;
    21722179
     
    22662273        }
    22672274    }
     2275
     2276  int retval (0);
     2277
     2278  bool dependencies (false);
     2279  Generator::build_constituent_makefile (*constituent, dependencies, out);
     2280
     2281  if (dependencies)
     2282    retval = Generator::build_dependencies_infile (constituent, outdir/*, usecmt*/);
    22682283}
    22692284
     
    23002315      return;
    23012316    }
     2317  do_check_configuration (ap);
     2318  if (CmtError::get_last_error_code () == CmtError::configuration_error)
     2319    return;
     2320
    23022321  set_standard_macros ();
    23032322
     
    24152434    }
    24162435
     2436  int retval (0);
     2437
    24172438  Generator::build_constituents_makefile (Me.m_current_package, out);
    24182439  //  Generator::build_constituents_makefile (Me.m_current_package, ap.arguments);
    24192440
     2441  retval = Generator::build_library_links_infile (outdir);
     2442  if (0 != retval) return;
     2443
    24202444  const Constituent::ConstituentVector& constituents =
    24212445    Constituent::constituents ();
     2446  bool deps (false);
    24222447  for (int n = 0; n < constituents.size (); n++)
    24232448    {
    24242449      const Constituent& constituent = constituents[n];
    24252450      if (constituent.has_target_tag) continue;
    2426       Generator::build_constituent_infile (constituent, outdir, usecmt);
    2427     }
     2451
     2452      retval = Generator::build_constituent_infile (constituent, outdir, usecmt);
     2453      if (0 != retval) return;
     2454
     2455      if (!deps)
     2456        if (constituent.type == Application ||
     2457            constituent.type == Library ||
     2458            (constituent.type == Document &&
     2459             FragmentHandle (constituent.generator).need_dependencies ()))
     2460          {
     2461            deps = true;
     2462          }
     2463    }
     2464
     2465  if (deps)
     2466    retval = Generator::build_dependencies_infile (0, outdir, usecmt);
     2467}
     2468
     2469//----------------------------------------------------------
     2470void Cmt::do_build_broadcast_config (const ArgParser& ap)
     2471{
     2472  if (CmtLock::check () == CmtLock::locked_by_another_user)
     2473    {
     2474      CmtError::set (CmtError::conflicting_lock, "build_broadcast_config>");
     2475      return;
     2476    }
     2477  set_standard_macros ();
     2478
     2479  cmt_string out, outdir, name ("broadcast");
     2480  for (int i = 0; i < ap.arguments.size (); i++)
     2481    {
     2482      const cmt_string& arg = ap.arguments[i];
     2483      if (arg.substr (0, 5) == "-out=")
     2484        {
     2485          arg.substr (5, out);
     2486          CmtSystem::dirname (out, outdir);
     2487          CmtSystem::name (out, name);
     2488        }
     2489    }
     2490
     2491  cmt_string tag;
     2492  {
     2493    Symbol* macro = Symbol::find ("tag");
     2494    if (macro != 0)
     2495      {
     2496        tag = macro->build_macro_value ();
     2497        Symbol::expand (tag);
     2498      }
     2499  }
     2500  cmt_string file (tag + "_" + name);
     2501  //  cmt_string file (tag + "_uses");
     2502  if (Cmt::build_nmake ())
     2503    file += ".nmake";
     2504  else
     2505    file += ".make";
     2506  if (outdir != "")
     2507    {
     2508      if (outdir [outdir.size () - 1] != CmtSystem::file_separator ())
     2509        outdir += CmtSystem::file_separator ();
     2510      file = outdir + file;
     2511    }
     2512
     2513  ofstream t (file);
     2514  if (!t)
     2515    {
     2516      CmtError::set (CmtError::file_access_error, file);
     2517      return;
     2518    }
     2519  t.exceptions (ios::failbit | ios::badbit);
     2520  try
     2521    {
     2522//       Symbol* symbol = Symbol::find ("use_requirements");
     2523//       if (symbol != 0)
     2524//      symbol->show_macro (Make, t);
     2525      const cmt_string pattern = "^use_requirements$|.*_root$";
     2526      print_macros (Make, pattern, t);
     2527      t.close (); // ios_base::failbit
     2528    }
     2529  catch (const ios::failure& e)
     2530    {
     2531      CmtSystem::close_ostream (NULL, file + ": " + cmt_string (e.what ()));
     2532    }
     2533
     2534  Generator::build_packages_makefile (Me.m_current_package, out);
     2535  //  Generator::build_uses_makefile (Me.m_current_package, out);
    24282536}
    24292537
     
    24682576  {
    24692577    Symbol* macro = Symbol::find ("shlibsuffix");
    2470     if (macro == 0) return;
     2578    if (macro == 0)
     2579      {
     2580        if (strlen (ap.extra_file.c_str ()) == 0)
     2581          {
     2582            CmtError::set(CmtError::configuration_error, "shlibsuffix undefined");
     2583          }
     2584        else
     2585          { // we are most likely reading empty library_links.in without CMT
     2586            if (CmtMessage::active (Verbose))
     2587              CmtMessage::warning
     2588                (CmtError::get_error_name (CmtError::configuration_error)
     2589                 + ": shlibsuffix undefined");
     2590          }
     2591        return;
     2592      }
    24712593    shlibsuffix = macro->build_macro_value ();
    24722594    Symbol::expand (shlibsuffix);
     
    27162838      if (action_setup != get_action () &&
    27172839          none_style != use.style &&
    2718           0 == Project::find_in_cmt_paths (use.real_path).size ())
     2840          0 == Project::get_current ())
     2841          //      0 == Project::find_in_cmt_paths (use.real_path).size ())
    27192842        {
    2720           if (0 == CmtSystem::getenv ("CMTPEDANTIC").size () &&
    2721               0 == CmtSystem::getenv ("PEDANTIC").size ())
    2722             CmtMessage::warning
    2723               (CmtError::get_error_name (CmtError::configuration_error)
    2724                + ": Current use outside CMTPATH: " + use.get_info ());
    2725           else
    2726             CmtError::set(CmtError::configuration_error,
    2727                           "Current use outside CMTPATH: " + use.get_info ());
     2843          bool use_cmtpath_pattern (false);
     2844          static CmtPathPattern::CmtPathPatternVector& CmtPathPatterns = CmtPathPattern::patterns ();
     2845          for (int i = 0; i < CmtPathPatterns.size (); i++)
     2846            {
     2847              CmtPathPattern& p = CmtPathPatterns[i];
     2848              if (p.use->get_package ()->is_cmt () || p.is_constant ()) continue;
     2849              use_cmtpath_pattern = true;
     2850              break;
     2851            }
     2852          if (use_cmtpath_pattern)
     2853            // non-constant cmtpath_pattern found that
     2854            // cannot be applied for package outside CMTPATH
     2855            {
     2856              if (0 == CmtSystem::getenv ("CMTPEDANTIC").size () &&
     2857                  0 == CmtSystem::getenv ("PEDANTIC").size ())
     2858                CmtMessage::warning
     2859                  (CmtError::get_error_name (CmtError::configuration_error)
     2860                   + ": Package outside CMTPATH: " + use.get_info ());
     2861              else
     2862                CmtError::set(CmtError::configuration_error,
     2863                              "Package outside CMTPATH: " + use.get_info ());
     2864            }
    27282865        }
    27292866    }
     
    27372874  static CmtSystem::cmt_string_vector tags;
    27382875
    2739   CmtSystem::split (Me.m_extra_tags, " \t,", tags);
     2876  if (action_build_constituents_config != get_action ())
     2877    CmtSystem::split (Me.m_extra_tags, " \t,", tags);
    27402878
    27412879  for (int i = 0; i < tags.size (); i++)
     
    38483986  uses.push_back (&Use::current ());
    38493987  int i;
     3988  cmt_string cmtinstallarea = "";
     3989  cmt_string tag = "";
    38503990  cmt_string shlibsuffix;
    3851   cmt_string symunlink;
     3991  cmt_string symunlinkcmd;
    38523992
    38533993  {
    38543994    Symbol* macro = Symbol::find ("shlibsuffix");
    3855     if (macro == 0) return;
     3995    if (macro == 0)
     3996      {
     3997        if (strlen (ap.extra_file.c_str ()) == 0)
     3998          {
     3999            CmtError::set(CmtError::configuration_error, "shlibsuffix undefined");
     4000          }
     4001        else
     4002          { // we are most likely reading empty library_links.in without CMT
     4003            if (CmtMessage::active (Verbose))
     4004              CmtMessage::warning
     4005                (CmtError::get_error_name (CmtError::configuration_error)
     4006                 + ": shlibsuffix undefined");
     4007          }
     4008        return;
     4009      }
    38564010    shlibsuffix = macro->build_macro_value ();
    38574011    Symbol::expand (shlibsuffix);
     
    38604014  {
    38614015    Symbol* macro = Symbol::find ("symunlink");
    3862     if (macro == 0) return;
    3863     symunlink = macro->build_macro_value ();
    3864     Symbol::expand (symunlink);
     4016    if (macro != 0)
     4017      {
     4018        symunlinkcmd = macro->build_macro_value ();
     4019        Symbol::expand (symunlinkcmd);
     4020      }
    38654021  }
    38664022
    3867 //   for (i = 0; i < Uses.size (); i++)
    3868 //     {
    3869 //       Use* use = Uses[i];
     4023  if (current_use.get_strategy ("InstallArea"))
     4024    {
     4025      const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
     4026     
     4027      cmt_string s1 = ia_mgr.get_installarea ();
     4028
     4029      {
     4030        Symbol* symbol = Symbol::find ("CMTINSTALLAREA");
     4031        if (symbol != 0)
     4032          {
     4033            s1 = symbol->build_macro_value ();
     4034            Symbol::expand (s1);
     4035          }
     4036      }
     4037
     4038      cmtinstallarea = s1;
     4039                 
     4040      cmt_string s2;
     4041
     4042      {
     4043        Symbol* macro = Symbol::find ("tag");
     4044        if (macro != 0)
     4045          {
     4046            s2 = macro->build_macro_value ();
     4047            Symbol::expand (s2);
     4048          }
     4049      }
     4050
     4051      tag = s2;
     4052    }
     4053
    38704054  for (i = 0; i < uses.size (); i++)
    38714055    {
    38724056      Use* use = uses[i];
    38734057
     4058      if (use == 0) continue;
    38744059      if (use->discarded) continue;
    38754060      if (use->m_hidden) continue;
    38764061
     4062      if (use->get_package_name () == "CMT") continue;
    38774063      if (!use->located ())
    38784064        {
     
    38804066                               + " " + use->version + " " + use->path
    38814067                               + " not found");
    3882               /*
    3883           if (!Me.m_quiet)
    3884             {
    3885               cerr << "#CMT> package " << use->get_package_name () <<
    3886                 " " << use->version << " " << use->path <<
    3887                 " not found" <<
    3888                 endl;
    3889             }
    3890               */
    3891         }
    3892       else
    3893         {
    3894           if (use->get_package_name () == "CMT") continue;
    3895 //           if (use->get_package_name () == current_use.get_package_name ()) continue;
    3896 
    3897           cmt_string s;
    3898 
    3899           s = use->get_package_name ();
    3900           s += "_libraries";
    3901 
    3902           Symbol* libraries_macro = Symbol::find (s);
    3903 
    3904           if (libraries_macro == 0) continue;
    3905 
    3906           cmt_string libraries = libraries_macro->build_macro_value ();
    3907           Symbol::expand (libraries);
    3908 
    3909           static CmtSystem::cmt_string_vector values;
    3910 
    3911           CmtSystem::split (libraries, " \t", values);
    3912 
    3913           for (int j = 0; j < values.size (); j++)
    3914             {
    3915               const cmt_string& library = values[j];
    3916 
    3917               static cmt_string libname;
    3918               static cmt_string name;
    3919 
    3920               // Is it a simple name or a complete path?
    3921 
    3922               libname = library;
    3923               Symbol::expand (libname);
    3924 
    3925               if (CmtSystem::absolute_path (libname))
    3926                 {
    3927                   /**
    3928                    *   We assume here that "library" contains a complete path.
    3929                    *   (including the complete syntax libxxx.so)
    3930                    */
    3931 
    3932                   cmt_string suffix;
    3933                   CmtSystem::basename (library, name);
    3934                 }
    3935               else
    3936                 {
    3937                   /**
    3938                    *   Here we expect that only the base name of the library
    3939                    *   is given : ie it should not contain the "lib" prefix,
    3940                    *   nor the suffix .so, nor any path prefix.
    3941                    *    This of course should generally correspond to a constituent name.
    3942                    */
    3943 
    3944                   name = "lib";
    3945                   name += libname;
    3946                   name += ".";
    3947                   name += shlibsuffix;
    3948                 }
    3949 
    3950               Symbol::expand (libname);
    3951 
    3952               if (current_use.get_strategy ("InstallArea"))
    3953                 {
    3954                   const CmtInstallAreaMgr& ia_mgr = CmtInstallAreaMgr::instance ();
    3955 
    3956                   cmt_string s1 = ia_mgr.get_installarea ();
    3957 
    3958                   {
    3959                     Symbol* symbol = Symbol::find ("CMTINSTALLAREA");
    3960                     if (symbol != 0)
    3961                       {
    3962                         s1 = symbol->build_macro_value ();
    3963                         Symbol::expand (s1);
    3964                       }
    3965                   }
    3966                  
    3967                   cmt_string s2;
    3968 
    3969                   {
    3970                     Symbol* macro = Symbol::find ("tag");
    3971                     if (macro != 0)
    3972                       {
    3973                         s2 = macro->build_macro_value ();
    3974                         Symbol::expand (s2);
    3975                       }
    3976                   }
    3977 
    3978                   // Now deleting the reference file
    3979 
    3980                   s = symunlink;
    3981                   s += " ";
    3982                   s += s1;
    3983                   s += CmtSystem::file_separator ();
    3984                   s += s2;
    3985                   s += CmtSystem::file_separator ();
    3986                   s += "lib";
    3987                   s += CmtSystem::file_separator ();
    3988                   s += name;
    3989                   s += ".cmtref";
    3990                   s += " ";
    3991                   s += s1;
    3992                   s += CmtSystem::file_separator ();
    3993                   s += s2;
    3994                   s += CmtSystem::file_separator ();
    3995                   s += "lib";
    3996                   s += CmtSystem::file_separator ();
    3997                   s += name;
    3998                 }
    3999               else
    4000                 {
    4001                   s = symunlink;
    4002                   s += " ../$(";
    4003                   s += current_use.get_package_name ();
    4004                   s += "_tag)/";
    4005                   s += name;
    4006                 }
    4007 
    4008               Symbol::expand (s);
    4009 
    4010               if (!Me.m_quiet) cerr << s << endl;
    4011 
    4012               int status = CmtSystem::execute (s);
    4013 
    4014               if (status != 0)
    4015                 {
    4016                   //                  if (status != 2) CmtError::set (CmtError::execution_error, s);
    4017                   CmtError::set (CmtError::execution_error, s);
    4018 
    4019                   CmtMessage::warning ("Cannot remove the symbolic link " + s);
    4020                   //                  cerr << "#CMT> Cannot remove the symbolic link " << s << endl;
    4021 
    4022                   break;
    4023                 }
    4024             }
    4025         }
     4068          continue;
     4069        }
     4070
     4071      use->remove_library_links (cmtinstallarea, tag, shlibsuffix, symunlinkcmd);
    40264072    }
    40274073}
     
    64176463    case action_build_constituents_makefile :
    64186464    case action_build_constituents_config :
     6465    case action_build_broadcast_config :
    64196466    case action_build_dependencies :
    64206467    case action_build_library_links :
     
    65356582    case action_build_constituents_makefile :
    65366583    case action_build_constituents_config :
     6584    case action_build_broadcast_config :
    65376585    case action_build_dependencies :
    65386586    case action_build_library_links :
     
    66426690    case action_build_constituents_makefile :
    66436691    case action_build_constituents_config :
     6692    case action_build_broadcast_config :
    66446693    case action_build_dependencies :
    66456694    case action_build_library_links :
     
    67896838        case action_build_constituents_makefile :
    67906839        case action_build_constituents_config :
     6840        case action_build_broadcast_config :
    67916841        case action_build_dependencies :
    67926842        case action_build_library_links :
     
    69116961        case action_build_constituents_config :
    69126962          do_build_constituents_config (ap);
     6963          break;
     6964        case action_build_broadcast_config :
     6965          do_build_broadcast_config (ap);
    69136966          break;
    69146967        case action_build_dependencies :
     
    90429095            else
    90439096              {
    9044                 if (Me.m_action == action_build_constituents_makefile ||
    9045                     Me.m_action == action_build_constituents_config)
    9046                   CmtMessage::warning ("package " + import +
    9047                                        " cannot be imported (requested for " +
    9048                                        constituent.name +")");
     9097                if ((!constituent.has_target_tag &&
     9098                     Me.m_action == action_build_constituents_config)
     9099                    ||
     9100                    (constituent.has_target_tag &&
     9101                     Me.m_action == action_build_constituent_config))
     9102                  CmtMessage::warning
     9103                    (CmtError::get_error_name (CmtError::configuration_error)
     9104                     + ": package " + import
     9105                     + " cannot be imported (requested for "
     9106                     + (constituent.type == Application ?
     9107                        "application " : "library ")
     9108                     + constituent.name +")");
     9109               
    90499110                if (Cmt::get_debug ())
    90509111                  {
     
    90529113                         << ("package " + import +
    90539114                             " cannot be imported (requested for " +
     9115                             (constituent.type == Application ?
     9116                              "application " : "library ") +
    90549117                             constituent.name +")")  << endl;
    90559118                  }
  • CMT/HEAD/source/cmt_parser.h

    r550 r588  
    228228  action_build_constituents_makefile,
    229229  action_build_constituents_config,
     230  action_build_broadcast_config,
    230231  action_build_dependencies,
    231232  action_build_library_links,
  • CMT/HEAD/source/cmt_symbol.cxx

    r565 r588  
    19071907
    19081908  */
    1909 cmt_string Symbol::resolve_macro_value (const cmt_string& tag_name)
     1909cmt_string Symbol::resolve_macro_value (const cmt_string& tag_name) const
    19101910{
    19111911  cmt_string temp = builder->build (*this, tag_name);
     
    19331933      (action != action_build_constituents_config) &&
    19341934      (action != action_build_constituent_config) &&
     1935      (action != action_build_broadcast_config) &&
    19351936      (action != action_show_macros) &&
    19361937      (action != action_show_actions) &&
     
    19521953          (action == action_build_constituents_config) ||
    19531954          (action == action_build_constituent_config) ||
     1955          (action == action_build_broadcast_config) ||
    19541956          (action == action_load) ||
    19551957          (!Cmt::get_quiet ()))
     
    19731975      else if (action == action_build_tag_makefile ||
    19741976               action == action_build_constituents_config ||
    1975                action == action_build_constituent_config)
     1977               action == action_build_constituent_config ||
     1978               action == action_build_broadcast_config)
    19761979        {
    19771980            /*
     
    19972000          (action == action_build_constituents_config) ||
    19982001          (action == action_build_constituent_config) ||
     2002          (action == action_build_broadcast_config) ||
    19992003          (action == action_load) ||
    20002004          (!Cmt::get_quiet ()))
     
    32873291
    32883292//-------------------------------------------------------------
    3289 bool Symbol::check_tag_used (Tag* tag)
     3293bool Symbol::check_tag_used (const Tag* tag)
    32903294{
    32913295  if (tag == 0) return (false);
  • CMT/HEAD/source/cmt_symbol.h

    r549 r588  
    102102  static void filter_path_value (const cmt_string& name, cmt_string& text);
    103103
    104   static bool check_tag_used (Tag* tag);
     104  static bool check_tag_used (const Tag* tag);
    105105
    106106  static cmt_string get_env_value (const cmt_string& name);
     
    122122  int print_macro (PrintMode mode, ostream& out = cout) const;
    123123  cmt_string clean_macro_value () const;
    124   cmt_string resolve_macro_value (const cmt_string& tag_name = "");
     124  cmt_string resolve_macro_value (const cmt_string& tag_name = "") const;
    125125  void show_macro (PrintMode mode, ostream& out = cout);
    126126  //  void show_macro (PrintMode mode);
  • CMT/HEAD/source/cmt_system.cxx

    r576 r588  
    674674  if (::unlink (name) != 0)
    675675    {
    676       CmtMessage::error ("Cannot remove file " + name);
     676      //      CmtMessage::error ("Cannot remove file " + name);
    677677      //      cerr << "#CMT> Cannot remove file " << name << endl;
    678678      return (false);
  • CMT/HEAD/source/cmt_use.cxx

    r582 r588  
    16241624  // On deplace tous les pointeurs d'une case en arriere
    16251625  //
     1626  //cerr << "move-0> " << use->get_package_name () << "[" << use->m_index << "]" << endl;
    16261627  for (use_index++; use_index < size; use_index++)
    16271628    {
     
    16291630      u->m_index--;
    16301631
     1632      //cerr << "move-1> " << u->get_package_name () << "[" << u->m_index << "]" << endl;
    16311633      uses[use_index - 1] = uses[use_index];
    16321634    }
     
    16381640  use->m_index = size - 1;
    16391641  uses[size - 1] = use;
     1642  //cerr << "move-2> " << use->get_package_name () << "[" << use->m_index << "]" << endl;
    16401643}
    16411644
     
    38153818
    38163819      if (CmtMessage::active (Info))
    3817         cerr << "   Creating the reference file " << ref_file << endl;
     3820        cerr << "   Creating reference file " << ref_file << endl;
    38183821          //      if (!Cmt::get_quiet ()) cerr << "   Creating the reference file " << ref_file << endl;
    3819       text.write (ref_file);
     3822      if (!text.write (ref_file))
     3823        {
     3824          CmtError::set (CmtError::file_access_error, ref_file);
     3825          return false;
     3826        }
    38203827    }
    38213828  else
     
    38443851  if (same_dirs (source, dest))
    38453852    {
    3846       return (false);
     3853      cmt_string lname;
     3854      CmtSystem::basename (libname, lname);
     3855      if (lname == name)
     3856        return true;
    38473857    }
    38483858
     
    38553865      if (!CmtSystem::create_symlink (libname, s))
    38563866        {
    3857           CmtMessage::error ("Cannot create a symbolic link to " + libname);
     3867          CmtError::set (CmtError::file_access_error, "Cannot create symbolic link to " + libname);
     3868          //CmtMessage::error ("Cannot create a symbolic link to " + libname);
    38583869          //      cerr << "#CMT> Cannot create a symbolic link to " << libname << endl;
    38593870          return (false);
     
    38673878      cmd += " ";
    38683879      cmd += s;
    3869      
    38703880      int status = CmtSystem::execute (cmd);
    3871      
    38723881      if (status != 0)
    38733882        {
    3874           CmtMessage::error ("Cannot create a symbolic link to " + libname);
     3883          CmtError::set (CmtError::execution_error, "Cannot create symbolic link to " + libname);
     3884          //CmtMessage::error ("Cannot create a symbolic link to " + libname);
    38753885          //      cerr << "#CMT> Cannot create a symbolic link to " << libname << endl;
    38763886          return (false);
     
    38813891}
    38823892
    3883 
     3893//----------------------------------------------------------
     3894static bool uninstall_library (const cmt_string& source_library_name,
     3895                               const cmt_string& dest_library_name,
     3896                               const cmt_string& cmtinstallarea,
     3897                               const cmt_string& tag,
     3898                               const cmt_string& symunlinkcmd)
     3899{
     3900  cmt_string libname = source_library_name;
     3901  cmt_string name = dest_library_name;
     3902  cmt_string s;
     3903  Use& current_use = Use::current ();
     3904
     3905  Symbol::expand (name);
     3906  Symbol::expand (libname);
     3907
     3908  if (cmtinstallarea != "")
     3909    {
     3910      s = cmtinstallarea;
     3911      s += CmtSystem::file_separator ();
     3912      s += tag;
     3913      s += CmtSystem::file_separator ();
     3914      s += "lib";
     3915      s += CmtSystem::file_separator ();
     3916      s += name;
     3917     
     3918      // Now removing the reference file
     3919
     3920      cmt_string r = s;
     3921      r += ".cmtref";
     3922
     3923      if (CmtMessage::active (Info))
     3924        cerr << "   Removing reference file " << r << endl;
     3925      if (symunlinkcmd == "")
     3926        {
     3927          if (!CmtSystem::remove_file (r) && CmtSystem::test_file(r))
     3928            {
     3929              CmtError::set (CmtError::file_access_error, r);
     3930              return false;
     3931            }
     3932        }
     3933      else
     3934        {
     3935          cmt_string cmd (symunlinkcmd);
     3936          cmd += " ";
     3937          cmd += r;
     3938          int status = CmtSystem::execute (cmd);
     3939          if (status != 0)
     3940            {
     3941              //                  if (status != 2) CmtError::set (CmtError::execution_error, s);
     3942              CmtError::set (CmtError::execution_error, cmd);
     3943            }
     3944        }
     3945    }
     3946  else
     3947    {
     3948      if (current_use.style != none_style)
     3949        {
     3950          s = "../$(";
     3951          s += current_use.get_package_name ();
     3952          s += "_tag)/";
     3953        }
     3954      else
     3955        {
     3956          s = "./";
     3957        }
     3958      s += name;
     3959    }
     3960
     3961  Symbol::expand (s);
     3962
     3963  cmt_string source;
     3964  cmt_string dest;
     3965
     3966  CmtSystem::dirname (libname, source);
     3967  CmtSystem::dirname (s, dest);
     3968
     3969  if (same_dirs (source, dest))
     3970    {
     3971      cmt_string lname;
     3972      CmtSystem::basename (libname, lname);
     3973      if (lname == name)
     3974        return true;
     3975    }
     3976
     3977  //if (!Cmt::get_quiet ())
     3978  if (CmtMessage::active (Info))
     3979    cerr << "   Removing symlink " << s << " to " << libname << endl;
     3980
     3981  if (symunlinkcmd == "")
     3982    {
     3983      if (!CmtSystem::remove_file (s) && CmtSystem::test_file(s))
     3984        {
     3985          CmtError::set (CmtError::file_access_error, "Cannot remove symbolic link to " + libname);
     3986          return (false);
     3987        }
     3988    }
     3989  else
     3990    {
     3991      cmt_string cmd = symunlinkcmd;
     3992      cmd += " ";
     3993      cmd += s;
     3994      int status = CmtSystem::execute (cmd);
     3995      if (status != 0)
     3996        {
     3997          CmtError::set (CmtError::execution_error, "Cannot remove symbolic link to " + libname);
     3998          //CmtMessage::error ("Cannot create a symbolic link to " + libname);
     3999          //      cerr << "#CMT> Cannot create a symbolic link to " << libname << endl;
     4000          return (false);
     4001        }
     4002    }
     4003 
     4004  return (true);
     4005}
     4006
     4007//----------------------------------------------------------
    38844008/**
    3885    Centralize the construction of library links for this Use.
    3886 */
     4009 *  This function construct absolute library path
     4010 *  for libraries specified via <package>_libraries macros
     4011 *  to be used by build[remove]_library_links functions,
     4012 *  and class Generator build_library_links_infile function, in particular.
     4013 */
     4014void Use::absolute_library_path (const cmt_string& libname,
     4015                                 const cmt_string& shlibsuffix,
     4016                                 CmtSystem::cmt_string_vector& paths) const
     4017{
     4018  if (CmtSystem::absolute_path (libname))
     4019    {
     4020      paths.push_back (libname);
     4021      return;
     4022    }
     4023
     4024  /**
     4025   *   Here we expect that only the base name of the library
     4026   *   is given : ie it should not contain the "lib" prefix,
     4027   *   nor the suffix .so, nor any path prefix.
     4028   *   This of course should generally correspond to a constituent name.
     4029   */
     4030  cmt_string libpath;
     4031  if (style != none_style)
     4032    {
     4033      libpath = "${";
     4034      libpath += prefix;
     4035      libpath += "ROOT}/${";
     4036      libpath += get_package_name ();
     4037      libpath += "_tag}/";
     4038    }
     4039  else
     4040    {
     4041      libpath = "${";
     4042      libpath += prefix;
     4043      libpath += "ROOT}/";
     4044    }
     4045  libpath += "$(library_prefix)";
     4046  libpath += libname;
     4047  libpath += "$(library_suffix)";
     4048  libpath += ".";
     4049  libpath += shlibsuffix;
     4050  paths.push_back (libpath);
     4051
     4052#ifdef __APPLE__
     4053  if (style != none_style)
     4054    {
     4055      libpath = "${";
     4056      libpath += prefix;
     4057      libpath += "ROOT}/${";
     4058      libpath += get_package_name ();
     4059      libpath += "_tag}/";
     4060    }
     4061  else
     4062    {
     4063      libpath = "${";
     4064      libpath += prefix;
     4065      libpath += "ROOT}/";
     4066    }
     4067  libpath += libname;
     4068  libpath += ".bundle";
     4069  paths.push_back (libpath);
     4070#endif
     4071}
     4072
     4073//----------------------------------------------------------
     4074/**
     4075 *   Centralize the construction of library links for this Use.
     4076 */
    38874077void Use::build_library_links (const cmt_string& cmtinstallarea,
    38884078                               const cmt_string& tag,
     
    39334123      libname = library;
    39344124      Symbol::expand (libname);
    3935 
    3936       bool is_absolute = false;
    3937 
    3938       is_absolute = CmtSystem::absolute_path (libname);
    3939 
    3940       if (is_absolute)
    3941         {
    3942           /**
    3943            *   We assume here that "library" contains a complete path.
    3944            *   (including the complete syntax libxxx.so)
    3945            */
    3946 
    3947           cmt_string suffix;
    3948           CmtSystem::basename (library, name);
    3949         }
    3950       else
    3951         {
    3952           /**
    3953            *   Here we expect that only the base name of the library
    3954            *   is given : ie it should not contain the "lib" prefix,
    3955            *   nor the suffix .so, nor any path prefix.
    3956            *    This of course should generally correspond to a constituent name.
    3957            */
    3958          
    3959           if (style != none_style)
    3960             {
    3961           libname = "${";
    3962           libname += prefix;
    3963           libname += "ROOT}/${";
    3964           libname += get_package_name ();
    3965           libname += "_tag}/";
    3966             }
    3967           else
    3968             {
    3969           libname = "${";
    3970           libname += prefix;
    3971           libname += "ROOT}/";
    3972             }
    3973           libname += "$(library_prefix)";
    3974           libname += library;
    3975           libname += "$(library_suffix)";
    3976           libname += ".";
    3977           libname += shlibsuffix;
    3978 
    3979           name = "$(library_prefix)";
    3980           name += library;
    3981           name += "$(library_suffix)";
    3982           name += ".";
    3983           name += shlibsuffix;
    3984         }
    3985 
    3986       if (!install_library (libname, name, cmtinstallarea, tag, symlinkcmd))
    3987         {
    3988           continue;
    3989         }
    3990 
    3991 #ifdef __APPLE__
    3992       if (!is_absolute)
    3993         {
    3994           if (style != none_style)
    3995             {
    3996           libname = "${";
    3997           libname += prefix;
    3998           libname += "ROOT}/${";
    3999           libname += get_package_name ();
    4000           libname += "_tag}/";
    4001             }
    4002           else
    4003             {
    4004           libname = "${";
    4005           libname += prefix;
    4006           libname += "ROOT}/";
    4007             }
    4008           libname += library;
    4009           libname += ".bundle";
    4010 
    4011           name = library;
    4012           name += ".bundle";
    4013          
    4014           if (!install_library (libname, name, cmtinstallarea, tag, symlinkcmd))
    4015             {
    4016               continue;
    4017             }
    4018         }
    4019 #endif
     4125      if (0 == libname.size ()) continue;
     4126
     4127      CmtSystem::cmt_string_vector paths;
     4128      absolute_library_path (libname,
     4129                             shlibsuffix,
     4130                             paths);
     4131
     4132      for (int k = 0; k < paths.size (); k++)
     4133        {
     4134          CmtSystem::basename (paths[k], name);
     4135          if (!install_library (paths[k], name, cmtinstallarea, tag, symlinkcmd))
     4136            {
     4137              CmtError::print ();
     4138            }
     4139        }
     4140    }
     4141}
     4142//----------------------------------------------------------
     4143/**
     4144 *   Centralize the removal of library links for this Use.
     4145 */
     4146void Use::remove_library_links (const cmt_string& cmtinstallarea,
     4147                                const cmt_string& tag,
     4148                                const cmt_string& shlibsuffix,
     4149                                const cmt_string& symunlinkcmd) const
     4150{
     4151  if (!located ())
     4152    {
     4153      CmtMessage::warning ("package " + get_package_name ()
     4154                           + " " + version + " " + path
     4155                           + " not found");
     4156      return;
     4157    }
     4158
     4159  cmt_string s;
     4160
     4161  s = get_package_name ();
     4162  s += "_libraries";
     4163
     4164  Symbol* libraries_macro = Symbol::find (s);
     4165
     4166  if (libraries_macro == 0) return;
     4167
     4168  cmt_string libraries = libraries_macro->build_macro_value ();
     4169  Symbol::expand (libraries);
     4170  static CmtSystem::cmt_string_vector values;
     4171
     4172  CmtSystem::split (libraries, " \t", values);
     4173
     4174  for (int j = 0; j < values.size (); j++)
     4175    {
     4176      const cmt_string& library = values[j];
     4177
     4178      static cmt_string libname;
     4179      static cmt_string name;
     4180
     4181      // Is it a simple name or a complete path?
     4182
     4183      libname = library;
     4184      Symbol::expand (libname);
     4185      if (0 == libname.size ()) continue;
     4186
     4187      CmtSystem::cmt_string_vector paths;
     4188      absolute_library_path (libname,
     4189                             shlibsuffix,
     4190                             paths);
     4191     
     4192      for (int k = 0; k < paths.size (); k++)
     4193        {
     4194          CmtSystem::basename (paths[k], name);
     4195          if (!uninstall_library (paths[k], name, cmtinstallarea, tag, symunlinkcmd))
     4196            {
     4197              CmtError::print ();
     4198            }
     4199        }
    40204200    }
    40214201}
  • CMT/HEAD/source/cmt_use.h

    r582 r588  
    118118                            const cmt_string& shlibsuffix,
    119119                            const cmt_string& symlinkcmd) const;
    120 
     120  void remove_library_links (const cmt_string& cmtinstallarea,
     121                             const cmt_string& tag,
     122                             const cmt_string& shlibsuffix,
     123                             const cmt_string& symunlinkcmd) const;
     124 
    121125  bool get_all_clients (const cmt_string& to_name);
    122126
     
    152156  bool is_head_version (const cmt_string& version);
    153157  void clear ();
     158  void absolute_library_path (const cmt_string& libname,
     159                              const cmt_string& shlibsuffix,
     160                              CmtSystem::cmt_string_vector& paths) const;
    154161// Public attributes
    155162public:
  • CMT/HEAD/src/Makefile.core

    r556 r588  
    135135# add to the list of valid suffixes
    136136# so that nonterminal match-anything rules will not be considered
    137 .SUFFIXES: .make .stamp .cxx
     137.SUFFIXES: .make .in .stamp .cxx
  • CMT/HEAD/src/Makefile.header

    r547 r588  
    1919
    2020cmt_local_tagfile = $(bin)$(tag).make
     21cmt_broadcast_tagfile = $(bin)$(tag)_broadcast.make
    2122
    2223cmt_constituents_makefile = $(bin)constituents.make
    23 
    24 cmt_local_setup = $(bin)setup$$$$.make
    25 #cmt_local_setup = $(bin)$(package)setup$$$$.make
    26 #cmt_final_setup = $(bin)${PACKAGE}setup.make
     24cmt_broadcast_makefile = $(bin)broadcast.make
     25
    2726cmt_final_setup = $(bin)setup.make
    28 #cmt_final_setup = $(bin)$(package)setup.make
    29 
    30 #
    31 #  Generic entry points for all targets
    32 #
    33 #ifndef QUICK
    34 #all :: check_config ;
    35 #else
    36 #all :: no_check_config ;
    37 #endif
    38 #all :: $(cmt_constituents_makefile)
    39 #       @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
    40 default :: all ;
     27
     28cmt_check_configurationstamp = $(bin)cmt_check_configuration.stamp
     29
     30ifdef CMTBCAST
     31QUICK = 1
     32endif
     33
     34ifdef QUICK
     35ifndef CMTBCAST
     36
     37ifneq ($(MAKECMDGOALS),binclean)
     38ifneq ($(MAKECMDGOALS),help)
     39cmt_included = 1
     40-include $(cmt_local_tagfile)
     41endif
     42endif
     43
     44else
     45
     46ifneq ($(MAKECMDGOALS),help)
     47cmt_included = 1
     48-include $(cmt_broadcast_tagfile)
     49endif
     50
     51endif
     52endif
     53
     54all ::
     55ifndef CMTBCAST
     56ifndef cmt_included
     57        @$(MAKE) $(cmt_constituents_makefile)
     58endif
     59        $(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
     60else
     61ifndef cmt_included
     62        @$(MAKE) $(cmt_broadcast_makefile)
     63endif
     64        @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@
     65endif
     66
     67.DEFAULT :
     68ifndef CMTBCAST
     69ifndef cmt_included
     70        @$(MAKE) $(cmt_constituents_makefile)
     71endif
     72        @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
     73else
     74ifndef cmt_included
     75        @$(MAKE) $(cmt_broadcast_makefile)
     76endif
     77        @$(MAKE) --no-print-directory -f $(cmt_broadcast_makefile) CMTBCAST= $@
     78endif
    4179
    4280check_config ::
    43         @$(cmtexe) check configuration; retval=$$?; \
    44         if test $${retval} -ne 0; then \
    45           test -z "$(cmtmsg)" || \
    46           echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \
    47         fi; exit $${retval}
    48 
    49 #       @$(cmtexe) check configuration; retval=$$?; \
    50 #       if test $${retval} = 0; then \
    51 #         $(MAKE) --no-print-directory target="all" common_target; \
    52 #       else \
    53 #         test -z "$(cmtmsg)" || \
    54 #         echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \
    55 #       fi
    56 
    57 #no_check_config ::
    58 #       @$(MAKE) --no-print-directory target="all" common_target
    59 
    60 binclean ::
    61         if test ! "$(bin)" = "./"; then \
    62           if test -d $(bin) ; then \
    63             test -z "$(cmtmsg)" || \
    64             echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \
    65             \rm -rf $(bin) ; \
    66           fi ; \
    67         fi
    68 
    69 #clean uninstall :: check_config
    70 #       @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
    71 #       @$(cmtexe) check configuration
    72 #       @$(MAKE) --no-print-directory target="$@" common_target
    73 
    74 .DEFAULT ::
    75         @$(MAKE) $(cmt_constituents_makefile)
    76         @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $@
    77 
    78 #       @$(cmtexe) check configuration
    79 #       @$(MAKE) --no-print-directory target="$@" common_target
    80 #       @$(MAKE) --no-print-directory target="config $@" common_target
    81 
    82 #
    83 #  Capture all possible targets
    84 #
    85 #common_target : $(cmt_constituents_makefile)
    86 #       @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $(target)
    87 
    88 #$(cmt_constituents_makefile) : $(cmt_local_tagfile)
     81        +@$(cmtexe) check configuration; retval=$$?; \
     82          if test $${retval} -ne 0; then \
     83            test -z "$(cmtmsg)" || \
     84            echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \
     85          fi; exit $${retval}
     86
     87$(cmt_check_configurationstamp) : $(use_requirements)
     88        +@$(cmtexe) check configuration; retval=$$?; \
     89          if test $${retval} -ne 0; then \
     90            test -z "$(cmtmsg)" || \
     91            echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \
     92          fi; exit $${retval}
     93        +$(silent) if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi && \touch $@
     94#       echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; exit 17
    8995
    9096ifndef QUICK
    91 $(cmt_constituents_makefile) : check_config
    92 else
    93 $(cmt_constituents_makefile) :
    94 endif
    95         $(echo) "(Makefile.header) Rebuilding $@"; \
     97$(cmt_constituents_makefile) ::
     98#$(cmt_constituents_makefile) : check_config
     99else
     100$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(use_requirements)
     101#$(cmt_local_tagfile) $(cmt_constituents_makefile) : $(cmt_check_configurationstamp)
     102endif
     103        +$(echo) "(Makefile.header) Rebuilding $@"; \
    96104          if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \
    97           $(cmtexe) -tag=$(tags) build constituents_config -out=$@; \
     105          $(cmtexe) -tag=$(tags) build constituents_config -out=$(cmt_constituents_makefile); \
    98106          retval=$$?; \
    99107          if test $${retval} -ne 0; then \
     
    105113
    106114ifndef QUICK
    107 $(cmt_local_tagfile) ::
    108 else
    109 $(cmt_local_tagfile) :
    110 endif
    111         $(echo) "(Makefile.header) Rebuilding $@"; \
    112           if test -f $@; then rm -f $@; fi; \
    113           if test ! -d $(@D); then $(mkdir) -p $(@D); fi; \
    114           $(cmtexe) -tag=$(tags) build tag_makefile >$@
    115         $(echo) "(Makefile.header) Rebuilding $(cmt_final_setup)"; \
    116           test ! -f $(cmt_local_setup) || \rm -f $(cmt_local_setup); \
    117           trap '\rm -f $(cmt_local_setup)' 0 1 2 15; \
    118           $(cmtexe) -tag=$(tags) show setup >$(cmt_local_setup) && \
    119           if [ -f $(cmt_final_setup) ] && \
    120             \cmp -s $(cmt_final_setup) $(cmt_local_setup); then \
    121             \rm $(cmt_local_setup); else \
    122             \mv -f $(cmt_local_setup) $(cmt_final_setup); fi
     115$(cmt_broadcast_makefile) ::
     116#$(cmt_broadcast_makefile) : check_config
     117else
     118$(cmt_broadcast_tagfile) $(cmt_broadcast_makefile) : $(use_requirements)
     119#$(cmt_broadcast_makefile) : $(cmt_check_configurationstamp)
     120endif
     121        +$(echo) "(Makefile.header) Rebuilding $@"; \
     122          if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \
     123          $(cmtexe) -tag=$(tags) build broadcast_config -out=$(cmt_broadcast_makefile); \
     124          retval=$$?; \
     125          if test $${retval} -ne 0; then \
     126            test -z "$(cmtmsg)" || \
     127            echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot generate $@" >&2; \
     128            \rm -f $@; \
     129          fi; \
     130          exit $${retval}
    123131
    124132#
     
    134142everywhere :: $(everywhere)
    135143
     144ifndef CMTBCAST
     145binclean ::
     146        if _bin=`cd $(bin) 2>/dev/null&&pwd -P`&&_cur=`pwd -P`&&[ -n "$${_bin}" ]&&[ "$${_cur#$${_bin}}" = "$${_cur}" ] ; then \
     147            test -z "$(cmtmsg)" || \
     148            echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \
     149            \rm -rf $(bin) ; \
     150        fi
     151endif
     152
    136153#
    137154#   Display all targets
    138155#
    139156help ::
     157ifndef CMTBCAST
    140158        @echo '--------------------------------------------------------------------------'
    141159        @echo 'You may select one of the following make targets :'
     
    160178        @echo '              run all applications defined with the -check option'
    161179        @echo ' '
    162 
    163 
    164 # explicit rule not to remake
     180        @echo 'To switch to BCAST mode, set CMTBCAST to non-empty string.'
     181else
     182        @echo 'Targets for BCAST mode:'
     183        @echo
     184        @echo 'help        : this help'
     185ifndef BCAST_ONLY
     186ifndef BCAST_GLOBAL
     187        @echo 'all         : (re)build all used packages in current project (this is default target)'
     188else
     189        @echo 'all         : (re)build all used packages in all projects (this is default target)'
     190endif
     191else
     192        @echo 'all         : (re)build current package (this is default target)'
     193endif
     194        @echo 'clean       : remove everything that can be rebuilt'
     195        @echo 'binclean    : fast erase of binary directories (and installation area)'
     196        @echo 'uninstall   : remove everything installed in the installation area'
     197        @echo
     198ifndef BCAST_GLOBAL
     199        @uses=`$(cmtexe) -private show macros '_project$$|package$$' -tag=$(tags)| \
     200          awk -F = '{if ($$1 ~ /_project$$/) {uses[substr($$1,1,length($$1)-8)]=$$2}else if ($$1 == "package") {cur = $$2;gsub("'\''","",cur)}}END{for (u in uses){if (uses[u]==uses[cur]) print u}}'`; \
     201          for u in $${uses}; do \
     202            echo "$${u} : (re)build package $${u} ($(_groups))"; \
     203            echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \
     204            echo "$${u}binclean : fast erase of binary directory in package $${u}"; \
     205            echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \
     206          done
     207else
     208        @uses=`$(cmtexe) -private show macros '_root$$' -tag=$(tags)| \
     209          awk -F = '{u=substr($$1,1,length($$1)-5);if (u != "CMT" && u != "CMTHOME" && u != "CMTUSERCONTEXT") print u}'`; \
     210          for u in $${uses}; do \
     211            echo "$${u} : (re)build package $${u} ($(_groups))"; \
     212            echo "$${u}clean : remove everything that can be rebuilt in package $${u}"; \
     213            echo "$${u}binclean : fast erase of binary directory in package $${u}"; \
     214            echo "$${u}uninstall : remove everything installed in the installation area from package $${u}"; \
     215          done
     216endif
     217        @echo
     218ifndef BCAST_ONLY
     219        @echo '   ... with dependencies packages (may be ignored by setting BCAST_ONLY).'
     220else
     221        @echo '   ... without dependencies packages (may be included by unsetting BCAST_ONLY).'
     222endif
     223        @echo
     224ifndef BCAST_GLOBAL
     225        @echo 'To (re)build packages in all projects, set BCAST_GLOBAL.'
     226else
     227        @echo 'To (re)build packages in current project, unset BCAST_GLOBAL.'
     228endif
     229ifndef NO_ALL_GROUPS
     230        @echo 'To (re)build default group only, set NO_ALL_GROUPS.'
     231ifndef CMTACTIONS
     232        @echo 'To also (re)build cmt_actions group, set CMTACTIONS.'
     233endif
     234else
     235        @echo 'To (re)build all groups, unset NO_ALL_GROUPS.'
     236endif
     237        @echo
     238        @echo 'To switch to PACKAGE mode, unset CMTBCAST.'
     239endif
     240
     241ifndef NO_ALL_GROUPS
     242ifndef CMTACTIONS
     243_groups = all groups except cmt_actions
     244else
     245_groups = all groups
     246endif
     247else
     248_groups = default group
     249endif
     250
     251# explicit rule to avoid implicit rule search
     252# and not to remake
    165253${CMTROOT}/src/Makefile.header : ;
     254${CMTROOT}/src/Makefile.core : ;
     255ifdef use_requirements
     256$(use_requirements) : ;
     257endif
    166258
    167259# for multiple command line goals,
  • CMT/HEAD/src/setup.csh

    r584 r588  
    5454
    5555alias jcmt '(java cmt_parser)'
     56
     57# Set MAKEFLAGS, if unset (similar to NPROC with Plan 9 mk utility)
     58if ( $?MAKEFLAGS == 0 ) then
     59  setenv MAKEFLAGS -j`getconf _NPROCESSORS_ONLN` || unsetenv MAKEFLAGS
     60  if ( $?MAKEFLAGS == 1 ) then
     61    setenv MAKEFLAGS "${MAKEFLAGS} QUICK=1"
     62  else
     63    setenv MAKEFLAGS "QUICK=1"
     64  endif
     65endif
  • CMT/HEAD/src/setup.sh

    r585 r588  
    1111fi
    1212
    13 if [ `expr $- : '.*i'` -ne 0 ]; then
     13if [ -n "$-" ] && [ "${-#*i}" != "$-" ]; then
    1414if [ -n "${ZSH_NAME-}" ]; then
    1515  . ${CMTROOT}/src/setup.zsh
     
    4747
    4848alias jcmt='(java cmt_parser)'; export jcmt
     49
     50# Set MAKEFLAGS, if unset (similar to NPROC with Plan 9 mk utility)
     51if [ -z ${MAKEFLAGS+CMT} ]; then
     52  MAKEFLAGS=-j`getconf _NPROCESSORS_ONLN 2>/dev/null` && export MAKEFLAGS || unset MAKEFLAGS
     53  if [ -n "${MAKEFLAGS:-}" ]; then
     54    MAKEFLAGS="${MAKEFLAGS} QUICK=1"
     55  else
     56    MAKEFLAGS="QUICK=1"
     57  fi
     58  export MAKEFLAGS
     59fi
Note: See TracChangeset for help on using the changeset viewer.