1 | #----------------------------------------------------------- |
---|
2 | # Copyright Christian Arnault LAL-Orsay CNRS |
---|
3 | # arnault@lal.in2p3.fr |
---|
4 | # See the complete license in cmt_license.txt "http://www.cecill.info". |
---|
5 | #----------------------------------------------------------- |
---|
6 | |
---|
7 | include ${CMTROOT}/src/Makefile.core |
---|
8 | |
---|
9 | # |
---|
10 | # Basic tag management |
---|
11 | # |
---|
12 | ifdef tag |
---|
13 | CMTEXTRATAGS = $(tag) |
---|
14 | else |
---|
15 | tag = $(CMTCONFIG) |
---|
16 | endif |
---|
17 | |
---|
18 | tags = $(tag),$(CMTEXTRATAGS) |
---|
19 | |
---|
20 | cmt_local_tagfile = $(bin)$(tag).make |
---|
21 | |
---|
22 | cmt_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 |
---|
27 | cmt_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 | |
---|
39 | check_config :: |
---|
40 | @$(cmtexe) check configuration; retval=$$?; \ |
---|
41 | if test $${retval} = 0; then \ |
---|
42 | $(MAKE) --no-print-directory target="all" common_target; \ |
---|
43 | else \ |
---|
44 | echo "#CMT> There are configuration errors. Please correct them before running gmake"; \ |
---|
45 | fi |
---|
46 | |
---|
47 | no_check_config :: |
---|
48 | @$(MAKE) --no-print-directory target="all" common_target |
---|
49 | |
---|
50 | binclean :: |
---|
51 | if test ! "$(bin)" = "./"; then \ |
---|
52 | if test -d $(bin) ; then \ |
---|
53 | test -z "$(cmtmsg)" || \ |
---|
54 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \ |
---|
55 | /bin/rm -rf $(bin) ; \ |
---|
56 | fi ; \ |
---|
57 | fi |
---|
58 | |
---|
59 | clean :: |
---|
60 | @$(cmtexe) check configuration |
---|
61 | @$(MAKE) --no-print-directory target="$@" common_target |
---|
62 | |
---|
63 | .DEFAULT :: |
---|
64 | @$(cmtexe) check configuration |
---|
65 | @$(MAKE) --no-print-directory target="$@" common_target |
---|
66 | # @$(MAKE) --no-print-directory target="config $@" common_target |
---|
67 | |
---|
68 | # |
---|
69 | # Capture all possible targets |
---|
70 | # |
---|
71 | common_target : $(cmt_constituents_makefile) |
---|
72 | @$(MAKE) --no-print-directory -f $(cmt_constituents_makefile) $(target) |
---|
73 | # @$(MAKE) --no-print-directory -f $< cmt_lock_pid=$(cmt_lock_pid) $(target) |
---|
74 | |
---|
75 | $(cmt_constituents_makefile) : $(cmt_local_tagfile) |
---|
76 | $(echo) "(Makefile.header) Rebuilding $@"; \ |
---|
77 | if test ! -d $(@D) ; then $(mkdir) -p $(@D); fi; \ |
---|
78 | $(cmtexe) -tag=$(tags) build constituents_makefile -out=$@; \ |
---|
79 | retval=$$?; \ |
---|
80 | if test $${retval} != 0; then \ |
---|
81 | test -z "$(cmtmsg)" || \ |
---|
82 | echo "$(CMTMSGPREFIX)" "(Makefile.header) Cannot generate $@" >&2; \ |
---|
83 | \rm -f $@; \ |
---|
84 | fi; \ |
---|
85 | exit $${retval} |
---|
86 | |
---|
87 | ifndef QUICK |
---|
88 | $(cmt_local_tagfile) :: |
---|
89 | else |
---|
90 | $(cmt_local_tagfile) : |
---|
91 | endif |
---|
92 | $(echo) "(Makefile.header) Rebuilding $@"; \ |
---|
93 | if test -f $@; then rm -f $@; fi; \ |
---|
94 | if test ! -d $(@D); then $(mkdir) -p $(@D); fi; \ |
---|
95 | $(cmtexe) -tag=$(tags) build tag_makefile >$@ |
---|
96 | $(echo) "(Makefile.header) Rebuilding $(cmt_final_setup)"; \ |
---|
97 | test ! -f $(cmt_local_setup) || \rm -f $(cmt_local_setup); \ |
---|
98 | trap '\rm -f $(cmt_local_setup)' 0 1 2 15; \ |
---|
99 | $(cmtexe) -tag=$(tags) show setup >$(cmt_local_setup) && \ |
---|
100 | if [ -f $(cmt_final_setup) ] && \ |
---|
101 | \cmp -s $(cmt_final_setup) $(cmt_local_setup); then \ |
---|
102 | \rm $(cmt_local_setup); else \ |
---|
103 | \mv -f $(cmt_local_setup) $(cmt_final_setup); fi |
---|
104 | |
---|
105 | # && /bin/echo $@ ok |
---|
106 | # $(echo) CMTCONFIG=$(CMTCONFIG) ; \ |
---|
107 | # |
---|
108 | |
---|
109 | # |
---|
110 | # Ancient mechanism for remote launchers (kept for backward compatibility) |
---|
111 | # |
---|
112 | $(gmake_hosts) :: |
---|
113 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; gmake $(MAKEFLAGS) $(target))'" |
---|
114 | |
---|
115 | $(make_hosts) :: |
---|
116 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'" |
---|
117 | |
---|
118 | |
---|
119 | everywhere :: $(everywhere) |
---|
120 | |
---|
121 | # |
---|
122 | # Display all targets |
---|
123 | # |
---|
124 | help :: |
---|
125 | @echo '--------------------------------------------------------------------------' |
---|
126 | @echo 'You may select one of the following make targets :' |
---|
127 | @echo ' ' |
---|
128 | @echo 'help : this help' |
---|
129 | @echo 'all : rebuild all constituents according to the $$(constituents) macro' |
---|
130 | @echo ' (this is the default target)' |
---|
131 | @echo 'clean : remove everything that can be rebuilt' |
---|
132 | @echo 'binclean : fast erase of the binary directory' |
---|
133 | @echo 'uninstall : remove everything installed in the installation area' |
---|
134 | @echo ' ' |
---|
135 | @groups=`$(cmtexe) show groups -tag=$(tags)`; \ |
---|
136 | for g in $${groups}; do \ |
---|
137 | echo "$${g} : rebuild all constituents of group $${g}"; \ |
---|
138 | done |
---|
139 | @echo "Constituents:"; \ |
---|
140 | for c in `$(cmtexe) show constituent_names -tag=$(tags)` ; do \ |
---|
141 | echo " $${c} $${c}clean $${c}uninstall"; \ |
---|
142 | done |
---|
143 | @echo ' ' |
---|
144 | @echo 'check :' |
---|
145 | @echo ' run all applications defined with the -check option' |
---|
146 | @echo ' ' |
---|
147 | |
---|
148 | |
---|
149 | # explicit rule not to remake |
---|
150 | ${CMTROOT}/src/Makefile.header : ; |
---|