# PROJECT_NAME # VERSION_MAJOR, VERSION_MINOR, VERSION_TWEAK (optional) # PROJECT_VERSION # LIBRARY_TARGETS # EXECUTABLE_TARGETS # APPLICATION_TARGETS # JAR_TARGETS # THIRDPARTY_LIBRARY_TARGETS # HEADER_ONLY_TARGETS # TARGET_NAME_${target} for all targets # HUMAN_READABLE_TARGET_NAME_${target} for all application targets # PLATFORMS (optionally PLATFORMS_${target}) # CCFLAGS (optionally CCFLAGS_${target}_${configuration}_${platform}_${arch} and all permutations) # LINKFLAGS (optionally LINKFLAGS_${target}_${configuration}_${platform}_${arch} and all permutations) # CPPFLAGS (same templates as CCFLAGS; used for CPP_SOURCES) # PROJECT_LIBRARY_DEPENDENCIES_${target} # STEM_LIBRARY_DEPENDENCIES (optionally STEM_LIBRARY_DEPENDENCIES_${target}, STEM_LIBRARY_DEPENDENCIES_${platform}, STEM_LIBRARY_DEPENDENCIES_${target}_${platform}) # THIRDPARTY_LIBRARY_DEPENDENCIES (optionally THIRDPARTY_LIBRARY_DEPENDENCIES_${target}, THIRDPARTY_LIBRARY_DEPENDENCIES_${platform}, THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform}) # SOURCES_${target} (optional for unittest target) # CPP_SOURCES_${target}, CPP_SOURCES_${target}_${platform} # SOURCES_unittest_suites # INCLUDES (will be copied inside containing directory at the destination) # INCLUDES_NO_SUBDIR (will be copied bare into the destination) # RESOURCES (optionally RESOURCES_${target}_${platform}_${arch} and all permutations) # GENERATED_TEXTURE_ATLASES # GENERATED_BITMAP_FONTS # GENERATED_ICON_linux # LINKFILES (optionally LINKFILES_${target}_${platform}_${arch} and all permutations) # DYNAMICLIBS_${target}, DYNAMICLIBS_${target}_${platform}, DYNAMICLIBS_${target}_${platform}_${arch} # EMBEDFILES (optionally EMBEDFILES_${target}_${configuration}_${platform}_${arch} and all permutations) # PREREQS (optionally PREREQS_${target}_${configuration}_${platform}_${arch} and all permutations) # DEPENDENCY_SED_COMMANDS # PLIST_FILE_${target}_${platform} for macosx, iphonesimulator, and iphoneos platforms # MANIFEST_FILE_${target}_${platform} for android and androidemulator platforms # INSTALLED_TARGETS # HEADER_ONLY_TARGETS # For Android only: # GENERATE_ANDROID_PACKAGE_NAME_${target} # GENERATE_ANDROID_CLASS_NAME_${target} # JAVA_SOURCES_${target} # JAVA_PACKAGE_SUBDIR_${target} # PROJECT_JAR_DEPENDENCIES_${target} # STEM_JAR_DEPENDENCIES_${target} # ANDROID_LAUNCH_ACTIVITY_NAME_${target} # SYSTEM_RESOURCES, SYSTEM_RESOURCES_${target}, SYSTEM_RESOURCES_${platform}, SYSTEM_RESOURCES_${target}_${platform} # USE_DEFAULT_ICONS_${target} #TODO: Each project gets its own manifest, icon, and string files; Java code lives only in eglshell. Need to substitute string for library load. UNAME = ${shell uname} ifeq (${UNAME},Linux) -include ~/.stem.defines STEM_SHARED_DIR ?= /usr/local/stem HOST_PLATFORM = linux else ifeq (${UNAME},Darwin) -include ~/.stem.defines STEM_SHARED_DIR ?= /usr/local/stem HOST_PLATFORM = macosx else STEM_SHARED_DIR ?= C:/stem -include ${STEM_SHARED_DIR}/stem.defines HOST_PLATFORM = windows endif define newline_and_tab endef PROJECT_VERSION ?= ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_TWEAK} TARGET_PLATFORMS_macosx ?= macosx iphonesimulator iphoneos android TARGET_PLATFORMS_linux ?= linux TARGET_PLATFORMS_windows ?= windows ALL_PLATFORMS = macosx iphonesimulator iphoneos linux windows android CODESIGN_IDENTITY ?= "iPhone Developer" STEM_TARGETS = ${LIBRARY_TARGETS} ${EXECUTABLE_TARGETS} ${APPLICATION_TARGETS} ${HEADER_ONLY_TARGETS} ALL_TARGETS = ${STEM_TARGETS} ${JAR_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS} PLATFORMS ?= ${ALL_PLATFORMS} PLATFORMS_unittest ?= ${filter ${PLATFORMS},macosx iphonesimulator linux windows} TARGET_PLATFORMS = ${filter ${TARGET_PLATFORMS_${HOST_PLATFORM}},${PLATFORMS}} TARGET_NAME_mainapp ?= ${PROJECT_NAME} TARGET_NAME_library ?= libstem_${PROJECT_NAME} TARGET_NAME_unittest ?= ${PROJECT_NAME}_unittest TARGET_NAME_testharness ?= ${PROJECT_NAME}_testharness TARGET_NAME_mainapp ?= ${PROJECT_NAME} CONFIGURATIONS ?= debug profile release CONFIGURATIONS_unittest ?= debug ${foreach target,${ALL_TARGETS}, \ ${eval PLATFORMS_${target} ?= ${filter ${PLATFORMS},${ALL_PLATFORMS}}} \ ${eval TARGET_PLATFORMS_${target} ?= ${filter ${TARGET_PLATFORMS},${PLATFORMS_${target}}}} \ ${eval TARGET_NAME_${target} ?= ${target}} \ } ${foreach target,${STEM_TARGETS}, \ ${eval CONFIGURATIONS_${target} ?= ${filter ${CONFIGURATIONS},debug profile release}} \ } ${foreach target,${THIRDPARTY_LIBRARY_TARGETS}, \ ${eval THIRDPARTY_LIBRARY_WORKING_SUBDIR_${target} = build/intermediate/${THIRDPARTY_LIBRARY_PRISTINE_SUBDIR_${target}}} \ ${eval CONFIGURATIONS_${target} ?= debug} \ ${eval BUILT_THIRDPARTY_LIBRARY_FILES_${target} = \ ${foreach library,${BUILT_LIBRARY_LOCATION_${target}},${notdir ${library}}} \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach library,${BUILT_LIBRARY_LOCATION_${target}_${platform}},${notdir ${library}}} \ } \ } \ } UTILITY_BUILD_DIR_macosx = profile-macosx UTILITY_BUILD_DIR_windows = profile-windows-${firstword ${BUILT_THIN_ARCHS_windows}} UTILITY_BUILD_DIR_linux = profile-linux-${firstword ${BUILT_THIN_ARCHS_linux}} TEXTUREPACKER_DIR ?= ${STEM_SHARED_DIR}/${shell ${STEM_SHARED_DIR}/stemconfig --resolve-version texturepacker/latest} FILEBUNDLER_DIR ?= ${STEM_SHARED_DIR}/${shell ${STEM_SHARED_DIR}/stemconfig --resolve-version utilities/latest} AUDIOLAB_DIR ?= ${STEM_SHARED_DIR}/${shell ${STEM_SHARED_DIR}/stemconfig --resolve-version audiolab/latest} TILESET_DIR ?= ${STEM_SHARED_DIR}/${shell ${STEM_SHARED_DIR}/stemconfig --resolve-version tileset/latest} MAKEFONT = ${TEXTUREPACKER_DIR}/makefont/${UTILITY_BUILD_DIR_${HOST_PLATFORM}}/makefont TEXTUREPACKER = ${TEXTUREPACKER_DIR}/texturepacker/${UTILITY_BUILD_DIR_${HOST_PLATFORM}}/texturepacker ICONHELPER = ${TEXTUREPACKER_DIR}/iconhelper/${UTILITY_BUILD_DIR_${HOST_PLATFORM}}/iconhelper FILEBUNDLER = ${FILEBUNDLER_DIR}/filebundler/${UTILITY_BUILD_DIR_${HOST_PLATFORM}}/filebundler STRIPEDITDATA = ${TILESET_DIR}/stripEditData/${UTILITY_BUILD_DIR_${HOST_PLATFORM}}/stripEditData TILEMAPBUNDLER = ${TILESET_DIR}/tileMapBundler/${UTILITY_BUILD_DIR_${HOST_PLATFORM}}/tileMapBundler #Per-configuration compile/link settings CCFLAGS_debug ?= -g -DDEBUG CCFLAGS_profile ?= -g -O3 CCFLAGS_release ?= -O3 CPPFLAGS_debug ?= ${CCFLAGS_debug} CPPFLAGS_profile ?= ${CCFLAGS_profile} CPPFLAGS_release ?= ${CCFLAGS_release} #Per-platform compile/link settings ifneq ($(filter macosx,${TARGET_PLATFORMS}),) SDKROOT_macosx ?= ${shell xcrun --show-sdk-path} MACOSX_VERSION_MIN ?= 10.6 CC_macosx_i386 ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find cc} -arch i386 CC_macosx_x86_64 ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find cc} -arch x86_64 AR_macosx ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find ar} RANLIB_macosx ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find ranlib} STRIP_macosx ?= ${shell xcrun --sdk ${SDKROOT_macosx} --find strip} ARCHS_macosx ?= i386 x86_64 BUILT_FAT_ARCHS_macosx ?= i386 x86_64 BUILT_THIN_ARCHS_macosx ?= BUILT_ARCHS_macosx = ${sort ${BUILT_FAT_ARCHS_macosx} ${BUILT_THIN_ARCHS_macosx}} ifeq ($(filter echo_info,${MAKECMDGOALS}),) CCFLAGS_macosx += -isysroot ${SDKROOT_macosx} -mmacosx-version-min=${MACOSX_VERSION_MIN} CPPFLAGS_macosx += -isysroot ${SDKROOT_macosx} -mmacosx-version-min=${MACOSX_VERSION_MIN} LINKFLAGS_macosx += -isysroot ${SDKROOT_macosx} -mmacosx-version-min=${MACOSX_VERSION_MIN} EMBEDFLAGS_macosx += -isysroot ${SDKROOT_macosx} -mmacosx-version-min=${MACOSX_VERSION_MIN} endif EMBED_S_SUFFIX_i386 = _mingw EMBED_S_SUFFIX_x86_64 = _mingw endif ifneq ($(filter iphonesimulator,${TARGET_PLATFORMS}),) SDKROOT_iphonesimulator ?= ${shell xcrun --show-sdk-path --sdk iphonesimulator} SDKROOT_iphonesimulator_unittest ?= ${SDKROOT_iphonesimulator} IPHONEOS_TARGET_MIN ?= 7.1 CC_iphonesimulator_i386 ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find cc} -arch i386 AR_iphonesimulator ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find ar} RANLIB_iphonesimulator ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find ranlib} STRIP_iphonesimulator ?= ${shell xcrun --sdk ${SDKROOT_iphonesimulator} --find strip} ARCHS_iphonesimulator ?= i386 BUILT_FAT_ARCHS_iphonesimulator ?= i386 BUILT_THIN_ARCHS_iphonesimulator ?= BUILT_ARCHS_iphonesimulator = ${sort ${BUILT_FAT_ARCHS_iphonesimulator} ${BUILT_THIN_ARCHS_iphonesimulator}} ifeq ($(filter echo_info,${MAKECMDGOALS}),) CCFLAGS_iphonesimulator += -isysroot ${SDKROOT_iphonesimulator} -mios-simulator-version-min=${IPHONEOS_TARGET_MIN} -fobjc-abi-version=2 -fobjc-legacy-dispatch CPPFLAGS_iphonesimulator += -isysroot ${SDKROOT_iphonesimulator} -mios-simulator-version-min=${IPHONEOS_TARGET_MIN} -fobjc-abi-version=2 -fobjc-legacy-dispatch LINKFLAGS_iphonesimulator += -isysroot ${SDKROOT_iphonesimulator} -mios-simulator-version-min=${IPHONEOS_TARGET_MIN} -Xlinker -objc_abi_version -Xlinker 2 endif endif ifneq ($(filter iphoneos,${TARGET_PLATFORMS}),) SDKROOT_iphoneos ?= ${shell xcrun --show-sdk-path --sdk iphoneos} CC_iphoneos_armv7 ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find cc} -arch armv7 CC_iphoneos_arm64 ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find cc} -arch arm64 AR_iphoneos ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find ar} RANLIB_iphoneos ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find ranlib} STRIP_iphoneos ?= ${shell xcrun --sdk ${SDKROOT_iphoneos} --find strip} ARCHS_iphoneos ?= armv7 arm64 BUILT_FAT_ARCHS_iphoneos ?= armv7 arm64 BUILT_THIN_ARCHS_iphoneos ?= BUILT_ARCHS_iphoneos = ${sort ${BUILT_FAT_ARCHS_iphoneos} ${BUILT_THIN_ARCHS_iphoneos}} ifeq ($(filter echo_info,${MAKECMDGOALS}),) CCFLAGS_iphoneos += -isysroot ${SDKROOT_iphoneos} -miphoneos-version-min=${IPHONEOS_TARGET_MIN} -fobjc-abi-version=2 -fobjc-legacy-dispatch CPPFLAGS_iphoneos += -isysroot ${SDKROOT_iphoneos} -miphoneos-version-min=${IPHONEOS_TARGET_MIN} -fobjc-abi-version=2 -fobjc-legacy-dispatch LINKFLAGS_iphoneos += -isysroot ${SDKROOT_iphoneos} -miphoneos-version-min=${IPHONEOS_TARGET_MIN} -Xlinker -objc_abi_version -Xlinker 2 endif endif ifneq ($(filter linux,${TARGET_PLATFORMS}),) CC_linux_i386 ?= /usr/bin/gcc CC_linux_x86_64 ?= /usr/bin/gcc CC_linux_armv7l ?= /usr/bin/gcc AR_linux_i386 ?= /usr/bin/ar AR_linux_x86_64 ?= /usr/bin/ar AR_linux_armv7l ?= /usr/bin/ar RANLIB_linux_i386 ?= /usr/bin/ranlib RANLIB_linux_x86_64 ?= /usr/bin/ranlib RANLIB_linux_armv7l ?= /usr/bin/ranlib STRIP_linux_i386 ?= /usr/bin/strip STRIP_linux_x86_64 ?= /usr/bin/strip STRIP_linux_armv7l ?= /usr/bin/strip ARCHS_linux ?= i386 x86_64 armv7l BUILT_FAT_ARCHS_linux ?= BUILT_THIN_ARCHS_linux ?= x86_64 BUILT_ARCHS_linux = ${sort ${BUILT_FAT_ARCHS_linux} ${BUILT_THIN_ARCHS_linux}} ifeq ($(filter echo_info,${MAKECMDGOALS}),) CCFLAGS_linux_i386 += -m32 CCFLAGS_linux_x86_64 += -m64 CCFLAGS_linux_armv7l += CPPFLAGS_linux_i386 += -m32 CPPFLAGS_linux_x86_64 += -m64 CPPFLAGS_linux_armv7l += LINKFLAGS_linux_i386 += -m32 -Wl,-E LINKFLAGS_linux_x86_64 += -m64 -Wl,-E LINKFLAGS_linux_armv7l += -Wl,-E endif endif ifneq ($(filter windows,${TARGET_PLATFORMS}),) MINGW_W32_PATH ?= C:/MinGW MINGW_W32_VERSION ?= 4.6.2 MINGW_W64_PATH ?= C:/MinGW-w64 MINGW_W64_VERSION ?= 4.7.0 CC_windows_i386 ?= ${MINGW_W32_PATH}/bin/gcc.exe CC_windows_x86_64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-gcc.exe AR_windows_i386 ?= ${MINGW_W32_PATH}/bin/ar.exe AR_windows_x86_64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-ar.exe RANLIB_windows_i386 ?= ${MINGW_W32_PATH}/bin/ranlib.exe RANLIB_windows_x86_64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-ranlib.exe STRIP_windows_i386 ?= ${MINGW_W32_PATH}/bin/strip.exe STRIP_windows_x86_64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-strip.exe WINDRES_windows_i386 ?= ${MINGW_W32_PATH}/bin/windres.exe WINDRES_windows_x86_64 ?= ${MINGW_W64_PATH}/bin/x86_64-w64-mingw32-windres.exe ARCHS_windows ?= i386 x86_64 BUILT_FAT_ARCHS_windows ?= BUILT_THIN_ARCHS_windows ?= i386 x86_64 BUILT_ARCHS_windows = ${sort ${BUILT_FAT_ARCHS_windows} ${BUILT_THIN_ARCHS_windows}} ifeq ($(filter echo_info,${MAKECMDGOALS}),) CCFLAGS_windows += CPPFLAGS_windows += LINKFLAGS_windows += LINKFLAGS_unittest_windows += -mconsole endif EXECUTABLE_SUFFIX_windows = .exe EMBED_S_SUFFIX_i386 = _mingw EMBED_S_SUFFIX_x86_64 = _mingw_w64 endif ifneq ($(filter android,${TARGET_PLATFORMS}),) SDKROOT_android ?= /Users/adiener/Library/Android/sdk NDKROOT ?= ${SDKROOT_android}/ndk-bundle ANDROID_BUILD_SDK_DIR ?= ${SDKROOT_android}/build-tools/28.0.3 ANDROID_PLATFORM_SDK_DIR ?= ${SDKROOT_android}/platform-tools AAPT ?= ${ANDROID_BUILD_SDK_DIR}/aapt ADB ?= ${ANDROID_PLATFORM_SDK_DIR}/adb DX ?= ${ANDROID_BUILD_SDK_DIR}/dx ZIPALIGN ?= ${ANDROID_BUILD_SDK_DIR}/zipalign JAVA_HOME ?= /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home JAVAC ?= ${JAVA_HOME}/bin/javac JAR ?= ${JAVA_HOME}/bin/jar APKSIGNER ?= ${ANDROID_BUILD_SDK_DIR}/apksigner ANDROID_JAR ?= ${SDKROOT_android}/platforms/android-28/android.jar CC_android_armv7a ?= ${NDKROOT}/toolchains/llvm/prebuilt/darwin-x86_64/bin/armv7a-linux-androideabi28-clang AR_android_armv7a ?= ${NDKROOT}/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ar RANLIB_android_armv7a ?= ${NDKROOT}/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-ranlib STRIP_android ?= ${NDKROOT}/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/bin/aarch64-linux-android-strip ARCHS_android ?= armv7a BUILT_FAT_ARCHS_android ?= BUILT_THIN_ARCHS_android ?= armv7a BUILT_ARCHS_android = ${sort ${BUILT_FAT_ARCHS_android} ${BUILT_THIN_ARCHS_android}} ifeq ($(filter echo_info,${MAKECMDGOALS}),) CCFLAGS_android_armv7a += -isysroot "${NDKROOT}/platforms/android-28/arch-arm" -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fPIC CPPFLAGS_android_armv7a += -isysroot "${NDKROOT}/platforms/android-28/arch-arm" -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fPIC LINKFLAGS_android_armv7a += -shared -Wl,--fix-cortex-a8 endif endif #General compile/link settings DEFINE_CCFLAGS += -DVERSION_MAJOR=${VERSION_MAJOR}u -DVERSION_MINOR=${VERSION_MINOR}u -DVERSION_TWEAK=${VERSION_TWEAK}u WARNING_CCFLAGS += -Wall -Wextra -Wno-unused-parameter -Werror OTHER_CCFLAGS += -std=gnu99 ifeq ($(filter echo_info,${MAKECMDGOALS}),) CCFLAGS += ${DEFINE_CCFLAGS} ${WARNING_CCFLAGS} ${OTHER_CCFLAGS} CPPFLAGS += ${DEFINE_CCFLAGS} ${WARNING_CCFLAGS} endif define permutations_3 #(variable, target, configuration, platform) ${strip \ ${$1} \ ${$1_$2} ${$1_$2_$3} ${$1_$2_$4} ${$1_$2_$3_$4} \ ${$1_$3} ${$1_$3_$4} \ ${$1_$4} \ } endef define permutations_4 #(variable, target, configuration, platform, arch) ${strip \ ${$1} \ ${$1_$2} ${$1_$2_$3} ${$1_$2_$4} ${$1_$2_$5} ${$1_$2_$3_$4} ${$1_$2_$3_$5} ${$1_$2_$4_$5} ${$1_$2_$3_$4_$5} \ ${$1_$3} ${$1_$3_$4} ${$1_$3_$5} ${$1_$3_$4_$5} \ ${$1_$4} ${$1_$4_$5} \ ${$1_$5} \ } endef SOURCES_unittest += \ build/intermediate/TestList.c \ ${SOURCES_unittest_suites} .PHONY: all all: ${ALL_TARGETS} ${if ${filter unittest,${EXECUTABLE_TARGETS}},test} ${if ${strip ${INCLUDES} ${INCLUDES_NO_SUBDIR}},include} #TestList.c is automatically generated from ${SOURCES_unittest_suites}. It is used by the unit test framework to determine which tests to run. build/intermediate/TestList.c: build/intermediate/TestSuites.txt | build/intermediate echo 'const char * UnitTest_suiteNameList[] = {${foreach file,${SOURCES_unittest_suites},"${basename ${notdir ${file}}}",} (void *) 0};' > $@ #TestSuites.txt tracks the state of ${SOURCES_unittest_suites} so that TestList.c can be updated if and only if ${SOURCES_unittest_suites} has changed. .PHONY is abused slightly to cause the target to be conditionally remade. ifneq (${shell echo "${SOURCES_unittest_suites}" | cmp - build/intermediate/TestSuites.txt 2>&1},) .PHONY: build/intermediate/TestSuites.txt endif build/intermediate/TestSuites.txt: | build/intermediate echo "${SOURCES_unittest_suites}" > $@ build/intermediate/icon_win32.coff: resources/icon.ico resources/icon.rc ${WINDRES_windows_i386} resources/icon.rc -o $@ -O coff build/intermediate/icon_win64.coff: resources/icon.ico resources/icon.rc ${WINDRES_windows_x86_64} resources/icon.rc -o $@ -O coff define configuration_object_list_template #(target, configuration) ${foreach platform,${TARGET_PLATFORMS_$1}, \ ${call platform_object_list_template,$1,$2,${platform}} \ } endef define platform_object_list_template #(target, configuration, platform) ${foreach arch,${BUILT_ARCHS_$3}, \ ${call arch_object_list_template,$1,$2,$3,${arch}} \ } endef define arch_object_list_template #(target, configuration, platform, arch) ${foreach source,${SOURCES_$1} ${SOURCES_$1_$3} ${CPP_SOURCES_$1} ${CPP_SOURCES_$1_$3}, \ build/intermediate/$1-$2-$3-$4/${notdir ${basename ${source}}}.o \ } endef define embedfile_list_template #(target, configuration, platform, arch) ${foreach file,${call permutations_4,EMBEDFILES,$1,$2,$3,$4}, \ build/intermediate/$1-$2-$3-$4/${subst .,_,${notdir ${file}}}.o \ } endef define create_directory_target_template #(dir) ifneq (${UNAME},Linux) .LOW_RESOLUTION_TIME: $1 endif $1: mkdir -p $1 endef ${foreach target,${STEM_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${if ${strip ${BUILT_FAT_ARCHS_${platform}}}, \ ${eval ${call create_directory_target_template,build/${target}/${configuration}-${platform}}} \ } \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${eval ${call create_directory_target_template,build/intermediate/${target}-${configuration}-${platform}-${arch}}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval ${call create_directory_target_template,build/${target}/${configuration}-${platform}-${arch}}} \ } \ } \ } \ } ${eval ${call create_directory_target_template,build/intermediate}} ${eval ${call create_directory_target_template,build/generated}} ifeq ($(filter clean clean_d echo_info,${MAKECMDGOALS}),) ${foreach target,${STEM_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${eval COMPUTED_STEM_LIBRARY_DEPENDENCIES_${target}_${platform} = ${shell ${STEM_SHARED_DIR}/stemconfig --add-dependencies --platform ${platform} --stem-only ${STEM_LIBRARY_DEPENDENCIES} ${STEM_LIBRARY_DEPENDENCIES_${target}} ${STEM_LIBRARY_DEPENDENCIES_${platform}} ${STEM_LIBRARY_DEPENDENCIES_${target}_${platform}}}} \ ${eval COMPUTED_THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform} = ${shell ${STEM_SHARED_DIR}/stemconfig --add-dependencies --platform ${platform} --thirdparty-only ${STEM_LIBRARY_DEPENDENCIES} ${STEM_LIBRARY_DEPENDENCIES_${target}} ${STEM_LIBRARY_DEPENDENCIES_${platform}} ${STEM_LIBRARY_DEPENDENCIES_${target}_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform}}}} \ ${if ${strip ${BUILT_FAT_ARCHS_${platform}}}, \ ${eval COMPUTED_LINKFLAGS_${target}_${platform} = ${shell ${STEM_SHARED_DIR}/stemconfig --link-flags ${platform} ${STEM_LIBRARY_DEPENDENCIES} ${STEM_LIBRARY_DEPENDENCIES_${target}} ${STEM_LIBRARY_DEPENDENCIES_${platform}} ${STEM_LIBRARY_DEPENDENCIES_${target}_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform}}}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval COMPUTED_LINKFLAGS_${target}_${platform}_${arch} = ${shell ${STEM_SHARED_DIR}/stemconfig --link-flags ${platform}-${arch} ${STEM_LIBRARY_DEPENDENCIES} ${STEM_LIBRARY_DEPENDENCIES_${target}} ${STEM_LIBRARY_DEPENDENCIES_${platform}} ${STEM_LIBRARY_DEPENDENCIES_${target}_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${platform}} ${THIRDPARTY_LIBRARY_DEPENDENCIES_${target}_${platform}}}} \ } \ } \ ${if ${filter android,${TARGET_PLATFORMS_${target}}}, \ ${if ${strip ${STEM_JAR_DEPENDENCIES_${target}}}, \ ${eval COMPUTED_STEM_JAR_DEPENDENCIES_${target} = ${shell ${STEM_SHARED_DIR}/stemconfig --resolve-version ${STEM_JAR_DEPENDENCIES_${target}}}} \ ,} \ ,} \ ${if ${strip ${USE_DEFAULT_ICONS_${target}}}, \ ${eval CCFLAGS_linux += -I ${STEM_SHARED_DIR}/icons/linux} \ } \ } endif define linux_icon_template #(image_file) PREREQS_linux += build/generated/IconData_${PROJECT_NAME}.h CCFLAGS_linux += -I build/generated build/generated/IconData_${PROJECT_NAME}.h: $1 ${ICONHELPER} | build/generated ${ICONHELPER} $$< $$@ ${PROJECT_NAME} endef ${if ${strip ${GENERATED_ICON_linux}}, \ ${eval ${call linux_icon_template,${GENERATED_ICON_linux}}} \ } define embed_template #(target, configuration, platform, arch, embed_file) build/intermediate/$1-$2-$3-$4/${subst .,_,${notdir $5}}.o: $5 | build/intermediate/$1-$2-$3-$4 build/generated sed -e "s,\$$$${SYMBOL_NAME},${subst .,_,${notdir $5}},g" \ -e "s,\$$$${FILE_PATH},$5,g" \ ${STEM_SHARED_DIR}/embed${EMBED_S_SUFFIX_$4}.s > build/generated/${subst .,_,${notdir $5}}_$4.s ${CC_$3_$4} ${EMBEDFLAGS_$3} -c -o $$@ build/generated/${subst .,_,${notdir $5}}_$4.s endef define include_ccflags_template #(target, platform) -I source \ -I ${STEM_SHARED_DIR}/include \ ${foreach stem_dependency,${COMPUTED_STEM_LIBRARY_DEPENDENCIES_$1_$2},-I ${STEM_SHARED_DIR}/${stem_dependency}/include} \ ${foreach thirdparty_dependency,${COMPUTED_THIRDPARTY_LIBRARY_DEPENDENCIES_$1_$2},-I ${STEM_SHARED_DIR}/${dir ${thirdparty_dependency}}include} endef define define_ccflags_template #(target, configuration, platform, arch) -DSTEM_TARGET_$1 -DSTEM_CONFIGURATION_$2 -DSTEM_PLATFORM_$3 -DSTEM_ARCH_$4 -DSTEM_HUMAN_READABLE_TARGET_NAME='"${subst \,,${HUMAN_READABLE_TARGET_NAME_$1}}"' endef define dependency_template #(target, configuration, platform, arch, source_file) ifneq (${PRINT_D_COMMANDS},1) .SILENT: build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.d endif build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.d: $5 | ${call permutations_4,PREREQS,$1,$2,$3,$4} build/intermediate/$1-$2-$3-$4 ${CC_$3_$4} ${call permutations_4,CCFLAGS,$1,$2,$3,$4} ${call include_ccflags_template,$1,$3} ${call define_ccflags_template,$1,$2,$3,$4} -MM -o $$@.temp $5 sed 's,\(${notdir ${basename $5}}\)\.o[ :]*,$${basename $$@}.o $${basename $$@}.d: ,g;${DEPENDENCY_SED_COMMANDS}' < $$@.temp > $$@ rm $$@.temp endef define dependency_template_cpp #(target, configuration, platform, arch, source_file) ifneq (${PRINT_D_COMMANDS},1) .SILENT: build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.d endif build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.d: $5 | ${call permutations_4,PREREQS,$1,$2,$3,$4} build/intermediate/$1-$2-$3-$4 ${CC_$3_$4} ${call permutations_4,CPPFLAGS,$1,$2,$3,$4} ${call include_ccflags_template,$1,$3} ${call define_ccflags_template,$1,$2,$3,$4} -MM -o $$@.temp $5 sed 's,\(${notdir ${basename $5}}\)\.o[ :]*,$${basename $$@}.o $${basename $$@}.d: ,g;${DEPENDENCY_SED_COMMANDS}' < $$@.temp > $$@ rm $$@.temp endef #Produces dependency build targets for all source files in each configuration/platform/arch ifeq ($(filter clean clean_d echo_info,${MAKECMDGOALS}),) ${foreach target,${STEM_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${foreach source,${SOURCES_${target}} ${SOURCES_${target}_${platform}}, \ ${eval ${call dependency_template,${target},${configuration},${platform},${arch},${source}}} \ ${eval -include build/intermediate/${target}-${configuration}-${platform}-${arch}/${notdir ${basename ${source}}}.d} \ } \ ${foreach source,${CPP_SOURCES_${target}} ${CPP_SOURCES_${target}_${platform}}, \ ${eval ${call dependency_template_cpp,${target},${configuration},${platform},${arch},${source}}} \ ${eval -include build/intermediate/${target}-${configuration}-${platform}-${arch}/${notdir ${basename ${source}}}.d} \ } \ } \ } \ } \ } endif define compile_template #(target, configuration, platform, arch, source_file) build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.o: $5 | ${call permutations_4,PREREQS,$1,$2,$3,$4} build/intermediate/$1-$2-$3-$4 ${CC_$3_$4} ${call permutations_4,CCFLAGS,$1,$2,$3,$4} ${call include_ccflags_template,$1,$3} ${call define_ccflags_template,$1,$2,$3,$4} -c -o $$@ $5 endef define compile_template_cpp #(target, configuration, platform, arch, source_file) build/intermediate/$1-$2-$3-$4/${notdir ${basename $5}}.o: $5 | ${call permutations_4,PREREQS,$1,$2,$3,$4} build/intermediate/$1-$2-$3-$4 ${CC_$3_$4} ${call permutations_4,CPPFLAGS,$1,$2,$3,$4} ${call include_ccflags_template,$1,$3} ${call define_ccflags_template,$1,$2,$3,$4} -c -o $$@ $5 endef #Produces object build targets for all source and embed files in each configuration/platform/arch ${foreach target,${STEM_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${foreach source,${SOURCES_${target}} ${SOURCES_${target}_${platform}}, \ ${eval ${call compile_template,${target},${configuration},${platform},${arch},${source}}} \ } \ ${foreach source,${CPP_SOURCES_${target}} ${CPP_SOURCES_${target}_${platform}}, \ ${eval ${call compile_template_cpp,${target},${configuration},${platform},${arch},${source}}} \ } \ ${foreach embed_file,${call permutations_4,EMBEDFILES,${target},${configuration},${platform},${arch}}, \ ${eval ${call embed_template,${target},${configuration},${platform},${arch},${embed_file}}} \ } \ } \ } \ } \ } define fat_library_template #(target, configuration, platform, arch, output_file) build/intermediate/$1-$2-$3-$4/$5: ${call arch_object_list_template,$1,$2,$3,$4} ${call embedfile_list_template,$1,$2,$3,$4} ${AR_$3} rc $$@ $$^ ${RANLIB_$3} $$@ endef define thin_library_template #(target, configuration, platform, arch, output_file) build/intermediate/$1-$2-$3-$4/$5: ${call arch_object_list_template,$1,$2,$3,$4} ${call embedfile_list_template,$1,$2,$3,$4} ${AR_$3_$4} rc $$@ $$^ ${RANLIB_$3_$4} $$@ endef #Produces static library build targets for each arch/platform/target for library targets ${foreach target,${LIBRARY_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_FAT_ARCHS_${platform}}, \ ${eval ${call fat_library_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}.a}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval ${call thin_library_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}.a}} \ } \ } \ } \ } define executable_template #(target, configuration, platform, arch, output_file, dependent_libraries) build/intermediate/$1-$2-$3-$4/$5: ${call arch_object_list_template,$1,$2,$3,$4} $6 ${call permutations_3,LINKFILES,$1,$3,$4} ${call embedfile_list_template,$1,$2,$3,$4} ${CC_$3_$4} -o $$@ $$^ \ ${call permutations_4,LINKFLAGS,$1,$2,$3,$4} \ ${foreach project_library,${PROJECT_LIBRARY_DEPENDENCIES_$1} ${PROJECT_LIBRARY_DEPENDENCIES_$1_$3}, \ ${call permutations_4,LINKFLAGS,${project_library},$2,$3,$4} \ } \ ${COMPUTED_LINKFLAGS_$1_$3} ${COMPUTED_LINKFLAGS_$1_$3_$4} endef #HACK: shell/% filtered out, since shell doesn't have anything to link and there's no mechanism for distinguishing between include-only and linked libraries define fat_library_dependency_template #(target, configuration, platform) ${foreach library,${filter ${link_library}%,${PROJECT_LIBRARY_DEPENDENCIES_$1} ${PROJECT_LIBRARY_DEPENDENCIES_$1_$3}}, \ build/${library}/$2-$3/${TARGET_NAME_${library}}.a \ } \ ${foreach library,${filter-out shell/%,${COMPUTED_STEM_LIBRARY_DEPENDENCIES_$1_$3}}, \ ${STEM_SHARED_DIR}/${library}/library/$2-$3/libstem_${word 1,${subst /, ,${library}}}.a \ } \ ${foreach library,${COMPUTED_THIRDPARTY_LIBRARY_DEPENDENCIES_$1_$3}, \ ${STEM_SHARED_DIR}/${dir ${library}}${firstword ${subst /, ,${library}}}/$3/${notdir ${library}} \ } endef define thin_library_dependency_template #(target, configuration, platform, arch) ${foreach library,${filter ${link_library}%,${PROJECT_LIBRARY_DEPENDENCIES_$1} ${PROJECT_LIBRARY_DEPENDENCIES_$1_$3}}, \ build/${library}/$2-$3-$4/${TARGET_NAME_${library}}.a \ } \ ${foreach library,${filter-out shell/%,${COMPUTED_STEM_LIBRARY_DEPENDENCIES_$1_$3}}, \ ${STEM_SHARED_DIR}/${library}/library/$2-$3-$4/libstem_${word 1,${subst /, ,${library}}}.a \ } \ ${foreach library,${COMPUTED_THIRDPARTY_LIBRARY_DEPENDENCIES_$1_$3}, \ ${STEM_SHARED_DIR}/${dir ${library}}${firstword ${subst /, ,${library}}}/$3-$4/${notdir ${library}} \ } endef #Produces executable build targets for each arch/platform/target for executable and application targets ${foreach target,${EXECUTABLE_TARGETS} ${APPLICATION_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_FAT_ARCHS_${platform}}, \ ${eval ${call executable_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}${EXECUTABLE_SUFFIX_${platform}},${call fat_library_dependency_template,${target},${configuration},${platform}}}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval ${call executable_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}${EXECUTABLE_SUFFIX_${platform}},${call thin_library_dependency_template,${target},${configuration},${platform},${arch}}}} \ } \ } \ } \ } define thin_binary_list_template #(target, configuration, platform, arch, target_name) build/intermediate/$1-$2-$3-$4/$5 endef #Produces THIN_BINARIES_${target}_${configuration}_${platform}_${arch} variables for each target/configuration/platform for library targets ${foreach target,${LIBRARY_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${eval THIN_BINARIES_${target}_${configuration}_${platform}_${arch} = ${call thin_binary_list_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}.a}} \ } \ } \ } \ } #Produces THIN_BINARIES_${target}_${configuration}_${platform}_${arch} variables for each target/configuration/platform for executable targets ${foreach target,${EXECUTABLE_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${eval THIN_BINARIES_${target}_${configuration}_${platform}_${arch} = ${call thin_binary_list_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}${EXECUTABLE_SUFFIX_${platform}}}} \ } \ } \ } \ } #Produces THIN_BINARIES_${target}_${configuration}_${platform}_${arch} variables for each target/configuration/platform for application targets ${foreach target,${APPLICATION_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${eval THIN_BINARIES_${target}_${configuration}_${platform}_${arch} = ${call thin_binary_list_template,${target},${configuration},${platform},${arch},${TARGET_NAME_${target}}${EXECUTABLE_SUFFIX_${platform}}}} \ } \ } \ } \ } define assemble_fat_library_macosx #(target, configuration) build/$1/$2-macosx/${TARGET_NAME_$1}.a: ${foreach arch,${BUILT_FAT_ARCHS_macosx},${THIN_BINARIES_$1_$2_macosx_${arch}}} | build/$1/$2-macosx lipo -create -output $$@ $$^ endef define assemble_fat_library_iphonesimulator #(target, configuration) build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.a: ${foreach arch,${BUILT_FAT_ARCHS_iphonesimulator},${THIN_BINARIES_$1_$2_iphonesimulator_${arch}}} | build/$1/$2-iphonesimulator lipo -create -output $$@ $$^ endef define assemble_fat_library_iphoneos #(target, configuration) build/$1/$2-iphoneos/${TARGET_NAME_$1}.a: ${foreach arch,${BUILT_FAT_ARCHS_iphoneos},${THIN_BINARIES_$1_$2_iphoneos_${arch}}} | build/$1/$2-iphoneos lipo -create -output $$@ $$^ endef define assemble_thin_library_linux #(target, configuration, arch) build/$1/$2-linux-$3/${TARGET_NAME_$1}.a: ${THIN_BINARIES_$1_$2_linux_$3} | build/$1/$2-linux-$3 cp $$^ $$@ endef define assemble_thin_library_windows #(target, configuration, arch) build/$1/$2-windows-$3/${TARGET_NAME_$1}.a: ${THIN_BINARIES_$1_$2_windows_$3} | build/$1/$2-windows-$3 cp $$^ $$@ endef define assemble_thin_library_android #(target, configuration, arch) build/$1/$2-android-$3/${TARGET_NAME_$1}.a: ${THIN_BINARIES_$1_$2_android_$3} | build/$1/$2-android-$3 cp $$^ $$@ endef #Produces final library build targets ${foreach target,${LIBRARY_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${if ${strip ${BUILT_FAT_ARCHS_${platform}}}, \ ${eval ${call assemble_fat_library_${platform},${target},${configuration}}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval ${call assemble_thin_library_${platform},${target},${configuration},${arch}}} \ } \ } \ } \ } define copy_target_resources #(target, platform, arch, resources_dir) ${if ${strip ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$2} ${RESOURCES_$1_$2} ${RESOURCES_$2_$3} ${RESOURCES_$1_$2_$3}},mkdir -p $4,} ${foreach resource,${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$2} ${RESOURCES_$1_$2} ${RESOURCES_$2_$3} ${RESOURCES_$1_$2_$3}, \ cp -r ${resource} $4${newline_and_tab} \ } ${if ${filter macosx,${HOST_PLATFORM}}, \ ${if ${strip ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_$2} ${RESOURCES_$1_$2}},find $4 -name .svn -print0 -or -name .DS_Store -print0 | xargs -0 rm -rf} \ } endef define copy_android_target_system_resources #(target, platform, resources_dir) ${if ${strip ${SYSTEM_RESOURCES} ${SYSTEM_RESOURCES_$1} ${SYSTEM_RESOURCES_$2} ${SYSTEM_RESOURCES_$1_$2}},mkdir -p $3,} ${foreach resource,${SYSTEM_RESOURCES} ${SYSTEM_RESOURCES_$1} ${SYSTEM_RESOURCES_$2} ${SYSTEM_RESOURCES_$1_$2}, \ cp -r ${resource} $3${newline_and_tab} \ } ${if ${strip ${SYSTEM_RESOURCES} ${SYSTEM_RESOURCES_$1} ${SYSTEM_RESOURCES_$2} ${SYSTEM_RESOURCES_$1_$2}},find $3 -name .svn -print0 -or -name .DS_Store -print0 | xargs -0 rm -rf} endef define copy_target_dynamiclibs #(target, platform, arch, dll_dir) ${foreach dynamiclib,${DYNAMICLIBS_$1} ${DYNAMICLIBS_$1_$2} ${DYNAMICLIBS_$1_$2_$3}, \ cp ${dynamiclib} $3${newline_and_tab} \ } endef define assemble_fat_executable_macosx #(target, configuration) build/$1/$2-macosx/${TARGET_NAME_$1}: ${foreach arch,${BUILT_ARCHS_macosx},${THIN_BINARIES_$1_$2_macosx_${arch}}} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_macosx} ${RESOURCES_$1_macosx} | build/$1/$2-macosx lipo -create -output $$@ ${foreach arch,${BUILT_ARCHS_macosx},${THIN_BINARIES_$1_$2_macosx_${arch}}} ${if ${filter configuration,release},${STRIP_macosx -S $$@}} ${call copy_target_resources,$1,macosx,,$${dir $$@}} ${call copy_target_dynamiclibs,$1,macosx,,$${dir $$@}} endef define assemble_fat_executable_iphonesimulator #(target, configuration) build/$1/$2-iphonesimulator/${TARGET_NAME_$1}: ${foreach arch,${BUILT_ARCHS_iphonesimulator},${THIN_BINARIES_$1_$2_iphonesimulator_${arch}}} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_iphonesimulator} ${RESOURCES_$1_iphonesimulator} | build/$1/$2-iphonesimulator lipo -create -output $$@ ${foreach arch,${BUILT_ARCHS_iphonesimulator},${THIN_BINARIES_$1_$2_iphonesimulator_${arch}}} ${if ${filter configuration,release},${STRIP_iphonesimulator -S $$@}} ${call copy_target_resources,$1,iphonesimulator,,$${dir $$@}} ${call copy_target_dynamiclibs,$1,iphonesimulator,,$${dir $$@}} endef define assemble_fat_executable_iphoneos #(target, configuration) build/$1/$2-iphoneos/${TARGET_NAME_$1}: ${foreach arch,${BUILT_ARCHS_iphoneos},${THIN_BINARIES_$1_$2_iphoneos_${arch}}} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_iphoneos} ${RESOURCES_$1_iphoneos} | build/$1/$2-iphoneos lipo -create -output $$@ ${foreach arch,${BUILT_ARCHS_iphoneos},${THIN_BINARIES_$1_$2_iphoneos_${arch}}} ${if ${filter configuration,release},${STRIP_iphoneos -S $$@}} ${call copy_target_resources,$1,iphoneos,,$${dir $$@}} ${call copy_target_dynamiclibs,$1,iphoneos,,$${dir $$@}} endef define assemble_thin_executable_linux #(target, configuration, arch) build/$1/$2-linux-$3/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_linux_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_linux} ${RESOURCES_linux_$3} ${RESOURCES_$1_linux} ${RESOURCES_$1_linux_$3} | build/$1/$2-linux-$3 cp ${THIN_BINARIES_$1_$2_linux_$3} $$@ ${if ${filter configuration,release},${STRIP_linux_$3 -S $$@}} ${call copy_target_resources,$1,linux,$3,$${dir $$@}} ${call copy_target_dynamiclibs,$1,linux,$3,$${dir $$@}} endef define assemble_thin_executable_windows #(target, configuration, arch) build/$1/$2-windows-$3/${TARGET_NAME_$1}.exe: ${THIN_BINARIES_$1_$2_windows_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_windows} ${RESOURCES_windows_$3} ${RESOURCES_$1_windows} ${RESOURCES_$1_windows_$3} | build/$1/$2-windows-$3 cp ${THIN_BINARIES_$1_$2_windows_$3} $$@ ${if ${filter configuration,release},${STRIP_windows_$3 -S $$@}} ${call copy_target_resources,$1,windows,$3,$${dir $$@}} ${call copy_target_dynamiclibs,$1,windows,$3,$${dir $$@}} endef #TODO: This is invalid define assemble_thin_executable_android #(target, configuration, arch) build/$1/$2-android-$3/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_android_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_android} ${RESOURCES_android_$3} ${RESOURCES_$1_android} ${RESOURCES_$1_android_$3} | build/$1/$2-android-$3 cp ${THIN_BINARIES_$1_$2_android_$3} $$@ ${if ${filter configuration,release},${STRIP_android_$3 -S $$@}} ${call copy_target_resources,$1,android,$3,$${dir $$@}} ${call copy_target_dynamiclibs,$1,android,$3,$${dir $$@}} endef #Produces final executable build targets ${foreach target,${EXECUTABLE_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${if ${strip ${BUILT_FAT_ARCHS_${platform}}}, \ ${eval ${call assemble_fat_executable_${platform},${target},${configuration}}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval ${call assemble_thin_executable_${platform},${target},${configuration},${arch}}} \ } \ } \ } \ } PLIST_PLATFORM_CASED_iphonesimulator = iPhoneSimulator PLIST_PLATFORM_LOWER_iphonesimulator = iphonesimulator PLIST_SDK_NAME_iphonesimulator = iphonesimulator${IPHONESIMULATOR_VERSION_MIN} PLIST_PLATFORM_CASED_iphoneos = iPhoneOS PLIST_PLATFORM_LOWER_iphoneos = iphoneos PLIST_SDK_NAME_iphoneos = iphoneos${IPHONEOS_VERSION_MIN} define create_app_bundle #(target, platform, executable_dir, plist_dir, resources_dir) mkdir -p $3 $4 $5 sed -e "s/\$$$${PRODUCT_NAME}/${TARGET_NAME_$1}/g" \ -e "s/\$$$${HUMAN_READABLE_PRODUCT_NAME}/${HUMAN_READABLE_TARGET_NAME_$1}/g" \ -e "s/\$$$${VERSION}/${PROJECT_VERSION}/g" \ -e "s/\$$$${COPYRIGHT_YEAR}/"`date +%Y`"/g" \ -e "s/\$$$${BUILD_NUMBER}/0/g" \ -e "s/\$$$${PLATFORM_CASED}/${PLIST_PLATFORM_CASED_$2}/g" \ -e "s/\$$$${PLATFORM_LOWER}/${PLIST_PLATFORM_LOWER_$2}/g" \ -e "s/\$$$${SDK}/${PLIST_SDK_NAME_$2}/g" \ ${PLIST_FILE_$1_$2} > $4/Info.plist echo "APPL????" > $4/PkgInfo ${call copy_target_resources,$1,$2,,$5} endef define assemble_fat_application_macosx #(target, configuration) build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/MacOS/${TARGET_NAME_$1}: ${foreach arch,${BUILT_ARCHS_macosx},${THIN_BINARIES_$1_$2_macosx_${arch}}} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_macosx} ${RESOURCES_$1_macosx} | build/$1/$2-macosx ${call create_app_bundle,$1,macosx,build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/MacOS,build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents,build/$1/$2-macosx/$${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/Resources} lipo -create -output "$$@" ${foreach arch,${BUILT_ARCHS_macosx},${THIN_BINARIES_$1_$2_macosx_${arch}}} ${if ${filter configuration,release},${STRIP_macosx -S "$$@"}} endef define assemble_fat_application_iphonesimulator #(target, configuration) build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app/${TARGET_NAME_$1}: ${foreach arch,${BUILT_ARCHS_iphonesimulator},${THIN_BINARIES_$1_$2_iphonesimulator_${arch}}} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_iphonesimulator} ${RESOURCES_$1_iphonesimulator} | build/$1/$2-iphonesimulator ${call create_app_bundle,$1,iphonesimulator,build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app,build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app,build/$1/$2-iphonesimulator/${TARGET_NAME_$1}.app} lipo -create -output "$$@" ${foreach arch,${BUILT_ARCHS_iphonesimulator},${THIN_BINARIES_$1_$2_iphonesimulator_${arch}}} ${if ${filter configuration,release},${STRIP_iphonesimulator -S "$$@"}} endef define assemble_fat_application_iphoneos #(target, configuration) build/$1/$2-iphoneos/${TARGET_NAME_$1}.app/${TARGET_NAME_$1}: ${foreach arch,${BUILT_ARCHS_iphoneos},${THIN_BINARIES_$1_$2_iphoneos_${arch}}} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_iphoneos} ${RESOURCES_$1_iphoneos} | build/$1/$2-iphoneos ${call create_app_bundle,$1,iphoneos,build/$1/$2-iphoneos/${TARGET_NAME_$1}.app,build/$1/$2-iphoneos/${TARGET_NAME_$1}.app,build/$1/$2-iphoneos/${TARGET_NAME_$1}.app} lipo -create -output "$$@" ${foreach arch,${BUILT_ARCHS_iphoneos},${THIN_BINARIES_$1_$2_iphoneos_${arch}}} ${if ${filter configuration,release},${STRIP_iphoneos -S "$$@"}} endef define assemble_thin_application_linux #(target, configuration, arch) build/$1/$2-linux-$3/${TARGET_NAME_$1}: ${THIN_BINARIES_$1_$2_linux_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_linux} ${RESOURCES_linux_$3} ${RESOURCES_$1_linux} ${RESOURCES_$1_linux_$3} | build/$1/$2-linux-$3 ${call copy_target_resources,$1,linux,$3,$${dir $$@}Resources} ${call copy_target_dynamiclibs,$1,linux,$3,$${dir $$@}} cp ${THIN_BINARIES_$1_$2_linux_$3} "$$@" ${if ${filter configuration,release},${STRIP_linux_$3 -S "$$@"}} endef define assemble_thin_application_windows #(target, configuration, arch) build/$1/$2-windows-$3/${TARGET_NAME_$1}.exe: ${THIN_BINARIES_$1_$2_windows_$3} ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_windows} ${RESOURCES_windows_$3} ${RESOURCES_$1_windows} ${RESOURCES_$1_windows_$3} | build/$1/$2-windows-$3 ${call copy_target_resources,$1,windows,$3,$${dir $$@}Resources} ${call copy_target_dynamiclibs,$1,windows,$3,$${dir $$@}} cp ${THIN_BINARIES_$1_$2_windows_$3} "$$@" ${if ${filter configuration,release},${STRIP_windows_$3 -S "$$@"}} endef define assemble_thin_application_android #(target, configuration, arch) build/$1/$2-android-$3/${TARGET_NAME_$1}.apk: ${THIN_BINARIES_$1_$2_android_$3} ${MANIFEST_FILE_$1_android} build/intermediate/resources_$1 build/intermediate/$1-android-$3/classes.dex build/intermediate/$1-$2-android-$3/${TARGET_NAME_$1} | build/$1/$2-android-$3 build/intermediate/$1-$2-android-$3 mkdir -p build/intermediate/$1-$2-android-$3/lib/armeabi-v7a cp build/intermediate/$1-$2-android-$3/${TARGET_NAME_$1} build/intermediate/$1-$2-android-$3/lib/armeabi-v7a/lib${TARGET_NAME_$1}.so ${AAPT} package -f -M $${MANIFEST_FILE_$1_android} $${if $${strip $${SYSTEM_RESOURCES} $${SYSTEM_RESOURCES_$1} $${SYSTEM_RESOURCES_android} $${SYSTEM_RESOURCES_$1_android}},-S build/intermediate/resources_$1/res,} $${if $${strip $${RESOURCES} $${RESOURCES_$1} $${RESOURCES_android} $${RESOURCES_android_$3} $${RESOURCES_$1_android} $${RESOURCES_$1_android_$3}},-A build/intermediate/resources_$1/assets,} -I ${ANDROID_JAR} -F build/intermediate/$1-$2-android-$3/${TARGET_NAME_$1}.apk.unaligned cp build/intermediate/$1-android-$3/classes.dex build/intermediate/$1-$2-android-$3/classes.dex cd build/intermediate/$1-$2-android-$3 && ${AAPT} add ${TARGET_NAME_$1}.apk.unaligned classes.dex && ${AAPT} add ${TARGET_NAME_$1}.apk.unaligned lib/armeabi-v7a/lib${TARGET_NAME_$1}.so ${ZIPALIGN} -f 4 build/intermediate/$1-$2-android-$3/${TARGET_NAME_$1}.apk.unaligned build/intermediate/$1-$2-android-$3/${TARGET_NAME_$1}.apk.aligned JAVA_HOME="${JAVA_HOME}" ${APKSIGNER} sign --ks ~/.android/debug.keystore --ks-pass "pass:android" build/intermediate/$1-$2-android-$3/${TARGET_NAME_$1}.apk.aligned mv build/intermediate/$1-$2-android-$3/${TARGET_NAME_$1}.apk.aligned $$@ endef #Produces final application build targets ${foreach target,${APPLICATION_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${if ${strip ${BUILT_FAT_ARCHS_${platform}}}, \ ${eval ${call assemble_fat_application_${platform},${target},${configuration}}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval ${call assemble_thin_application_${platform},${target},${configuration},${arch}}} \ } \ } \ } \ } define LIBRARY_file_dependency_template #(target, configuration, platform, platform-arch) build/$1/$2-$4/${TARGET_NAME_$1}.a endef define EXECUTABLE_file_dependency_template #(target, configuration, platform, platform-arch) build/$1/$2-$4/${TARGET_NAME_$1}${EXECUTABLE_SUFFIX_$3} endef define APPLICATION_file_dependency_template #(target, configuration, platform, platform-arch) build/$1/$2-$4/${call application_file_name_template_$3,$1} endef define application_file_name_template_macosx #(target) $${HUMAN_READABLE_TARGET_NAME_$1}.app/Contents/MacOS/${TARGET_NAME_$1} endef define application_file_name_template_iphonesimulator #(target) ${TARGET_NAME_$1}.app/${TARGET_NAME_$1} endef define application_file_name_template_iphoneos #(target) ${TARGET_NAME_$1}.app/${TARGET_NAME_$1} endef define application_file_name_template_linux #(target) ${TARGET_NAME_$1} endef define application_file_name_template_windows #(target) ${TARGET_NAME_$1}.exe endef define application_file_name_template_android #(target) ${TARGET_NAME_$1}.apk # TODO: ? endef define THIRDPARTY_LIBRARY_file_dependency_template #(target, configuration, platform, platform-arch) ${foreach library,${BUILT_THIRDPARTY_LIBRARY_FILES_$1},build/$1/$4/${library}} ${THIRDPARTY_LIBRARY_WORKING_SUBDIR_$1} endef define HEADER_ONLY_file_dependency_template #(target, configuration, platform, platform-arch) ${INCLUDES} endef define target_template #(target, target_type) .PHONY: $1 $1: ${foreach configuration,${CONFIGURATIONS_$1}, \ ${foreach platform,${TARGET_PLATFORMS_$1}, \ ${if ${strip ${BUILT_FAT_ARCHS_${platform}}}, \ ${call $2_file_dependency_template,$1,${configuration},${platform},${platform}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${call $2_file_dependency_template,$1,${configuration},${platform},${platform}-${arch}} \ } \ } \ } endef ${foreach target_type,LIBRARY EXECUTABLE APPLICATION THIRDPARTY_LIBRARY HEADER_ONLY, \ ${foreach target,${${target_type}_TARGETS}, \ ${eval ${call target_template,${target},${target_type}}} \ } \ } .PHONY: test test: ${foreach platform,${TARGET_PLATFORMS_unittest},run_unittests_${platform}} define run_fat_unittests_template #(platform) .PHONY: run_unittests_$1 run_unittests_$1: unittest ./build/unittest/debug-$1/${TARGET_NAME_unittest} "${CURDIR}/build/unittest/debug-$1" endef define run_all_thin_unittests_template #(platform) .PHONY: run_unittests_$1 run_unittests_$1: ${foreach arch,${BUILT_THIN_ARCHS_$1},run_unittests_$1_${arch}} endef define run_thin_unittests_template #(platform, arch) .PHONY: run_unittests_$1_$2 run_unittests_$1_$2: unittest ./build/unittest/debug-$1-$2/${TARGET_NAME_unittest} "${CURDIR}/build/unittest/debug-$1-$2" endef ${foreach fat_platform,macosx, \ ${eval ${call run_fat_unittests_template,${fat_platform}}} \ } ${foreach thin_platform,linux windows, \ ${foreach arch,${BUILT_THIN_ARCHS_${thin_platform}}, \ ${eval ${call run_thin_unittests_template,${thin_platform},${arch}}} \ } \ ${eval ${call run_all_thin_unittests_template,${thin_platform}}} \ } .PHONY: run_unittests_iphonesimulator run_unittests_iphonesimulator: unittest DYLD_ROOT_PATH=${SDKROOT_iphonesimulator_unittest} \ ./build/unittest/debug-iphonesimulator/${TARGET_NAME_unittest} "${CURDIR}/build/unittest/debug-iphonesimulator" .PHONY: run_unittests_android run_unittests_android: unittest # TODO: Invoke emulator? ${foreach dir,${sort ${foreach include_file,${INCLUDES},build/include/${notdir ${patsubst %/,%,${dir ${include_file}}}}}}, \ ${eval ${call create_directory_target_template,${dir}}} \ } ${if ${strip ${INCLUDES_NO_SUBDIR}}, \ ${eval ${call create_directory_target_template,build/include}} \ } .PHONY: include include: ${INCLUDES} ${INCLUDES_NO_SUBDIR} | ${foreach include_file,${INCLUDES},build/include/${notdir ${patsubst %/,%,${dir ${include_file}}}}} ${if ${strip ${INCLUDES_NO_SUBDIR}},build/include} ${foreach include_file,${INCLUDES}, \ cp -p ${include_file} build/include/${notdir ${patsubst %/,%,${dir ${include_file}}}}${newline_and_tab} \ } ${foreach bare_include_file,${INCLUDES_NO_SUBDIR}, \ cp -p ${bare_include_file} build/include${newline_and_tab} \ } ${INCLUDES} ${INCLUDES_NO_SUBDIR}: ${THIRDPARTY_LIBRARY_TARGETS} .PHONY: clean clean: rm -rf build .PHONY: clean_d ifneq (${PRINT_D_COMMANDS},1) .SILENT: clean_d endif clean_d: ${foreach target,${STEM_TARGETS}, \ ${foreach configuration,${CONFIGURATIONS_${target}}, \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${foreach source,${SOURCES_${target}} ${SOURCES_${target}_${platform}}, \ rm -f build/intermediate/${target}-${configuration}-${platform}-${arch}/${notdir ${basename ${source}}}.d${newline_and_tab} \ } \ ${foreach source,${CPP_SOURCES_${target}} ${CPP_SOURCES_${target}_${platform}}, \ rm -f build/intermediate/${target}-${configuration}-${platform}-${arch}/${notdir ${basename ${source}}}.d${newline_and_tab} \ } \ } \ } \ } \ } @echo "Dependency files removed" define texture_atlas_template #(config_file) ${shell ${TEXTUREPACKER} --outputs -c $1}: $1 ${TEXTUREPACKER} ${shell ${TEXTUREPACKER} --prereqs -c $1} | build/generated ${TEXTUREPACKER} -c $$< endef ${foreach texture_atlas,${GENERATED_TEXTURE_ATLASES}, \ ${eval ${call texture_atlas_template,${texture_atlas}}} \ } define bitmap_font_template #(config_file) ${shell ${MAKEFONT} --outputs -c $1}: $1 ${MAKEFONT} ${shell ${MAKEFONT} --prereqs -c $1} | build/generated ${MAKEFONT} -c $$< endef ${foreach bitmap_font,${GENERATED_BITMAP_FONTS}, \ ${eval ${call bitmap_font_template,${bitmap_font}}} \ } IOS_SIM ?= ios-sim define launch_target_iphonesimulator_template #(target) .PHONY: launch_$1_iphonesimulator launch_$1_iphonesimulator: $1 ${IOS_SIM} launch "build/$1/debug-iphonesimulator/${TARGET_NAME_$1}.app" ${IOS_SIM_ARGS} endef define launch_target_androidemulator_template #(target) .PHONY: launch_$1_androidemulator launch_$1_androidemulator: $1 # TODO: Install apk and launch in emulator somehow endef define add_blob_header #(source_file, target_file) ruby -e "contents = \"\"; File.open(\"$1\", \"r\") {|file| contents = file.read}; File.open(\"$2\", \"w\") {|file| file.write(\"\xFA\xDE\x71\x71\"); file.write([contents.length + 8].pack(\"N\")); file.write(contents)}" endef RESOURCE_RULES_PLIST ?= /Developer/Platforms/MacOSX.platform/ResourceRules.plist define codesign_target_iphoneos_template #(target) .PHONY: codesign_$1_iphoneos codesign_$1_iphoneos: $1 sed -e "s/\$$$${PRODUCT_NAME}/${TARGET_NAME_$1}/g" resources/Entitlements.plist > build/intermediate/Entitlements.plist ${call add_blob_header,build/intermediate/Entitlements.plist,build/intermediate/Entitlements.xcent} export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate ${foreach configuration,${CONFIGURATIONS_$1},\ cp "${RESOURCE_RULES_PLIST}" "build/$1/${configuration}-iphoneos/${TARGET_NAME_$1}.app"${newline_and_tab} \ /usr/bin/codesign -f -s ${CODESIGN_IDENTITY} --resource-rules=${RESOURCE_RULES_PLIST} --entitlements=build/intermediate/Entitlements.xcent "build/$1/${configuration}-iphoneos/${TARGET_NAME_$1}.app"${newline_and_tab} \ } endef define install_target_android_template #(target, arch) .PHONY: install_$1_android install_$1_android: $1 ${ADB} install -r -t build/$1/debug-android-armv7a/${TARGET_NAME_$1}.apk ${ADB} shell am start -n $${ANDROID_LAUNCH_ACTIVITY_NAME_$1} -a android.intent.action.MAIN -c android.intent.category.LAUNCHER endef ${foreach target,${APPLICATION_TARGETS}, \ ${if ${filter iphonesimulator,${TARGET_PLATFORMS_${target}}}, \ ${eval ${call launch_target_iphonesimulator_template,${target}}} \ } \ ${if ${filter iphoneos,${TARGET_PLATFORMS_${target}}}, \ ${eval ${call codesign_target_iphoneos_template,${target}}} \ } \ ${if ${filter androidemulator,${TARGET_PLATFORMS_${target}}}, \ ${eval ${call launch_target_androidemulator_template,${target}}} \ } \ ${if ${filter android,${TARGET_PLATFORMS_${target}}}, \ ${eval ${call install_target_android_template,${target},${ARCHS_android}}} \ } \ } define android_resource_template #(target) build/intermediate/resources_$1: ${RESOURCES} ${RESOURCES_$1} ${RESOURCES_android} ${RESOURCES_$1_android} ${SYSTEM_RESOURCES} ${SYSTEM_RESOURCES_android} ${SYSTEM_RESOURCES_$1} ${SYSTEM_RESOURCES_android_$1} ${call copy_android_target_system_resources,$1,android,build/intermediate/resources_$1/res} ${call copy_target_resources,$1,android,armv7a,build/intermediate/resources_$1/assets} endef define java_r_template #(target) build/intermediate/$1-android-armv7a/rjava/${JAVA_PACKAGE_SUBDIR_$1}/R.java: build/intermediate/resources_$1 ${MANIFEST_FILE_$1_android} mkdir -p build/intermediate/$1-android-armv7a/rjava ${AAPT} package -m -S build/intermediate/resources_$1/res -J build/intermediate/$1-android-armv7a/rjava -M ${MANIFEST_FILE_$1_android} -I ${ANDROID_JAR} endef define java_dex_template #(target) build/intermediate/$1-android-armv7a/classes.dex: build/intermediate/$1-android-armv7a/javac/${JAVA_PACKAGE_SUBDIR_$1}/${basename ${notdir ${firstword ${JAVA_SOURCES_$1}}}}.class build/intermediate/$1-android-armv7a/javac/${JAVA_PACKAGE_SUBDIR_$1}/R.class JAVA_HOME="${JAVA_HOME}" ${DX} --dex --output $$@ build/intermediate/$1-android-armv7a/javac ${JAR_DEPENDENCIES_$1} endef define java_compile_template #(target) build/intermediate/$1-android-armv7a/javac/${JAVA_PACKAGE_SUBDIR_$1}/${basename ${notdir ${firstword ${JAVA_SOURCES_$1}}}}.class: ${JAVA_SOURCES_$1} ${JAR_DEPENDENCIES_$1} mkdir -p build/intermediate/$1-android-armv7a/javac JAVA_HOME="${JAVA_HOME}" "${JAVAC}" -classpath "${ANDROID_JAR}${foreach jar,${JAR_DEPENDENCIES_$1},:${jar}}" -bootclasspath "${JAVA_HOME}/jre/lib/rt.jar" -sourcepath ${dir ${firstword ${JAVA_SOURCES_$1}}} -d build/intermediate/$1-android-armv7a/javac -target 1.7 -source 1.7 $$^ endef define java_compile_template_r #(target) build/intermediate/$1-android-armv7a/javac/${JAVA_PACKAGE_SUBDIR_$1}/${basename ${notdir ${firstword ${JAVA_SOURCES_$1}}}}.class: ${JAVA_SOURCES_$1} build/intermediate/$1-android-armv7a/rjava/${JAVA_PACKAGE_SUBDIR_$1}/R.java ${JAR_DEPENDENCIES_$1} mkdir -p build/intermediate/$1-android-armv7a/javac JAVA_HOME="${JAVA_HOME}" "${JAVAC}" -classpath "${ANDROID_JAR}${foreach jar,${JAR_DEPENDENCIES_$1},:${jar}}" -bootclasspath "${JAVA_HOME}/jre/lib/rt.jar" -sourcepath ${dir ${firstword ${JAVA_SOURCES_$1}}} -sourcepath build/intermediate/$1-android-armv7a/rjava -d build/intermediate/$1-android-armv7a/javac -target 1.7 -source 1.7 ${JAVA_SOURCES_$1} build/intermediate/$1-android-armv7a/rjava/${JAVA_PACKAGE_SUBDIR_$1}/R.java endef define generate_eglshell_java_template #(target) build/generated/${GENERATE_ANDROID_CLASS_NAME_$1}.java: ${STEM_SHARED_DIR}/EGLShell_activity_template.java | build/generated sed -e "s/\$$$${PACKAGE_NAME}/${GENERATE_ANDROID_PACKAGE_NAME_$1}/g" \ -e "s/\$$$${CLASS_NAME}/${GENERATE_ANDROID_CLASS_NAME_$1}/g" \ -e "s/\$$$${LIBRARY_NAME}/${TARGET_NAME_$1}/g" \ $$^ > $$@ endef define generate_android_manifest_template #(target) build/generated/AndroidManifest.xml: ${STEM_SHARED_DIR}/EGLShell_manifest_template.xml | build/generated sed -e "s/\$$$${PACKAGE_NAME}/${GENERATE_ANDROID_PACKAGE_NAME_$1}/g" \ -e "s/\$$$${CLASS_NAME}/${GENERATE_ANDROID_CLASS_NAME_$1}/g" \ -e "s/\$$$${APP_NAME}/${HUMAN_READABLE_TARGET_NAME_$1}/g" \ $$^ > $$@ endef ${foreach target,${APPLICATION_TARGETS}, \ ${if ${filter android,${TARGET_PLATFORMS_${target}}}, \ ${if ${strip ${GENERATE_ANDROID_CLASS_NAME_${target}}}, \ ${eval JAVA_SOURCES_${target} += build/generated/${GENERATE_ANDROID_CLASS_NAME_${target}}.java} \ ${eval MANIFEST_FILE_${target}_android = build/generated/AndroidManifest.xml} \ ${eval ANDROID_LAUNCH_ACTIVITY_NAME_${target} = "${GENERATE_ANDROID_PACKAGE_NAME_${target}}/${GENERATE_ANDROID_PACKAGE_NAME_${target}}.${GENERATE_ANDROID_CLASS_NAME_${target}}"} \ ${eval JAVA_PACKAGE_SUBDIR_${target} = ${subst .,/,${GENERATE_ANDROID_PACKAGE_NAME_${target}}}} \ ${eval ${call generate_eglshell_java_template,${target}}} \ ${eval ${call generate_android_manifest_template,${target}}} \ ,} \ ${if ${strip ${USE_DEFAULT_ICONS_${target}}}, \ ${eval SYSTEM_RESOURCES_${target} += ${STEM_SHARED_DIR}/icons/android/mipmap-hdpi ${STEM_SHARED_DIR}/icons/android/mipmap-mdpi ${STEM_SHARED_DIR}/icons/android/mipmap-xhdpi ${STEM_SHARED_DIR}/icons/android/mipmap-xxhdpi} \ ,} \ ${eval JAR_DEPENDENCIES_${target} = ${foreach target,${PROJECT_JAR_DEPENDENCIES_${target}},build/${target}.jar } ${foreach project,${COMPUTED_STEM_JAR_DEPENDENCIES_${target}},${STEM_SHARED_DIR}/${project}/${word 1,${subst /, ,${project}}}.jar }} \ ${eval ${call android_resource_template,${target}}} \ ${eval ${call java_r_template,${target}}} \ ${eval ${call java_dex_template,${target}}} \ ${eval ${call java_compile_template_r,${target}}} \ } \ } define create_jar_template #(target) .PHONY: $1 $1: build/$1.jar build/$1.jar: build/intermediate/$1-android-armv7a/javac/${JAVA_PACKAGE_SUBDIR_$1}/${basename ${notdir ${firstword ${JAVA_SOURCES_$1}}}}.class cd build/intermediate/$1-android-armv7a/javac && JAVA_HOME="${JAVA_HOME}" "${JAR}" cf $1.jar . mv build/intermediate/$1-android-armv7a/javac/$1.jar $$@ endef ${foreach target,${JAR_TARGETS}, \ ${eval ${call create_jar_template,${target}}} \ ${eval ${call java_compile_template,${target}}} \ } INSTALL_DIR = ${STEM_SHARED_DIR}/${PROJECT_NAME}/${PROJECT_VERSION} define install_template .PHONY: install install: ${if ${filter-out ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}},mkdir -p ${foreach installed_target,${filter-out ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}},"${INSTALL_DIR}/${installed_target}"}} ${if ${filter ${LIBRARY_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS} ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}},rm -rf "${INSTALL_DIR}/include/*"} ${if ${filter ${LIBRARY_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS} ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}},mkdir -p "${INSTALL_DIR}/include"} ${if ${filter ${LIBRARY_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS} ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}},cp -r -p build/include/* ${INSTALL_DIR}/include} ${if ${filter ${LIBRARY_TARGETS} ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}},cp -p Changes.txt License.txt ReadMe.txt ${INSTALL_DIR}} ${foreach installed_target,${filter-out ${JAR_TARGETS} ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}},cp -r -p build/${installed_target}/* "${INSTALL_DIR}/${installed_target}"${newline_and_tab}} ${foreach installed_jar,${filter ${JAR_TARGETS},${INSTALLED_TARGETS}},cp -p build/${installed_jar}.jar "${INSTALL_DIR}/${installed_jar}.jar"${newline_and_tab}} ${if ${strip ${filter ${LIBRARY_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS} ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}}},ruby ${STEM_SHARED_DIR}/stemconfig.rb --register-installed ${if ${strip ${THIRDPARTY_LIBRARY_TARGETS}},thirdparty,stem} ${PROJECT_NAME} ${firstword ${MAKEFILE_LIST}}} ${if ${and ${strip ${filter ${EXECUTABLE_TARGETS},${INSTALLED_TARGETS}}},${if ${strip ${filter ${LIBRARY_TARGETS} ${THIRDPARTY_LIBRARY_TARGETS} ${HEADER_ONLY_TARGETS},${INSTALLED_TARGETS}}},,true}},ruby ${STEM_SHARED_DIR}/stemconfig.rb --register-installed tool ${PROJECT_NAME} ${firstword ${MAKEFILE_LIST}}} endef ${if ${strip ${INSTALLED_TARGETS}}, \ ${eval ${call install_template}} \ } define thirdparty_library_working_subdir_template #(target) ${THIRDPARTY_LIBRARY_WORKING_SUBDIR_$1}: ${THIRDPARTY_LIBRARY_PRISTINE_SUBDIR_$1} mkdir -p $${dir $$@} rm -rf $$@ cp -r $$^ $$@ ${if ${filter macosx,${HOST_PLATFORM}}, \ find $$@ -name .svn -print0 | xargs -0 rm -rf \ } endef define thirdparty_library_build_template #(target, platform, arch) ${foreach library,${BUILT_THIRDPARTY_LIBRARY_FILES_$1},build/intermediate/$1-$2-$3/${library}}: ${THIRDPARTY_LIBRARY_WORKING_SUBDIR_$1} ${call $1_build_commands_$2,$3} mkdir -p $${dir $$@} cp ${BUILT_LIBRARY_LOCATION_$1} ${BUILT_LIBRARY_LOCATION_$1_$2} $${dir $$@} ${call $1_clean_commands_$2,$3} endef define assemble_fat_thirdparty_library #(target, platform, library) build/$1/$2/$3: ${foreach arch,$${BUILT_FAT_ARCHS_$2},build/intermediate/$1-$2-${arch}/$3} mkdir -p $${dir $$@} lipo -create -output $$@ $$^ endef define assemble_thin_thirdparty_library #(target, platform, library, arch) build/$1/$2-$3/$4: build/intermediate/$1-$2-$3/$4 mkdir -p $${dir $$@} cp $$^ $$@ endef ${foreach target,${THIRDPARTY_LIBRARY_TARGETS}, \ ${eval ${call thirdparty_library_working_subdir_template,${target}}} \ ${foreach platform,${TARGET_PLATFORMS_${target}}, \ ${foreach arch,${BUILT_ARCHS_${platform}}, \ ${eval ${call thirdparty_library_build_template,${target},${platform},${arch}}} \ } \ ${foreach library,${BUILT_THIRDPARTY_LIBRARY_FILES_${target}}, \ ${if ${strip ${BUILT_FAT_ARCHS_${platform}}}, \ ${eval ${call assemble_fat_thirdparty_library,${target},${platform},${library}}} \ } \ ${foreach arch,${BUILT_THIN_ARCHS_${platform}}, \ ${eval ${call assemble_thin_thirdparty_library,${target},${platform},${arch},${library}}} \ } \ } \ } \ }