From 8b23a6c7e1aee255004dd19098d4c2462b61b849 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 19:30:32 -0800 Subject: auto import from //depot/cupcake/@135843 --- android/build/binary.make | 34 ++++++++++ android/build/clear_vars.make | 30 +++++++++ android/build/definitions.make | 109 +++++++++++++++++++++++++++++++++ android/build/getdir.make | 19 ++++++ android/build/host_executable.make | 34 ++++++++++ android/build/host_static_library.make | 35 +++++++++++ android/build/mkdeps.sh | 51 +++++++++++++++ 7 files changed, 312 insertions(+) create mode 100644 android/build/binary.make create mode 100644 android/build/clear_vars.make create mode 100644 android/build/definitions.make create mode 100644 android/build/getdir.make create mode 100644 android/build/host_executable.make create mode 100644 android/build/host_static_library.make create mode 100755 android/build/mkdeps.sh (limited to 'android/build') diff --git a/android/build/binary.make b/android/build/binary.make new file mode 100644 index 0000000..1c75d52 --- /dev/null +++ b/android/build/binary.make @@ -0,0 +1,34 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# definitions shared by host_executable.make and host_static_library.make +# + +# the directory where we're going to place our object files +LOCAL_OBJS_DIR := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE)) +LOCAL_OBJECTS := +LOCAL_CC ?= $(CC) +LOCAL_C_SOURCES := $(filter %.c,$(LOCAL_SRC_FILES)) +LOCAL_OBJC_SOURCES := $(filter %.m,$(LOCAL_SRC_FILES)) + +$(foreach src,$(LOCAL_C_SOURCES), \ + $(eval $(call compile-c-source,$(src))) \ +) + +$(foreach src,$(LOCAL_OBJC_SOURCES), \ + $(eval $(call compile-objc-source,$(src))) \ +) + +CLEAN_OBJS_DIRS += $(LOCAL_OBJS_DIR) diff --git a/android/build/clear_vars.make b/android/build/clear_vars.make new file mode 100644 index 0000000..a9289b0 --- /dev/null +++ b/android/build/clear_vars.make @@ -0,0 +1,30 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# called multiple times to clear variables used to define a given 'module' +# +LOCAL_NO_DEFAULT_COMPILER_FLAGS:= +LOCAL_CC := +LOCAL_CXX := +LOCAL_CFLAGS := +LOCAL_LDFLAGS := +LOCAL_LDLIBS := +LOCAL_SRC_FILES := +LOCAL_MODULE := +LOCAL_MODULE_PATH:= +LOCAL_STATIC_LIBRARIES := +LOCAL_BUILT_MODULE := +LOCAL_PREBUILT_OBJ_FILES := + diff --git a/android/build/definitions.make b/android/build/definitions.make new file mode 100644 index 0000000..cd03f89 --- /dev/null +++ b/android/build/definitions.make @@ -0,0 +1,109 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# shared definitions +ifeq ($(strip $(SHOW)),) +define pretty +@echo $1 +endef +hide := @ +else +define pretty +endef +hide := +endif + +define my-dir +. +endef + +# return the directory containing the intermediate files for a given +# kind of executable +# $1 = type (EXECUTABLES or STATIC_LIBRARIES) +# $2 = module name +# $3 = ignored +# +define intermediates-dir-for +$(OBJS_DIR)/intermediates/$(2) +endef + +# Generate the full path of a given static library +define library-path +$(OBJS_DIR)/$(1).a +endef + +define executable-path +$(OBJS_DIR)/$(1)$(EXE) +endef + +# Compile a C source file +# +define compile-c-source +SRC:=$(1) +OBJ:=$$(LOCAL_OBJS_DIR)/$$(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_PATH)/$$(SRC) +$$(OBJ): PRIVATE_SRC0 := $$(SRC) +$$(OBJ): $$(SRC_PATH)/$$(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) $$(SRC_PATH)/android/build/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d +endef + +# Compile an Objective-C source file +# +define compile-objc-source +SRC:=$(1) +OBJ:=$$(LOCAL_OBJS_DIR)/$$(SRC:%.m=%.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_PATH)/$$(SRC) +$$(OBJ): PRIVATE_SRC0 := $$(SRC) +$$(OBJ): $$(SRC_PATH)/$$(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) $$(SRC_PATH)/android/build/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d +endef + +# for now, we only use prebuilt SDL libraries, so copy them +define copy-prebuilt-lib +_SRC := $(1) +_SRC1 := $$(notdir $$(_SRC)) +_DST := $$(OBJS_DIR)/$$(_SRC1) +LIBRARIES += $$(_DST) +$$(_DST): PRIVATE_DST := $$(_DST) +$$(_DST): PRIVATE_SRC := $$(_SRC) +$$(_DST): $$(_SRC) + @mkdir -p $$(dir $$(PRIVATE_DST)) + @echo "Prebuilt: $$(PRIVATE_DST)" + $(hide) cp -f $$(PRIVATE_SRC) $$(PRIVATE_DST) +endef + +define create-dir +$(1): + mkdir -p $(1) +endef + diff --git a/android/build/getdir.make b/android/build/getdir.make new file mode 100644 index 0000000..a4dadd3 --- /dev/null +++ b/android/build/getdir.make @@ -0,0 +1,19 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# used to return in 'dir' the name of the current operating system +# we really get the value from the configuration script +# +dir := $(HOST_OS) diff --git a/android/build/host_executable.make b/android/build/host_executable.make new file mode 100644 index 0000000..62f4762 --- /dev/null +++ b/android/build/host_executable.make @@ -0,0 +1,34 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# first, call a library containing all object files +LOCAL_BUILT_MODULE := $(call executable-path,$(LOCAL_MODULE)) +LOCAL_CC ?= $(CC) +include $(BUILD_SYSTEM)/binary.make + +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) + @ mkdir -p $(dir $@) + @ echo "Executable: $@" + $(hide) $(LD) $(PRIVATE_LDFLAGS) -o $@ $(PRIVATE_LIBRARY) $(PRIVATE_OBJS) $(PRIVATE_LDLIBS) + +EXECUTABLES += $(LOCAL_BUILT_MODULE) +$(LOCAL_BUILT_MODULE): $(foreach lib,$(LOCAL_STATIC_LIBRARIES),$(call library-path,$(lib))) + diff --git a/android/build/host_static_library.make b/android/build/host_static_library.make new file mode 100644 index 0000000..3de5a99 --- /dev/null +++ b/android/build/host_static_library.make @@ -0,0 +1,35 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# build a host executable, the name of the final executable should be +# put in LOCAL_BUILT_MODULE for use by the caller +# + +#$(info STATIC_LIBRARY SRCS=$(LOCAL_SRC_FILES)) +LOCAL_BUILT_MODULE := $(call library-path,$(LOCAL_MODULE)) +LOCAL_CC ?= $(CC) +include $(BUILD_SYSTEM)/binary.make + +LOCAL_AR ?= $(AR) +ARFLAGS := crs + +$(LOCAL_BUILT_MODULE): PRIVATE_AR := $(LOCAL_AR) +$(LOCAL_BUILT_MODULE): PRIVATE_OBJECTS := $(LOCAL_OBJECTS) +$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS) + @mkdir -p $(dir $@) + @echo "Library: $@" + $(hide) $(PRIVATE_AR) $(ARFLAGS) $@ $(PRIVATE_OBJECTS) + +LIBRARIES += $(LOCAL_BUILT_MODULE) diff --git a/android/build/mkdeps.sh b/android/build/mkdeps.sh new file mode 100755 index 0000000..abecec7 --- /dev/null +++ b/android/build/mkdeps.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This script is used to transform the dependency files generated by GCC +# For example, a typical .d file will have a line like: +# +# source.o: /full/path/to/source.c other.h headers.h +# ... +# +# the script is used to replace 'source.o' to a full path, as in +# +# objs/intermediates/emulator/source.o: /full/path/to/source.c other.h headers.h +# +# parameters +# +# $1: object file (full path) +# $2: source dependency file to modify (erased on success) +# $3: target source dependency file +# + +# quote the object path. we change a single '.' into +# a '\.' since this will be parsed by sed. +# +OBJECT=`echo $1 | sed -e s/\\\\./\\\\\\\\./g` +#echo OBJECT=$OBJECT + +OBJ_NAME=`basename $OBJECT` +#echo OBJ_NAME=$OBJ_NAME + +# we replace $OBJ_NAME with $OBJECT only if $OBJ_NAME starts the line +# that's because some versions of GCC (e.g. 4.2.3) already produce +# a correct dependency line with the full path to the object file. +# In this case, we don't want to touch anything +# +cat $2 | sed -e s%^$OBJ_NAME%$OBJECT%g > $3 && rm -f $2 + + + -- cgit v1.1