1 # Makefile to build the Windows SDK under linux. 2 # 3 # This file is included by build/core/Makefile when a PRODUCT-sdk-win_sdk build 4 # is requested. 5 # 6 # Summary of operations: 7 # - create a regular Linux SDK 8 # - build a few Windows tools 9 # - mirror the linux SDK directory and patch it with the Windows tools 10 # 11 # This way we avoid the headache of building a full SDK in MinGW mode, which is 12 # made complicated by the fact the build system does not support cross-compilation. 13 14 # We can only use this under Linux with the mingw32 package installed. 15 ifneq ($(shell uname),Linux) 16 $(error Linux is required to create a Windows SDK) 17 endif 18 ifeq ($(strip $(shell which i586-mingw32msvc-gcc 2>/dev/null)),) 19 $(error MinGW is required to build a Windows SDK. Please 'apt-get install mingw32') 20 endif 21 ifeq ($(strip $(shell which unix2dos todos 2>/dev/null)),) 22 $(error Need a unix2dos command. Please 'apt-get install tofrodos') 23 endif 24 25 # Define WIN_SDK_TARGETS (the list of targets located in topdir/sdk) 26 # and the WIN_SDK_BUILD_PREREQ (the list of build prerequisites) 27 # that are tools-dependent and not platform-dependent. 28 include $(TOPDIR)sdk/build/windows_sdk_tools.mk 29 30 # This is the list of targets that we want to generate as 31 # Windows executables. All the targets specified here are located in 32 # the topdir/development directory and are somehow platform-dependent. 33 WIN_TARGETS := \ 34 aapt adb aidl \ 35 bcc_compat \ 36 etc1tool \ 37 dexdump dmtracedump \ 38 fastboot \ 39 hprof-conv \ 40 llvm-rs-cc \ 41 prebuilt \ 42 sqlite3 \ 43 zipalign \ 44 split-select \ 45 $(WIN_SDK_TARGETS) 46 47 # This is the list of *Linux* build tools that we need 48 # in order to be able to make the WIN_TARGETS. They are 49 # build prerequisites. 50 WIN_BUILD_PREREQ := \ 51 acp \ 52 bcc_compat \ 53 llvm-rs-cc \ 54 $(WIN_SDK_BUILD_PREREQ) 55 56 57 # MAIN_SDK_NAME/DIR is set in build/core/Makefile 58 WIN_SDK_NAME := $(subst $(HOST_OS)-$(SDK_HOST_ARCH),windows,$(MAIN_SDK_NAME)) 59 WIN_SDK_DIR := $(subst $(HOST_OS)-$(SDK_HOST_ARCH),windows,$(MAIN_SDK_DIR)) 60 WIN_SDK_ZIP := $(WIN_SDK_DIR)/$(WIN_SDK_NAME).zip 61 62 $(call dist-for-goals, win_sdk, $(WIN_SDK_ZIP)) 63 64 .PHONY: win_sdk winsdk-tools 65 66 define winsdk-banner 67 $(info ) 68 $(info ====== [Windows SDK] $1 ======) 69 $(info ) 70 endef 71 72 define winsdk-info 73 $(info MAIN_SDK_NAME: $(MAIN_SDK_NAME)) 74 $(info WIN_SDK_NAME : $(WIN_SDK_NAME)) 75 $(info WIN_SDK_DIR : $(WIN_SDK_DIR)) 76 $(info WIN_SDK_ZIP : $(WIN_SDK_ZIP)) 77 endef 78 79 win_sdk: $(WIN_SDK_ZIP) 80 $(call winsdk-banner,Done) 81 82 winsdk-tools: $(WIN_BUILD_PREREQ) 83 $(call winsdk-banner,Build Windows Tools) 84 $(hide) USE_MINGW=1 USE_CCACHE="" $(MAKE) PRODUCT-$(TARGET_PRODUCT)-$(strip $(WIN_TARGETS)) $(if $(hide),,showcommands) 85 86 $(WIN_SDK_ZIP): winsdk-tools sdk 87 $(call winsdk-banner,Build $(WIN_SDK_NAME)) 88 $(call winsdk-info) 89 $(hide) rm -rf $(WIN_SDK_DIR) 90 $(hide) mkdir -p $(WIN_SDK_DIR) 91 $(hide) cp -rf $(MAIN_SDK_DIR)/$(MAIN_SDK_NAME) $(WIN_SDK_DIR)/$(WIN_SDK_NAME) 92 $(hide) USB_DRIVER_HOOK=$(USB_DRIVER_HOOK) \ 93 PLATFORM_VERSION=$(PLATFORM_VERSION) \ 94 $(TOPDIR)development/build/tools/patch_windows_sdk.sh $(subst @,-q,$(hide)) \ 95 $(WIN_SDK_DIR)/$(WIN_SDK_NAME) $(OUT_DIR) $(TOPDIR) 96 $(hide) PLATFORM_VERSION=$(PLATFORM_VERSION) \ 97 $(TOPDIR)sdk/build/patch_windows_sdk.sh $(subst @,-q,$(hide)) \ 98 $(WIN_SDK_DIR)/$(WIN_SDK_NAME) $(OUT_DIR) $(TOPDIR) 99 $(hide) ( \ 100 cd $(WIN_SDK_DIR) && \ 101 rm -f $(WIN_SDK_NAME).zip && \ 102 zip -rq $(subst @,-q,$(hide)) $(WIN_SDK_NAME).zip $(WIN_SDK_NAME) \ 103 ) 104 @echo "Windows SDK generated at $(WIN_SDK_ZIP)" 105