diff -rupN android-ndk-r7b-clean/build/core/build-binary.mk android-ndk-r7b/build/core/build-binary.mk --- android-ndk-r7b-clean/build/core/build-binary.mk 2012-02-18 10:35:29.445524526 -0600 +++ android-ndk-r7b/build/core/build-binary.mk 2012-02-18 10:36:19.244704012 -0600 @@ -195,7 +195,7 @@ LOCAL_DEPENDENCY_DIRS := # all_source_patterns contains the list of filename patterns that correspond # to source files recognized by our build system -all_source_extensions := .c .s .S $(LOCAL_CPP_EXTENSION) +all_source_extensions := .c .s .S $(LOCAL_CPP_EXTENSION) .f .f90 all_source_patterns := $(foreach _ext,$(all_source_extensions),%$(_ext)) all_cpp_patterns := $(foreach _ext,$(LOCAL_CPP_EXTENSION),%$(_ext)) @@ -244,6 +244,11 @@ $(foreach src,$(filter $(all_cpp_pattern $(call compile-cpp-source,$(src),$(call get-object-name,$(src)))\ ) +# handle free-form Fortran (.f90) +$(foreach src,$(filter %.f90,$(LOCAL_SRC_FILES)), $(call compile-f90-source,$(src))) + +# handle fixed form Fortran (.f) +$(foreach src,$(filter %.f,$(LOCAL_SRC_FILES)), $(call compile-fc-source,$(src))) # # The compile-xxx-source calls updated LOCAL_OBJECTS and LOCAL_DEPENDENCY_DIRS # diff -rupN android-ndk-r7b-clean/build/core/default-build-commands.mk android-ndk-r7b/build/core/default-build-commands.mk --- android-ndk-r7b-clean/build/core/default-build-commands.mk 2012-02-18 10:35:29.445524526 -0600 +++ android-ndk-r7b/build/core/default-build-commands.mk 2012-02-18 10:36:19.244704012 -0600 @@ -88,6 +88,9 @@ TARGET_CFLAGS = TARGET_CXX = $(TOOLCHAIN_PREFIX)g++ TARGET_CXXFLAGS = $(TARGET_CFLAGS) -fno-exceptions -fno-rtti +TARGET_FC = $(TOOLCHAIN_PREFIX)gfortran +TARGET_FFLAGS = + TARGET_LD = $(TOOLCHAIN_PREFIX)ld TARGET_LDFLAGS := diff -rupN android-ndk-r7b-clean/build/core/definitions.mk android-ndk-r7b/build/core/definitions.mk --- android-ndk-r7b-clean/build/core/definitions.mk 2012-02-18 10:35:29.445524526 -0600 +++ android-ndk-r7b/build/core/definitions.mk 2012-02-18 10:36:19.246872902 -0600 @@ -1234,6 +1234,94 @@ else endif endef +# slightly modified version for Fortran source files +define ev-build-fc-file +$$(_OBJ): PRIVATE_SRC := $$(_SRC) +$$(_OBJ): PRIVATE_OBJ := $$(_OBJ) +$$(_OBJ): PRIVATE_DEPS := $$(call host-path,$$(_OBJ).d) +$$(_OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) +$$(_OBJ): PRIVATE_TEXT := "$$(_TEXT)" +$$(_OBJ): PRIVATE_CC := $$(_CC) +$$(_OBJ): PRIVATE_CFLAGS := $$(_FLAGS) +$$(_OBJ): $$(_SRC) $$(LOCAL_MAKEFILE) $$(NDK_APP_APPLICATION_MK) + @mkdir -p $$(dir $$(PRIVATE_OBJ)) + @echo "$$(PRIVATE_TEXT) : $$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_SRC))" + $(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) $$(call host-path,$$(PRIVATE_SRC)) -o $$(call host-path,$$(PRIVATE_OBJ)) +endef + +# This assumes the same things than ev-build-fc-file, but will handle +# the definition of LOCAL_FILTER_ASM as well. +define ev-build-fc-source-file +LOCAL_DEPENDENCY_DIRS += $$(dir $$(_OBJ)) +ifndef LOCAL_FILTER_ASM + # Trivial case: Directly generate an object file + $$(eval $$(call ev-build-fc-file)) +else + # This is where things get hairy, we first transform + # the source into an assembler file, send it to the + # filter, then generate a final object file from it. + # + + # First, remember the original settings and compute + # the location of our temporary files. + # + _ORG_SRC := $$(_SRC) + _ORG_OBJ := $$(_OBJ) + _ORG_FLAGS := $$(_FLAGS) + _ORG_TEXT := $$(_TEXT) + + _OBJ_ASM_ORIGINAL := $$(patsubst %.o,%.s,$$(_ORG_OBJ)) + _OBJ_ASM_FILTERED := $$(patsubst %.o,%.filtered.s,$$(_ORG_OBJ)) + + # If the source file is a plain assembler file, we're going to + # use it directly in our filter. + ifneq (,$$(filter %.s,$$(_SRC))) + _OBJ_ASM_ORIGINAL := $$(_SRC) + endif + + #$$(info SRC=$$(_SRC) OBJ=$$(_OBJ) OBJ_ORIGINAL=$$(_OBJ_ASM_ORIGINAL) OBJ_FILTERED=$$(_OBJ_ASM_FILTERED)) + + # We need to transform the source into an assembly file, instead of + # an object. The proper way to do that depends on the file extension. + # + # For C and C++ source files, simply replace the -c by an -S in the + # compilation command (this forces the compiler to generate an + # assembly file). + # + # For assembler templates (which end in .S), replace the -c with -E + # to send it to the preprocessor instead. + # + # Don't do anything for plain assembly files (which end in .s) + # + ifeq (,$$(filter %.s,$$(_SRC))) + _OBJ := $$(_OBJ_ASM_ORIGINAL) + ifneq (,$$(filter %.S,$$(_SRC))) + _FLAGS := $$(patsubst -c,-E,$$(_ORG_FLAGS)) + else + _FLAGS := $$(patsubst -c,-S,$$(_ORG_FLAGS)) + endif + $$(eval $$(call ev-build-fc-file)) + endif + + # Next, process the assembly file with the filter + $$(_OBJ_ASM_FILTERED): PRIVATE_SRC := $$(_OBJ_ASM_ORIGINAL) + $$(_OBJ_ASM_FILTERED): PRIVATE_DST := $$(_OBJ_ASM_FILTERED) + $$(_OBJ_ASM_FILTERED): PRIVATE_FILTER := $$(LOCAL_FILTER_ASM) + $$(_OBJ_ASM_FILTERED): PRIVATE_MODULE := $$(LOCAL_MODULE) + $$(_OBJ_ASM_FILTERED): $$(_OBJ_ASM_ORIGINAL) + @echo "AsmFilter : $$(PRIVATE_MODULE) <= $$(notdir $$(PRIVATE_SRC))" + $(hide) $$(PRIVATE_FILTER) $$(PRIVATE_SRC) $$(PRIVATE_DST) + + # Then, generate the final object, we need to keep assembler-specific + # flags which look like -Wa,