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 | ifdef READONLY |
---|
21 | cmt_local_tagfile = /tmp/CMT_$(tag).make$$$$ |
---|
22 | else |
---|
23 | cmt_local_tagfile = $(tag).make |
---|
24 | endif |
---|
25 | |
---|
26 | # |
---|
27 | # Generic entry points for all targets |
---|
28 | # |
---|
29 | all :: check_config |
---|
30 | |
---|
31 | check_config :: |
---|
32 | @$(cmtexe) check configuration; status=$$?; \ |
---|
33 | if test $${status} = 0; then \ |
---|
34 | /bin/rm -f $(cmt_local_tagfile); \ |
---|
35 | $(MAKE) --no-print-directory $(MAKEFLAGS) target="first config all" common_target; \ |
---|
36 | else \ |
---|
37 | echo "#CMT> There are configuration errors. Please correct them before running gmake"; \ |
---|
38 | fi |
---|
39 | |
---|
40 | binclean :: |
---|
41 | @if test ! "$(bin)" = "./"; then \ |
---|
42 | if test -d $(bin) ; then \ |
---|
43 | echo "------> (Makefile.header) Cleaning all from $(bin)"; \ |
---|
44 | /bin/rm -rf $(bin) ; \ |
---|
45 | fi ; \ |
---|
46 | fi |
---|
47 | |
---|
48 | clean :: |
---|
49 | @$(cmtexe) check configuration |
---|
50 | @$(MAKE) --no-print-directory target="$@" common_target |
---|
51 | |
---|
52 | .DEFAULT :: |
---|
53 | @$(cmtexe) check configuration |
---|
54 | @$(MAKE) --no-print-directory target="config $@" common_target |
---|
55 | |
---|
56 | # |
---|
57 | # Capture all possible targets |
---|
58 | # |
---|
59 | common_target :: |
---|
60 | @tmpdir=/tmp; \ |
---|
61 | if test ! "${TMPDIR}" = ""; then tmpdir=${TMPDIR}; fi; \ |
---|
62 | cmt_lock_pid=`mkdir -p $${tmpdir}; mktemp $${tmpdir}/CMT_XXXXXX | sed -e 's#'"$${tmpdir}"'/CMT_##'`; \ |
---|
63 | temp_marker=$${tmpdir}/CMT_$${cmt_lock_pid}; \ |
---|
64 | temp_lock=$${tmpdir}/CMT_lock$${cmt_lock_pid}.make; \ |
---|
65 | temp_constituents=$${tmpdir}/CMT_constituents$${cmt_lock_pid}; \ |
---|
66 | if test ! "${CMTMAKEDEBUG}" = 1; then\ |
---|
67 | trap '/bin/rm -f $${temp_lock} $${temp_constituents} $${temp_marker}; exit $${status}' 0 1 2 15; \ |
---|
68 | fi; \ |
---|
69 | /bin/rm -f $${temp_marker}; \ |
---|
70 | /bin/rm -f $${temp_lock}; \ |
---|
71 | echo "------> (Makefile.header) Rebuilding constituents.make"; \ |
---|
72 | $(cmtexe) -quiet -tag=$(tags) build constituents_makefile -out=$${temp_constituents}; status=$$?; \ |
---|
73 | if test $${status} = 0; then \ |
---|
74 | /bin/rm -f $(cmt_local_tagfile); \ |
---|
75 | $(MAKE) --no-print-directory -f $${temp_constituents} cmt_lock_pid=$${cmt_lock_pid} $(target); \ |
---|
76 | status=$$?; \ |
---|
77 | else \ |
---|
78 | echo "#CMT> Error generating constituents makefile"; \ |
---|
79 | fi; \ |
---|
80 | exit $${status} |
---|
81 | |
---|
82 | |
---|
83 | # |
---|
84 | # Ancient mechanism for remote launchers (kept for backward compatibility) |
---|
85 | # |
---|
86 | $(gmake_hosts) :: |
---|
87 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd -quiet`; . setup.sh; gmake $(MAKEFLAGS) $(target))'" |
---|
88 | |
---|
89 | $(make_hosts) :: |
---|
90 | rsh $@ "sh -c '(cd `$(cmtexe) show pwd`; . setup.sh; make $(MAKEFLAGS) $(target))'" |
---|
91 | |
---|
92 | |
---|
93 | everywhere :: $(everywhere) |
---|
94 | |
---|
95 | # |
---|
96 | # Display all targets |
---|
97 | # |
---|
98 | help :: |
---|
99 | @echo '--------------------------------------------------------------------------' |
---|
100 | @echo 'You may select one of the following make targets :' |
---|
101 | @echo ' ' |
---|
102 | @echo 'help : this help' |
---|
103 | @echo 'all : rebuild all constituents according to the $$(constituents) macro' |
---|
104 | @echo ' (this is the default target)' |
---|
105 | @echo 'clean : remove everything that can be rebuilt' |
---|
106 | @echo 'binclean : fast erase of the binary directory' |
---|
107 | @echo ' ' |
---|
108 | @groups=`$(cmtexe) show groups -quiet -tag=$(tags)`; \ |
---|
109 | for g in $${groups}; do \ |
---|
110 | echo "$${g} : rebuild all constituents of group $${g}"; \ |
---|
111 | done |
---|
112 | @echo "Constituents:"; \ |
---|
113 | for c in `$(cmtexe) show constituent_names -quiet -tag=$(tags)` ; do \ |
---|
114 | echo " $${c} $${c}clean"; \ |
---|
115 | done |
---|
116 | @echo ' ' |
---|
117 | @echo 'check :' |
---|
118 | @echo ' run all applications defined with the -check option' |
---|
119 | @echo ' ' |
---|
120 | |
---|
121 | |
---|