OsmAnd/Osmand-kernel/Makefile.rules

95 lines
4 KiB
Text
Raw Normal View History

2012-05-31 21:01:27 +02:00
# Just check if we have everything defined
ifeq ($(CC_SOURCE_FILES_EXTS),)
2012-06-15 14:34:25 +02:00
CC_SOURCE_FILES_EXTS := c
2012-05-31 21:01:27 +02:00
endif
ifeq ($(CXX_SOURCE_FILES_EXTS),)
2012-06-15 14:34:25 +02:00
CXX_SOURCE_FILES_EXTS := cpp cxx cc
2012-05-31 21:01:27 +02:00
endif
# Target configuration
2012-06-17 12:30:45 +02:00
DEBUG_INFO_FORMAT := gdb3
2012-06-18 20:19:22 +02:00
ifeq ($(TARGET),windows)
2012-06-17 12:30:45 +02:00
DEBUG_INFO_FORMAT := coff
endif
CXXFLAGS_debug := -g$(DEBUG_INFO_FORMAT) -O0
CFLAGS_debug := -g$(DEBUG_INFO_FORMAT) -O0
2012-05-31 21:01:27 +02:00
CXXFLAGS_release := -O2
CFLAGS_release := -O2
2012-06-21 06:24:17 +02:00
2012-06-16 08:14:34 +02:00
OUTPUT_DIR_PREFIX = ../lib/$(TARGET)-$(ARCH)
BUILD_DIR_PREFIX = ../build/$(TARGET)-$(ARCH)
2012-05-31 21:01:27 +02:00
2012-06-04 09:13:33 +02:00
OBJECTS_NAMES = $(foreach sourceFilesExt,$(CC_SOURCE_FILES_EXTS), \
$(patsubst %.$(sourceFilesExt),%.$(sourceFilesExt).cc.o,$(filter %.$(sourceFilesExt),$(LOCAL_SRC_FILES))) \
2012-05-31 21:01:27 +02:00
) $(foreach sourceFilesExt,$(CXX_SOURCE_FILES_EXTS), \
2012-06-04 09:13:33 +02:00
$(patsubst %.$(sourceFilesExt),%.$(sourceFilesExt).cxx.o,$(filter %.$(sourceFilesExt),$(LOCAL_SRC_FILES))) \
2012-05-31 21:01:27 +02:00
)
2012-06-04 09:13:33 +02:00
OBJECTS = $(addprefix obj-$(TARGET)-$(ARCH)/,$(OBJECTS_NAMES))
2012-05-31 21:01:27 +02:00
2012-06-16 08:14:34 +02:00
# Declare phony targets
.PHONY: release debug clean installr installd install-release-$(DYNAMICLIB_EXT) install-debug-$(DYNAMICLIB_EXT) install-release-$(STATICLIB_EXT) install-debug-$(STATICLIB_EXT)
2012-05-31 21:01:27 +02:00
# Default target
.DEFAULT: installr
# Precious targets
.PRECIOUS: build-release/$(LIBNAME).$(LIBTYPE) build-debug/$(LIBNAME).$(LIBTYPE) $(addprefix build-release/,$(OBJECTS)) $(addprefix build-debug/,$(OBJECTS))
# Route build targets properly
2012-06-16 10:15:06 +02:00
installr: $(OUTPUT_DIR_PREFIX)-release/$(LIBNAME).$(LIBTYPE)
installd: $(OUTPUT_DIR_PREFIX)-debug/$(LIBNAME).$(LIBTYPE)
2012-06-16 08:14:34 +02:00
release: $(BUILD_DIR_PREFIX)-release/$(LIBNAME).$(LIBTYPE)
debug: $(BUILD_DIR_PREFIX)-debug/$(LIBNAME).$(LIBTYPE)
2012-05-31 21:01:27 +02:00
# Clean removes all objects
clean:
2012-06-21 06:24:17 +02:00
$(RM) -r build-release/obj-$(TARGET)-$(ARCH)
$(RM) -r build-debug/obj-$(TARGET)-$(ARCH)
2012-06-04 23:49:39 +02:00
$(RM) -r build-release/$(TARGET)-$(ARCH)
$(RM) -r build-debug/$(TARGET)-$(ARCH)
2012-06-16 08:14:34 +02:00
$(RM) -r $(BUILD_DIR_PREFIX)-release
$(RM) -r $(BUILD_DIR_PREFIX)-debug
$(RM) $(OUTPUT_DIR_PREFIX)-release/$(LIBNAME).$(LIBTYPE)
$(RM) $(OUTPUT_DIR_PREFIX)-debug/$(LIBNAME).$(LIBTYPE)
2012-05-31 21:01:27 +02:00
2012-06-16 08:14:34 +02:00
# This target copies final output file to output directory
$(OUTPUT_DIR_PREFIX)-%/$(LIBNAME).$(DYNAMICLIB_EXT): $(BUILD_DIR_PREFIX)-%/$(LIBNAME).$(LIBTYPE)
@mkdir -p $(OUTPUT_DIR_PREFIX)-$*
cp $(BUILD_DIR_PREFIX)-$*/$(LIBNAME).$(LIBTYPE) $(OUTPUT_DIR_PREFIX)-$*/$(LIBNAME).$(LIBTYPE)
2012-06-16 10:15:06 +02:00
$(OUTPUT_DIR_PREFIX)-%/$(LIBNAME).$(STATICLIB_EXT): $(BUILD_DIR_PREFIX)-%/$(LIBNAME).$(LIBTYPE)
@echo $@ does not need install
2012-05-31 21:01:27 +02:00
# Builds source files using CC compiler
build-release/obj-$(TARGET)-$(ARCH)/%.cc.o : % $(LOCAL_C_INCLUDES)
@mkdir -p `dirname $@`
2012-06-04 09:13:33 +02:00
$(CC) -o $@ -c $< $(CFLAGS_release) $(CFLAGS) $(addprefix -I, $(LOCAL_C_INCLUDES)) $(LOCAL_CFLAGS) $(GLOBAL_INCLUDES)
2012-05-31 21:01:27 +02:00
build-debug/obj-$(TARGET)-$(ARCH)/%.cc.o : % $(LOCAL_C_INCLUDES)
@mkdir -p `dirname $@`
2012-06-04 09:13:33 +02:00
$(CC) -o $@ -c $< $(CFLAGS_debug) $(CFLAGS) $(addprefix -I, $(LOCAL_C_INCLUDES)) $(LOCAL_CFLAGS) $(GLOBAL_INCLUDES)
2012-05-31 21:01:27 +02:00
# Builds source files using CXX compiler
build-release/obj-$(TARGET)-$(ARCH)/%.cxx.o : % $(LOCAL_C_INCLUDES)
@mkdir -p `dirname $@`
2012-06-15 14:34:25 +02:00
$(CXX) -o $@ -c $< $(CXXFLAGS_release) $(CXXFLAGS) $(addprefix -I, $(LOCAL_C_INCLUDES)) $(LOCAL_CFLAGS) $(GLOBAL_INCLUDES)
2012-05-31 21:01:27 +02:00
build-debug/obj-$(TARGET)-$(ARCH)/%.cxx.o : % $(LOCAL_C_INCLUDES)
@mkdir -p `dirname $@`
2012-06-15 14:34:25 +02:00
$(CXX) -o $@ -c $< $(CXXFLAGS_debug) $(CXXFLAGS) $(addprefix -I, $(LOCAL_C_INCLUDES)) $(LOCAL_CFLAGS) $(GLOBAL_INCLUDES)
2012-05-31 21:01:27 +02:00
# This target assembles static library
.SECONDEXPANSION:
2012-06-04 09:13:33 +02:00
build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(STATICLIB_EXT): $$(addprefix build-%/,$(OBJECTS))
2012-05-31 21:01:27 +02:00
@mkdir -p `dirname $@`
2012-06-04 23:49:39 +02:00
$(AR) rs $@ $(addprefix build-$*/,$(OBJECTS))
2012-06-15 14:34:25 +02:00
2012-05-31 21:01:27 +02:00
# This target assembles dynamic library
.SECONDEXPANSION:
2012-06-04 09:13:33 +02:00
build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(DYNAMICLIB_EXT): $$(addprefix build-%/,$(OBJECTS))
2012-05-31 21:01:27 +02:00
@mkdir -p `dirname $@`
2012-06-21 06:24:17 +02:00
$(CXX) $(DYNAMICLIB_FLAGS) -o $@ $(addprefix build-$*/,$(OBJECTS)) $(LDFLAGS) -L$(BUILD_DIR_PREFIX)-$* $(LDLIBS)
2012-06-16 08:14:34 +02:00
# This is for copying binary files to build directory
$(BUILD_DIR_PREFIX)-%/$(LIBNAME).$(LIBTYPE): build-%/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE)
@mkdir -p $(BUILD_DIR_PREFIX)-$*
cp build-$*/$(TARGET)-$(ARCH)/$(LIBNAME).$(LIBTYPE) $(BUILD_DIR_PREFIX)-$*/$(LIBNAME).$(LIBTYPE)