1 # Makefile.in for building crosstool-NG
2 # This file serves as source for the ./configure operation
4 # This series of test is here because GNU make 3.81 will *not* use MAKEFLAGS
5 # to set additional flags in the current Makfile ( see:
6 # http://savannah.gnu.org/bugs/?20501 ), although the make manual says it
7 # should ( see: http://www.gnu.org/software/make/manual/make.html#Options_002fRecursion )
8 # so we have to work it around by calling ourselves back if needed
10 # So why do we need not to use the built rules and variables? Because we
11 # need to generate scripts/crosstool-NG.sh from scripts/crosstool-NG.sh.in
12 # and there is a built-in implicit rule '%.sh:' that has neither a pre-requisite
13 # nor a command associated, and that built-in implicit rule takes precedence
14 # over our non-built-in implicit rule '%: %.in', below.
16 # CT_MAKEFLAGS will be used later, below...
18 # Do not print directories as we descend into them
19 ifeq ($(filter --no-print-directory,$(MAKEFLAGS)),)
20 CT_MAKEFLAGS += --no-print-directory
23 # Use neither builtin rules, nor builtin variables
24 # Note: dual test, because if -R and -r are given on the command line
25 # (who knows?), MAKEFLAGS contains 'Rr' instead of '-Rr', while adding
26 # '-Rr' to MAKEFLAGS adds it literaly ( and does not add 'Rr' )
27 ifeq ($(filter Rr,$(MAKEFLAGS)),)
28 ifeq ($(filter -Rr,$(MAKEFLAGS)),)
33 # Remove any suffix rules
38 ###############################################################################
39 # Configuration variables
49 # Paths found by ./configure
57 ###############################################################################
60 # Check if Makefile is up to date:
62 @echo "$< did changed: you must re-run './configure'"
65 # If installing with DESTDIR, check it's an absolute path
66 ifneq ($(strip $(DESTDIR)),)
67 ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
68 $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
72 ###############################################################################
75 # If any extra MAKEFLAGS were added, re-run ourselves
76 # See top of file for an explanation of why this is needed...
77 ifneq ($(strip $(CT_MAKEFLAGS)),)
79 MAKEFLAGS += $(CT_MAKEFLAGS)
80 build install clean distclean uninstall:
84 # There were no additional MAKEFLAGS to add, do the job
86 TARGETS := bin lib doc man
88 build: $(patsubst %,build-%,$(TARGETS))
90 install: build real-install
92 clean: $(patsubst %,clean-%,$(TARGETS))
95 @echo " RM 'Makefile'"
98 uninstall: real-uninstall
100 ###############################################################################
101 # Specific make rules
103 #--------------------------------------
106 build-bin: ct-ng scripts/crosstool-NG.sh scripts/saveSample.sh
112 build-man: docs/ct-ng.1.gz
114 docs/ct-ng.1.gz: docs/ct-ng.1
120 @$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;' \
121 -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;' \
122 -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;' \
123 -e 's,@@CT_MANDIR@@,$(MANDIR),g;' \
124 -e 's,@@CT_VERSION@@,$(VERSION),g;' \
125 -e 's,@@CT_DATE@@,$(DATE),g;' \
126 -e 's,@@CT_make@@,$(make),g;' \
127 -e 's,@@CT_bash@@,$(bash),g;' \
130 # We create a script fragment that is parseable from inside a Makefile,
131 # but also from inside a shell script, hence the reason why we don't
132 # use := to set varaibles, although that will incur a (very small)
133 # penalty from the Makefile that includes it (due to re-evaluation at
137 @(echo "export install=$(install)"; \
138 echo "export bash=$(bash)"; \
139 echo "export grep=$(grep)"; \
140 echo "export make=$(make)"; \
141 echo "export awk=$(awk)"; \
142 echo "export sed=$(sed)"; \
145 #--------------------------------------
151 @echo " RM 'script/crosstool-NG.sh'"
152 @rm -f scripts/crosstool-NG.sh
153 @echo " RM 'script/saveSample.sh'"
154 @rm -f scripts/saveSample.sh
157 @echo " RM 'paths.mk'"
163 @echo " RM 'docs/ct-ng.1'"
165 @echo " RM 'docs/ct-ng.1.gz'"
166 @rm -f docs/ct-ng.1.gz
168 #--------------------------------------
169 # Check for --local setup
171 ifeq ($(strip $(LOCAL)),1)
174 @echo " CHMOD 'ct-ng'"
176 @echo " CHMOD 'scripts/crosstool-NG.sh'"
177 @chmod a+x scripts/crosstool-NG.sh
178 @echo " CHMOD 'scripts/saveSample.sh'"
179 @chmod a+x scripts/saveSample.sh
186 #--------------------------------------
189 real-install: $(patsubst %,install-%,$(TARGETS))
191 install-bin: $(DESTDIR)$(BINDIR)
192 @echo " INST 'ct-ng'"
193 @$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
195 # If one is hacking crosstool-NG, the patch set might change between any two
196 # installations of the same VERSION, thus the patches must be removed prior
197 # to being installed. It is simpler to remove the whole lib/ directory, as it
198 # is the goal of the install-lib rule to install the lib/ directory...
199 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
201 install-lib-main: $(DESTDIR)$(LIBDIR)
202 @for src_dir in config kconfig patches scripts; do \
203 echo " INST '$${src_dir}/'"; \
204 tar cf - --exclude=.svn --exclude='*.sh.in' $${src_dir} \
205 |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
207 @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/crosstool-NG.sh
208 @chmod a+x $(DESTDIR)$(LIBDIR)/scripts/saveSample.sh
209 @rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
210 @echo " INST 'steps.mk'"
211 @$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
212 @echo " INST 'paths.mk'"
213 @$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
215 # Samples need a little love:
216 # - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
217 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
218 @echo " INST 'samples/'"
219 @tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
220 @for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do \
221 $(sed) -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file}; \
222 $(sed) -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
225 install-doc: $(DESTDIR)$(DOCDIR)
226 @for doc_file in docs/CREDITS docs/overview.txt; do \
227 echo " INST '$${doc_file}'"; \
228 $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
231 install-man: $(DESTDIR)$(MANDIR)
232 @echo " INST 'ct-ng.1.gz'"
233 @$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
235 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
237 @$(install) -m 755 -d "$@"
240 #--------------------------------------
243 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
246 @echo " RM '$(DESTDIR)$(BINDIR)/ct-ng'"
247 @rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
250 @echo " RMDIR '$(DESTDIR)$(LIBDIR)/'"
251 @rm -rf "$(DESTDIR)$(LIBDIR)"
254 @echo " RMDIR '$(DESTDIR)$(DOCDIR)/'"
255 @rm -rf "$(DESTDIR)$(DOCDIR)"
258 @echo " RM '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
259 @rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
263 endif # No extra MAKEFLAGS were added