make/devkit/Makefile
changeset 52665 61dcd7cd48c3
parent 52357 e2478be9c682
child 54148 62e4ada7c4c8
equal deleted inserted replaced
52664:15fc92f4ae9a 52665:61dcd7cd48c3
    39 # make tars BASE_OS=OEL6
    39 # make tars BASE_OS=OEL6
    40 #
    40 #
    41 # To build the full set of crosstools for additional platforms, use a command
    41 # To build the full set of crosstools for additional platforms, use a command
    42 # line looking like this:
    42 # line looking like this:
    43 #
    43 #
    44 # make cross_compile_target="aarch64-linux-gnu" BASE_OS=Fedora27
    44 # make TARGETS="aarch64-linux-gnu" BASE_OS=Fedora
    45 # or
    45 # or
    46 # make cross_compile_target="arm-linux-gnueabihf" BASE_OS=Fedora27
    46 # make TARGETS="arm-linux-gnueabihf ppc64-linux-gnu" BASE_OS=Fedora BASE_OS_VERSION=17
       
    47 #
       
    48 # to build several devkits for a specific OS version at once.
       
    49 # You can find the final results under ../../build/devkit/result/<host>-to-<target>
    47 #
    50 #
    48 # This is the makefile which iterates over all host and target platforms.
    51 # This is the makefile which iterates over all host and target platforms.
    49 #
    52 #
    50 
    53 
    51 os := $(shell uname -o)
    54 os := $(shell uname -o)
    52 cpu := $(shell uname -p)
    55 cpu := $(shell uname -p)
    53 
    56 
    54 # Figure out what platform this is building on.
    57 # Figure out what platform this is building on.
    55 me := $(cpu)-$(if $(findstring Linux,$(os)),unknown-linux-gnu)
    58 me := $(cpu)-$(if $(findstring Linux,$(os)),linux-gnu)
    56 
    59 
    57 $(info Building on platform $(me))
    60 $(info Building on platform $(me))
    58 
    61 
    59 #
    62 #
    60 # By default just build for the current platform, which is assumed to be Linux
    63 # By default just build for the current platform, which is assumed to be Linux
    61 #
    64 #
    62 ifeq ($(cross_compile_target), )
    65 ifeq ($(TARGETS), )
    63   platforms := $(me)
    66   platforms := $(me)
    64   host_platforms := $(platforms)
    67   host_platforms := $(platforms)
    65 else
    68 else
    66   platforms := $(cross_compile_target)
    69   platforms := $(TARGETS)
    67   host_platforms := $(me)
    70   host_platforms := $(me)
    68 endif
    71 endif
    69 target_platforms := $(platforms)
    72 target_platforms := $(platforms)
    70 $(info host_platforms $(host_platforms))
    73 $(info host_platforms $(host_platforms))
    71 $(info target_platforms $(target_platforms))
    74 $(info target_platforms $(target_platforms))
    77 endif
    80 endif
    78 
    81 
    79 OUTPUT_ROOT = $(abspath ../../build/devkit)
    82 OUTPUT_ROOT = $(abspath ../../build/devkit)
    80 RESULT = $(OUTPUT_ROOT)/result
    83 RESULT = $(OUTPUT_ROOT)/result
    81 
    84 
    82 submakevars = HOST=$@ BUILD=$(me) \
    85 submakevars = HOST=$@ BUILD=$(me) RESULT=$(RESULT) OUTPUT_ROOT=$(OUTPUT_ROOT)
    83     RESULT=$(RESULT) PREFIX=$(RESULT)/$@ \
    86 
    84     OUTPUT_ROOT=$(OUTPUT_ROOT)
       
    85 $(host_platforms) :
    87 $(host_platforms) :
    86 	@echo 'Building compilers for $@'
    88 	@echo 'Building compilers for $@'
    87 	@echo 'Targets: $(target_platforms)'
    89 	@echo 'Targets: $(target_platforms)'
    88 	for p in $(filter $@, $(target_platforms)) $(filter-out $@, $(target_platforms)); do \
    90 	for p in $(filter $@, $(target_platforms)) $(filter-out $@, $(target_platforms)); do \
    89 	  $(MAKE) -f Tools.gmk download-rpms $(submakevars) TARGET=$$p && \
    91 	  $(MAKE) -f Tools.gmk download-rpms $(submakevars) \
       
    92               TARGET=$$p PREFIX=$(RESULT)/$@-to-$$p && \
    90 	  $(MAKE) -f Tools.gmk all $(submakevars) \
    93 	  $(MAKE) -f Tools.gmk all $(submakevars) \
    91 	      TARGET=$$p || exit 1 ; \
    94               TARGET=$$p PREFIX=$(RESULT)/$@-to-$$p && \
       
    95 	  $(MAKE) -f Tools.gmk ccache $(submakevars) \
       
    96               TARGET=$@ PREFIX=$(RESULT)/$@-to-$$p BUILDDIR=$(OUTPUT_ROOT)/$@/$$p || exit 1 ; \
    92 	done
    97 	done
    93 	@echo 'Building ccache program for $@'
       
    94 	$(MAKE) -f Tools.gmk ccache $(submakevars) TARGET=$@
       
    95 	@echo 'All done"'
    98 	@echo 'All done"'
    96 
    99 
    97 today := $(shell date +%Y%m%d)
   100 today := $(shell date +%Y%m%d)
    98 
   101 
    99 define Mktar
   102 define Mktar
   100   $(1)_tar = $$(RESULT)/sdk-$(1)-$$(today).tar.gz
   103   $(1)-to-$(2)_tar = $$(RESULT)/sdk-$(1)-to-$(2)-$$(today).tar.gz
   101   $$($(1)_tar) : PLATFORM = $(1)
   104   $$($(1)-to-$(2)_tar) : PLATFORM = $(1)-to-$(2)
   102   TARFILES += $$($(1)_tar)
   105   TARFILES += $$($(1)-to-$(2)_tar)
   103   $$($(1)_tar) : $(1) $$(shell find $$(RESULT)/$(1))
   106   $$($(1)-to-$(2)_tar) : $$(shell find $$(RESULT)/$(1)-to-$(2) -type f)
   104 endef
   107 endef
   105 
   108 
   106 $(foreach p,$(host_platforms),$(eval $(call Mktar,$(p))))
   109 $(foreach p,$(host_platforms),$(foreach t,$(target_platforms),$(eval $(call Mktar,$(p),$(t)))))
   107 
   110 
   108 tars : all $(TARFILES)
   111 tars : all $(TARFILES)
   109 onlytars : $(TARFILES)
   112 onlytars : $(TARFILES)
   110 %.tar.gz :
   113 %.tar.gz :
   111 	@echo 'Creating compiler package $@'
   114 	@echo 'Creating compiler package $@'
   112 	cd $(RESULT)/$(PLATFORM) && tar -czf $@ *
   115 	cd $(RESULT) && tar -czf $@ $(PLATFORM)/*
   113 	touch $@
   116 	touch $@
   114 
   117 
   115 clean :
   118 clean :
   116 	rm -rf $(addprefix ../../build/devkit/, result $(host_platforms))
   119 	rm -rf $(addprefix ../../build/devkit/, result $(host_platforms))
   117 dist-clean: clean
   120 dist-clean: clean