diff -crB ./build/core/build-binary.mk ../android-ndk-r7-patched/./build/core/build-binary.mk *** ./build/core/build-binary.mk 2011-10-27 06:36:46.000000000 -0500 --- ../android-ndk-r7-patched/./build/core/build-binary.mk 2012-02-10 14:31:19.973529645 -0600 *************** *** 193,199 **** # 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_patterns := $(foreach _ext,$(all_source_extensions),%$(_ext)) all_cpp_patterns := $(foreach _ext,$(LOCAL_CPP_EXTENSION),%$(_ext)) --- 193,199 ---- # 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) .f .f90 all_source_patterns := $(foreach _ext,$(all_source_extensions),%$(_ext)) all_cpp_patterns := $(foreach _ext,$(LOCAL_CPP_EXTENSION),%$(_ext)) *************** *** 242,247 **** --- 242,252 ---- $(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 -crB ./build/core/default-build-commands.mk ../android-ndk-r7-patched/./build/core/default-build-commands.mk *** ./build/core/default-build-commands.mk 2011-10-24 09:37:26.000000000 -0500 --- ../android-ndk-r7-patched/./build/core/default-build-commands.mk 2012-02-10 14:31:44.801757982 -0600 *************** *** 88,93 **** --- 88,96 ---- 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 -crB ./build/core/definitions.mk ../android-ndk-r7-patched/./build/core/definitions.mk *** ./build/core/definitions.mk 2011-10-27 06:36:46.000000000 -0500 --- ../android-ndk-r7-patched/./build/core/definitions.mk 2012-02-10 14:31:55.278923983 -0600 *************** *** 1230,1235 **** --- 1230,1323 ---- 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,