116ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# Makefile to build the Windows SDK under linux.
216ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael#
316ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# This file is included by build/core/Makefile when a PRODUCT-sdk-win_sdk build
416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# is requested.
516ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael#
616ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# Summary of operations:
716ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# - create a regular Linux SDK
816ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# - build a few Windows tools
916ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# - mirror the linux SDK directory and patch it with the Windows tools
1016ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael#
1116ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# This way we avoid the headache of building a full SDK in MinGW mode, which is
1216ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# made complicated by the fact the build system does not support cross-compilation.
1316ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
1416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael# We can only use this under Linux with the mingw32 package installed.
1516ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelifneq ($(shell uname),Linux)
1616ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael$(error Linux is required to create a Windows SDK)
1716ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelendif
1816ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelifeq ($(strip $(shell which i586-mingw32msvc-gcc 2>/dev/null)),)
1916ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael$(error MinGW is required to build a Windows SDK. Please 'apt-get install mingw32')
2016ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelendif
211fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Mollifeq ($(strip $(shell which unix2dos todos 2>/dev/null)),)
2216ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael$(error Need a unix2dos command. Please 'apt-get install tofrodos')
2316ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelendif
2416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
253fb225fbfdfb045a1e117d02d110ffcd63c9252aRaphael Moll# Define WIN_SDK_TARGETS (the list of targets located in topdir/sdk)
263fb225fbfdfb045a1e117d02d110ffcd63c9252aRaphael Moll# and the WIN_SDK_BUILD_PREREQ (the list of build prerequisites)
273fb225fbfdfb045a1e117d02d110ffcd63c9252aRaphael Moll# that are tools-dependent and not platform-dependent.
281fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Mollinclude $(TOPDIR)sdk/build/windows_sdk_tools.mk
291fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Moll
30e07f59a612feef2243d934662aa0d6c54c520d8bRaphael# This is the list of targets that we want to generate as
31e07f59a612feef2243d934662aa0d6c54c520d8bRaphael# Windows executables. All the targets specified here are located in
32e07f59a612feef2243d934662aa0d6c54c520d8bRaphael# the topdir/development directory and are somehow platform-dependent.
3316ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelWIN_TARGETS := \
3416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	aapt adb aidl \
351fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Moll	etc1tool \
3616ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	dexdump dmtracedump \
3716ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	fastboot \
3816ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	hprof-conv \
3932d597b5b7e74b901c92a341409a57005b986efeRaphael	llvm-rs-cc \
4016ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	prebuilt \
411fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Moll	sqlite3 \
421fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Moll	zipalign \
431fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Moll	$(WIN_SDK_TARGETS)
4416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
4532d597b5b7e74b901c92a341409a57005b986efeRaphael# This is the list of *Linux* build tools that we need
4632d597b5b7e74b901c92a341409a57005b986efeRaphael# in order to be able to make the WIN_TARGETS. They are
4732d597b5b7e74b901c92a341409a57005b986efeRaphael# build prerequisites.
4832d597b5b7e74b901c92a341409a57005b986efeRaphaelWIN_BUILD_PREREQ := \
4932d597b5b7e74b901c92a341409a57005b986efeRaphael	acp \
503fb225fbfdfb045a1e117d02d110ffcd63c9252aRaphael Moll	llvm-rs-cc \
513fb225fbfdfb045a1e117d02d110ffcd63c9252aRaphael Moll	$(WIN_SDK_BUILD_PREREQ)
5232d597b5b7e74b901c92a341409a57005b986efeRaphael
5332d597b5b7e74b901c92a341409a57005b986efeRaphael
542ff496b8a14f3f2c68cd5a4d71d3f50a892b4811Raphael# MAIN_SDK_NAME/DIR is set in build/core/Makefile
552ff496b8a14f3f2c68cd5a4d71d3f50a892b4811RaphaelWIN_SDK_NAME := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(MAIN_SDK_NAME))
562ff496b8a14f3f2c68cd5a4d71d3f50a892b4811RaphaelWIN_SDK_DIR  := $(subst $(HOST_OS)-$(HOST_ARCH),windows,$(MAIN_SDK_DIR))
572ff496b8a14f3f2c68cd5a4d71d3f50a892b4811RaphaelWIN_SDK_ZIP  := $(WIN_SDK_DIR)/$(WIN_SDK_NAME).zip
5816ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
592ff496b8a14f3f2c68cd5a4d71d3f50a892b4811Raphael$(call dist-for-goals, win_sdk, $(WIN_SDK_ZIP))
6016ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
6116ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael.PHONY: win_sdk winsdk-tools
6216ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
6316ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaeldefine winsdk-banner
6416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael$(info )
6516ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael$(info ====== [Windows SDK] $1 ======)
6616ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael$(info )
6716ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelendef
6816ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
6916ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaeldefine winsdk-info
702ff496b8a14f3f2c68cd5a4d71d3f50a892b4811Raphael$(info MAIN_SDK_NAME: $(MAIN_SDK_NAME))
712ff496b8a14f3f2c68cd5a4d71d3f50a892b4811Raphael$(info WIN_SDK_NAME : $(WIN_SDK_NAME))
722ff496b8a14f3f2c68cd5a4d71d3f50a892b4811Raphael$(info WIN_SDK_DIR  : $(WIN_SDK_DIR))
732ff496b8a14f3f2c68cd5a4d71d3f50a892b4811Raphael$(info WIN_SDK_ZIP  : $(WIN_SDK_ZIP))
7416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelendef
7516ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
7616ede62379ba1a569e9a0164dd87ddce4e76c22bRaphaelwin_sdk: $(WIN_SDK_ZIP)
7716ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(call winsdk-banner,Done)
7816ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
7932d597b5b7e74b901c92a341409a57005b986efeRaphaelwinsdk-tools: $(WIN_BUILD_PREREQ)
8016ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(call winsdk-banner,Build Windows Tools)
81b058af052efa1dccf38eef8993008920088ff188Ying Wang	$(hide) USE_MINGW=1 USE_CCACHE="" $(MAKE) PRODUCT-$(TARGET_PRODUCT)-$(strip $(WIN_TARGETS)) $(if $(hide),,showcommands)
8216ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael
8316ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael$(WIN_SDK_ZIP): winsdk-tools sdk
8416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(call winsdk-banner,Build $(WIN_SDK_NAME))
8516ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(call winsdk-info)
8616ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(hide) rm -rf $(WIN_SDK_DIR)
8716ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(hide) mkdir -p $(WIN_SDK_DIR)
882ff496b8a14f3f2c68cd5a4d71d3f50a892b4811Raphael	$(hide) cp -rf $(MAIN_SDK_DIR)/$(MAIN_SDK_NAME) $(WIN_SDK_DIR)/$(WIN_SDK_NAME)
8916ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(hide) USB_DRIVER_HOOK=$(USB_DRIVER_HOOK) \
900e2de35b07d086bba435cda6c112481c75a47521Raphael		$(TOPDIR)development/build/tools/patch_windows_sdk.sh $(subst @,-q,$(hide)) \
9116ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael		$(WIN_SDK_DIR)/$(WIN_SDK_NAME) $(OUT_DIR) $(TOPDIR)
920e2de35b07d086bba435cda6c112481c75a47521Raphael	$(hide) $(TOPDIR)sdk/build/patch_windows_sdk.sh $(subst @,-q,$(hide)) \
931fe58f3892272469edf594a4a6ee1ab9a16d5813Raphael Moll		$(WIN_SDK_DIR)/$(WIN_SDK_NAME) $(OUT_DIR) $(TOPDIR)
9416ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	$(hide) ( \
9516ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael		cd $(WIN_SDK_DIR) && \
9616ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael		rm -f $(WIN_SDK_NAME).zip && \
9716ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael		zip -rq $(subst @,-q,$(hide)) $(WIN_SDK_NAME).zip $(WIN_SDK_NAME) \
9816ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael		)
9916ede62379ba1a569e9a0164dd87ddce4e76c22bRaphael	@echo "Windows SDK generated at $(WIN_SDK_ZIP)"
100