Makefile.in
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Nov 16 21:55:46 2008 +0000 (2008-11-16)
changeset 1047 0c450efc5e3f
parent 899 da93630960d1
child 1048 06521debb8ed
permissions -rw-r--r--
Honor the DESTDIR variable to install out-of-place (Eg. for packaging).

/trunk/configure | 10 10 0 0 +++++++++
/trunk/Makefile.in | 62 36 26 0 +++++++++++++++++++++++++++++++-----------------------
/trunk/docs/overview.txt | 12 12 0 0 ++++++++++
3 files changed, 58 insertions(+), 26 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 # Sanity checks
    10 
    11 # Check if Makefile is up to date:
    12 Makefile: Makefile.in
    13 	@echo "$< did changed: you must re-run './configure'"
    14 	@false
    15 
    16 # If installing with DESTDIR, check it's an absolute path
    17 ifneq ($(strip $(DESTDIR)),)
    18   ifneq ($(DESTDIR),$(abspath /$(DESTDIR)))
    19     $(error DESTDIR is not an absolute PATH: '$(DESTDIR)')
    20   endif
    21 endif
    22 
    23 ###############################################################################
    24 # Configuration variables
    25 
    26 VERSION:= @@VERSION@@
    27 BINDIR := @@BINDIR@@
    28 LIBDIR := @@LIBDIR@@
    29 DOCDIR := @@DOCDIR@@
    30 MANDIR := @@MANDIR@@
    31 DATE   := @@DATE@@
    32 LOCAL  := @@LOCAL@@
    33 MAKE   := $(shell which $(MAKE) || type -p $(MAKE) || echo /usr/bin/make)
    34 
    35 ###############################################################################
    36 # Global make rules
    37 
    38 TARGETS := bin lib doc man
    39 
    40 build: $(patsubst %,build-%,$(TARGETS))
    41 
    42 install: local-test build $(patsubst %,install-%,$(TARGETS))
    43 
    44 clean: $(patsubst %,clean-%,$(TARGETS))
    45 
    46 distclean: clean
    47 	@echo "  RM     'Makefile'"
    48 	@rm -f Makefile
    49 
    50 uninstall: local-test $(patsubst %,uninstall-%,$(TARGETS))
    51 
    52 ###############################################################################
    53 # Specific make rules
    54 
    55 #--------------------------------------
    56 # Build rules
    57 
    58 build-bin: ct-ng
    59 	@echo "  CHMOD  '$<'"
    60 	@chmod a+x $<
    61 
    62 build-lib:
    63 
    64 build-doc:
    65 
    66 build-man: docs/ct-ng.1.gz
    67 
    68 docs/ct-ng.1.gz: docs/ct-ng.1
    69 	@echo "  GZIP   '$@'"
    70 	@gzip -c9 $< >$@
    71 
    72 %: %.in Makefile
    73 	@echo "  SED    '$@'"
    74 	@sed -r -e 's,@@CT_MAKE@@,$(MAKE),g;'       \
    75 	        -e 's,@@CT_BINDIR@@,$(BINDIR),g;'   \
    76 	        -e 's,@@CT_LIBDIR@@,$(LIBDIR),g;'   \
    77 	        -e 's,@@CT_DOCDIR@@,$(DOCDIR),g;'   \
    78 	        -e 's,@@CT_MANDIR@@,$(MANDIR),g;'   \
    79 	        -e 's,@@CT_VERSION@@,$(VERSION),g;'	\
    80 	        -e 's,@@CT_DATE@@,$(DATE),g;'       \
    81 	     $@.in >$@
    82 
    83 #--------------------------------------
    84 # Clean rules
    85 
    86 clean-bin:
    87 	@echo "  RM     'ct-ng'"
    88 	@rm -f ct-ng
    89 
    90 clean-lib:
    91 
    92 clean-doc:
    93 
    94 clean-man:
    95 	@echo "  RM     'docs/ct-ng.1'"
    96 	@rm -f docs/ct-ng.1
    97 	@echo "  RM     'docs/ct-ng.1.gz'"
    98 	@rm -f docs/ct-ng.1.gz
    99 
   100 #--------------------------------------
   101 # Check for --local setup
   102 
   103 # If using locally, don't install
   104 local-test:
   105 	@if [ "$(LOCAL)" = "1" ]; then                                          \
   106 	     echo "You're using local copy as runtime. You can't (un)install."; \
   107 	     false;                                                             \
   108 	 fi
   109 
   110 #--------------------------------------
   111 # Install rules
   112 
   113 install-bin: $(DESTDIR)$(BINDIR)
   114 	@echo "  INST   'ct-ng'"
   115 	@install -m 755 ct-ng "$(DESTDIR)$(BINDIR)/ct-ng"
   116 
   117 # If one is hacking crosstool-NG, the patch set might change between any two
   118 # installations of the same VERSION, thus the patches must be removed prior
   119 # to being installed. It is simpler to remove the whole lib/ directory, as it
   120 # is the goal of the install-lib rule to install the lib/ directory...
   121 install-lib: uninstall-lib $(DESTDIR)$(LIBDIR) install-lib-main install-lib-samples
   122 
   123 install-lib-main: $(LIBDIR)
   124 	@for src_dir in config kconfig patches scripts tools; do                        \
   125 	     echo "  INST   '$${src_dir}/'";                                            \
   126 	     tar cf - --exclude=.svn $${src_dir} |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -); \
   127 	 done
   128 	@rm -f "$(DESTDIR)$(LIBDIR)/tools/addToolVersion.sh"
   129 	@echo "  INST   'steps.mk'"
   130 	@install -m 644 steps.mk "$(DESTDIR)$(LIBDIR)/steps.mk"
   131 
   132 # Samples need a little love:
   133 #  - change every occurrence of CT_TOP_DIR to CT_LIB_DIR
   134 install-lib-samples: $(DESTDIR)$(LIBDIR) install-lib-main
   135 	@echo "  INST   'samples/'"
   136 	@tar cf - --exclude=.svn samples |(cd "$(DESTDIR)$(LIBDIR)"; tar xf -)
   137 	@for samp_file in "$(DESTDIR)$(LIBDIR)/samples/"*"/crosstool.config"; do                \
   138 	     sed -r -i -e 's,\$$\{CT_TOP_DIR\},\$$\{CT_LIB_DIR\},g;' $${samp_file};             \
   139 	     sed -r -i -e 's,^(CT_WORK_DIR)=.*,\1="\$${CT_TOP_DIR}/targets",;' $${samp_file};   \
   140 	 done
   141 
   142 install-doc: $(DESTDIR)$(DOCDIR)
   143 	@for doc_file in docs/CREDITS docs/overview.txt; do         \
   144 	     echo "  INST   '$${doc_file}'";                        \
   145 	     install -m 644 "$${doc_file}" "$(DESTDIR)$(DOCDIR)";   \
   146 	 done
   147 
   148 install-man: $(DESTDIR)$(MANDIR)
   149 	@echo "  INST   'ct-ng.1.gz'"
   150 	@install -m 644 docs/ct-ng.1.gz "$(DESTDIR)$(MANDIR)"
   151 
   152 $(sort $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(DOCDIR) $(DESTDIR)$(MANDIR)):
   153 	@echo "  MKDIR  '$@'"
   154 	@install -m 755 -d "$@"
   155 
   156 
   157 #--------------------------------------
   158 # Uninstall rules
   159 
   160 uninstall-bin:
   161 	@echo "  RM     '$(DESTDIR)$(BINDIR)/ct-ng'"
   162 	@rm -f "$(DESTDIR)$(BINDIR)/ct-ng"
   163 
   164 uninstall-lib:
   165 	@echo "  RMDIR  '$(DESTDIR)$(LIBDIR)/'"
   166 	@rm -rf "$(DESTDIR)$(LIBDIR)"
   167 
   168 uninstall-doc:
   169 	@echo "  RMDIR  '$(DESTDIR)$(DOCDIR)/'"
   170 	@rm -rf "$(DESTDIR)$(DOCDIR)"
   171 
   172 uninstall-man:
   173 	@echo "  RM     '$(DESTDIR)$(MANDIR)/ct-ng.1.gz'"
   174 	@rm -f "$(DESTDIR)$(MANDIR)/ct-ng.1"{,.gz}