diff options
-rwxr-xr-x | android-configure.sh | 6 | ||||
-rw-r--r-- | android/build/binary.make | 7 | ||||
-rw-r--r-- | android/build/clear_vars.make | 1 | ||||
-rw-r--r-- | android/build/common.sh | 4 | ||||
-rw-r--r-- | android/build/definitions.make | 28 | ||||
-rw-r--r-- | android/build/host_executable.make | 4 |
6 files changed, 42 insertions, 8 deletions
diff --git a/android-configure.sh b/android-configure.sh index a36ece7..02e4d99 100755 --- a/android-configure.sh +++ b/android-configure.sh @@ -110,6 +110,12 @@ if [ -z "$CC" -a -z "$OPTION_CC" -a "$HOST_OS" = linux -a "$OPTION_TRY_64" != "y fi fi +echo "OPTION_CC='$OPTION_CC'" +if [ -n "$OPTION_CC" ]; then + echo "Using specified C compiler: $OPTION_CC" + CC="$OPTION_CC" +fi + # we only support generating 32-bit binaris on 64-bit systems. # And we may need to add a -Wa,--32 to CFLAGS to let the assembler # generate 32-bit binaries on Linux x86_64. diff --git a/android/build/binary.make b/android/build/binary.make index e22a96d..f6542dc 100644 --- a/android/build/binary.make +++ b/android/build/binary.make @@ -20,7 +20,8 @@ LOCAL_OBJS_DIR := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE)) LOCAL_OBJECTS := LOCAL_CC ?= $(CC) -LOCAL_C_SOURCES := $(filter %.c,$(LOCAL_SRC_FILES) $(LOCAL_GENERATED_SOURCES)) +LOCAL_C_SOURCES := $(filter %.c,$(LOCAL_SRC_FILES)) +LOCAL_GENERATED_C_SOURCES := $(filter %.c,$(LOCAL_GENERATED_SOURCES)) LOCAL_CXX_SOURCES := $(filter %$(LOCAL_CPP_EXTENSION),$(LOCAL_SRC_FILES) $(LOCAL_GENERATED_SOURCES)) LOCAL_OBJC_SOURCES := $(filter %.m,$(LOCAL_SRC_FILES) $(LOCAL_GENERATED_SOURCES)) @@ -28,6 +29,10 @@ $(foreach src,$(LOCAL_C_SOURCES), \ $(eval $(call compile-c-source,$(src))) \ ) +$(foreach src,$(LOCAL_GENERATED_C_SOURCES), \ + $(eval $(call compile-generated-c-source,$(src))) \ +) + $(foreach src,$(LOCAL_CXX_SOURCES), \ $(eval $(call compile-cxx-source,$(src))) \ ) diff --git a/android/build/clear_vars.make b/android/build/clear_vars.make index f84ecb4..f4ca9b7 100644 --- a/android/build/clear_vars.make +++ b/android/build/clear_vars.make @@ -27,5 +27,6 @@ LOCAL_MODULE_PATH:= LOCAL_STATIC_LIBRARIES := LOCAL_BUILT_MODULE := LOCAL_PREBUILT_OBJ_FILES := +LOCAL_GENERATED_SOURCES := LOCAL_CPP_EXTENSION := .cpp diff --git a/android/build/common.sh b/android/build/common.sh index 2f44d70..050fd90 100644 --- a/android/build/common.sh +++ b/android/build/common.sh @@ -269,7 +269,7 @@ EOF compile if [ $? != 0 ] ; then - echo "your C compiler doesn't seem to work:" + echo "your C compiler doesn't seem to work: $CC" cat $TMPL clean_exit fi @@ -534,7 +534,7 @@ create_config_mk () cat $TMPL clean_exit fi - + # re-create the start of the configuration file log "Generate : $config_mk" diff --git a/android/build/definitions.make b/android/build/definitions.make index e190cdd..ab9a34d 100644 --- a/android/build/definitions.make +++ b/android/build/definitions.make @@ -22,7 +22,7 @@ hide := @ else define pretty endef -hide := +hide := endif define my-dir @@ -31,7 +31,7 @@ endef # return the directory containing the intermediate files for a given # kind of executable -# $1 = type (EXECUTABLES or STATIC_LIBRARIES) +# $1 = type (EXECUTABLES or STATIC_LIBRARIES) # $2 = module name # $3 = ignored # @@ -41,7 +41,7 @@ endef # Generate the full path of a given static library define library-path -$(OBJS_DIR)/$(1).a +$(OBJS_DIR)/libs/$(1).a endef define executable-path @@ -92,7 +92,7 @@ endef # define compile-objc-source SRC:=$(1) -OBJ:=$$(LOCAL_OBJS_DIR)/$$(SRC:%.m=%.o) +OBJ:=$$(LOCAL_OBJS_DIR)/$$(notdir $$(SRC:%.m=%.o)) LOCAL_OBJECTS += $$(OBJ) DEPENDENCY_DIRS += $$(dir $$(OBJ)) $$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(OBJS_DIR) @@ -108,6 +108,26 @@ $$(OBJ): $$(SRC_PATH)/$$(SRC) $(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d endef +# Compile a generated C source files# +# +define compile-generated-c-source +SRC:=$(1) +OBJ:=$$(LOCAL_OBJS_DIR)/$$(notdir $$(SRC:%.c=%.o)) +LOCAL_OBJECTS += $$(OBJ) +DEPENDENCY_DIRS += $$(dir $$(OBJ)) +$$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(OBJS_DIR) +$$(OBJ): PRIVATE_CC := $$(LOCAL_CC) +$$(OBJ): PRIVATE_OBJ := $$(OBJ) +$$(OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) +$$(OBJ): PRIVATE_SRC := $$(SRC) +$$(OBJ): PRIVATE_SRC0 := $$(SRC) +$$(OBJ): $$(SRC) + @mkdir -p $$(dir $$(PRIVATE_OBJ)) + @echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)" + $(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC) + $(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d +endef + # Install a file # define install-target diff --git a/android/build/host_executable.make b/android/build/host_executable.make index 704da98..ca1e8ee 100644 --- a/android/build/host_executable.make +++ b/android/build/host_executable.make @@ -18,13 +18,15 @@ LOCAL_BUILT_MODULE := $(call executable-path,$(LOCAL_MODULE))$(HOST_EXEEXT) LOCAL_CC ?= $(CC) include $(BUILD_SYSTEM)/binary.make +LOCAL_LIBRARIES := $(foreach lib,$(LOCAL_STATIC_LIBRARIES),$(call library-path,$(lib))) + LOCAL_LDLIBS := $(foreach lib,$(LOCAL_STATIC_LIBRARIES),$(call library-path,$(lib))) $(LOCAL_LDLIBS) $(LOCAL_BUILT_MODULE): PRIVATE_LDFLAGS := $(LDFLAGS) $(LOCAL_LDFLAGS) $(LOCAL_BUILT_MODULE): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) $(LOCAL_BUILT_MODULE): PRIVATE_OBJS := $(LOCAL_OBJECTS) -$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS) +$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS) $(LOCAL_LIBRARIES) @ mkdir -p $(dir $@) @ echo "Executable: $@" $(hide) $(LD) $(PRIVATE_LDFLAGS) -o $@ $(PRIVATE_LIBRARY) $(PRIVATE_OBJS) $(PRIVATE_LDLIBS) |