Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jan 25 22:58:26 2009 +0000 (2009-01-25)
changeset 1153 487cb6aca0c4
parent 1152 73a8bb20ccf2
child 1154 0f15f05af399
permissions -rw-r--r--
Makefile.in: create and install the Makefile and shell-script fragment "paths.mk", containing the paths found by ./configure

/trunk/Makefile.in | 66 39 27 0 +++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 39 insertions(+), 27 deletions(-)
     1 # Makefile.in for building crosstool-NG
     2 # This file serves as source for the ./configure operation
     3 
     4 MAKEFLAGS += --no-print-directory --no-builtin-rules
     5 
     6 all: Makefile build
     7 
     8 ###############################################################################
     9 # Configuration variables
    10 
    11 VERSION:= @@VERSION@@
    12 BINDIR := @@BINDIR@@
    13 LIBDIR := @@LIBDIR@@
    14 DOCDIR := @@DOCDIR@@
    15 MANDIR := @@MANDIR@@
    16 DATE   := @@DATE@@
    17 LOCAL  := @@LOCAL@@
    18 
    19 # Paths found by ./configure
    20 install:= @@install@@
    21 bash   := @@bash@@
    22 grep   := @@grep@@
    23 make   := @@make@@
    24 awk    := @@awk@@
    25 sed    := @@sed@@
    26 
    27 ###############################################################################
    28 # Sanity checks
    29 
    30 # Check if Makefile is up to date:
    31 Makefile: Makefile.in
    32 	@echo "$< did changed: you must re-run './configure'"
    33 	@false
    34 
    35 # If installing with DESTDIR, check it's an absolute path
    36 ifneq ($(strip $(DESTDIR)),)
    37   ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
    38     $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
    39   endif
    40 endif
    41 
    42 ###############################################################################
    43 # Global make rules
    44 
    45 TARGETS := bin lib doc man
    46 
    47 build: $(patsubst %,build-%,$(TARGETS))
    48 
    49 install: build real-install
    50 
    51 clean: $(patsubst %,clean-%,$(TARGETS))
    52 
    53 distclean: clean
    54 	@echo "  RM     'Makefile'"
    55 	@rm -f Makefile
    56 
    57 uninstall: real-uninstall
    58 
    59 ###############################################################################
    60 # Specific make rules
    61 
    62 #--------------------------------------
    63 # Build rules
    64 
    65 build-bin: ct-ng
    66 
    67 build-lib: paths.mk
    68 
    69 build-doc:
    70 
    71 build-man: docs/ct-ng.1.gz
    72 
    73 docs/ct-ng.1.gz: docs/ct-ng.1
    74 	@echo "  GZIP   '$@'"
    75 	@gzip -c9 $< >$@
    76 
    77 %: %.in Makefile
    78 	@echo "  SED    '$@'"
    79 	@$(sed) -r -e 's,@@CT_BINDIR@@,$(BINDIR),g;'    \
    80 	           -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;'    \
    81 	           -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;'    \
    82 	           -e 's,@@CT_MANDIR@@,$(MANDIR),g;'    \
    83 	           -e 's,@@CT_VERSION@@,$(VERSION),g;'	\
    84 	           -e 's,@@CT_DATE@@,$(DATE),g;'        \
    85 	           -e 's,@@CT_make@@,$(make),g;'        \
    86 	           $@.in >$@
    87 
    88 # We create a script fragment that is parseable from inside a Makefile,
    89 # but also from inside a shell script, hence the reason why we don't
    90 # use := to set varaibles, although that will incur a (very small)
    91 # penalty from the Makefile that includes it (due to re-evaluation at
    92 # each call).
    93 paths.mk:
    94 	@echo "  GEN    '$@'"
    95 	@(echo "export install=$(install)"; \
    96 	  echo "export bash=$(bash)";       \
    97 	  echo "export grep=$(grep)";       \
    98 	  echo "export make=$(make)";       \
    99 	  echo "export awk=$(awk)";         \
   100 	  echo "export sed=$(sed)";         \
   101 	 ) >paths.mk
   102 
   103 #--------------------------------------
   104 # Clean rules
   105 
   106 clean-bin:
   107 	@echo "  RM     'ct-ng'"
   108 	@rm -f ct-ng
   109 
   110 clean-lib:
   111 
   112 clean-doc:
   113 
   114 clean-man:
   115 	@echo "  RM     'docs/ct-ng.1'"
   116 	@rm -f docs/ct-ng.1
   117 	@echo "  RM     'docs/ct-ng.1.gz'"
   118 	@rm -f docs/ct-ng.1.gz
   119 
   120 #--------------------------------------
   121 # Check for --local setup
   122 
   123 ifeq ($(strip $(LOCAL)),1)
   124 
   125 real-install:
   126 	@echo "  CHMOD  'ct-ng'"
   127 	@chmod a+x ct-ng
   128 
   129 real-uninstall:
   130 	@true
   131 
   132 else
   133 
   134 #--------------------------------------
   135 # Install rules
   136 
   137 real-install: $(patsubst %,install-%,$(TARGETS))
   138 
   139 install-bin: $(DESTDIR)$(BINDIR)
   140 	@echo "  INST   'ct-ng'"
   141 	@$(install) -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
   142 
   143 # If one is hacking crosstool-NG, the patch set might change between any two
   144 # installations of the same VERSION, thus the patches must be removed prior
   145 # to being installed. It is simpler to remove the whole lib/ directory, as it
   146 # is the goal of the install-lib rule to install the lib/ directory...
   147 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
   148 
   149 install-lib-main: $(DESTDIR)$(LIBDIR)
   150 	@for src_dir in config kconfig patches scripts; do                              \
   151 	     echo "  INST   '$${src_dir}/'";                                            \
   152 	     tar cf - --exclude=.svn $${src_dir} |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
   153 	 done
   154 	@rm -f "$(DESTDIR)$(LIBDIR)/scripts/addToolVersion.sh"
   155 	@echo "  INST   'steps.mk'"
   156 	@$(install) -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
   157 	@echo "  INST   'paths.mk'"
   158 	@$(install) -m 644 paths.mk "$(DESTDIR)$(LIBDIR)/paths.mk"
   159 
   160 # Samples need a little love:
   161 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   162 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
   163 	@echo "  INST   'samples/'"
   164 	@tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
   165 	@for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do                    \
   166 	     $(sed) -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file};           \
   167 	     $(sed) -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file}; \
   168 	 done
   169 
   170 install-doc: $(DESTDIR)$(DOCDIR)
   171 	@for doc_file in docs/CREDITS docs/overview.txt; do             \
   172 	     echo "  INST   '$${doc_file}'";                            \
   173 	     $(install) -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)"; \
   174 	 done
   175 
   176 install-man: $(DESTDIR)$(MANDIR)
   177 	@echo "  INST   'ct-ng.1.gz'"
   178 	@$(install) -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
   179 
   180 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
   181 	@echo "  MKDIR  '$@'"
   182 	@$(install) -m 755 -d "$@"
   183 
   184 
   185 #--------------------------------------
   186 # Uninstall rules
   187 
   188 real-uninstall: $(patsubst %,uninstall-%,$(TARGETS))
   189 
   190 uninstall-bin:
   191 	@echo "  RM     '$(DESTDIR)$(BINDIR)/ct-ng'"
   192 	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
   193 
   194 uninstall-lib:
   195 	@echo "  RMDIR  '$(DESTDIR)$(LIBDIR)/'"
   196 	@rm -rf "$(DESTDIR)$(LIBDIR)"
   197 
   198 uninstall-doc:
   199 	@echo "  RMDIR  '$(DESTDIR)$(DOCDIR)/'"
   200 	@rm -rf "$(DESTDIR)$(DOCDIR)"
   201 
   202 uninstall-man:
   203 	@echo "  RM     '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
   204 	@rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}
   205 
   206 endif # Not --local