main.c
#include <stdio.h>
#include <utility.h>
int main(int argc,char *argv[]){
printf("%d",getNumber());
return 0;
}
utility.h
int getNumber();
utility.c
int getNumber(){
return 2;
}
SimpleMakefile:main.o utility.o gcc -o SimpleMakefile main.o utility.o
main.o:main.c gcc -c main.c
utility.o:utility.c gcc -c utility.c
Makefile(另一种写法)
OBEJCT=main.o utility.o
SimpleMakefile:$(OBEJCT) gcc -o SimpleMakefile $(OBEJCT)
main.mk的droid流程
APP:droid->app_only->$(unbunled_build_modules)
系统:droid->droidcore
->dist_files
main.mk的定制文件(处理属性 零件)
vendorsetup.sh (出现在envsetup.sh)
AndroidProducts.mk
BoardConfig.mk
Android.mk (出现在main.mk)
# 生成droidcore的过程 主要files 与最后一个生成的installed-files.txt记录预安装程序模块
# 负责生成系统的所有可执行程序包 如system.img boot.img recovery.img等
.PHONY: droidcore
droidcore: files systemimage $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $(INSTALLED_USERDATAIMAGE_TARGET) $(INSTALLED_CACHEIMAGE_TARGET) $(INSTALLED_VENDORIMAGE_TARGET) $(INSTALLED_FILES_FILE)
------------------------------files-----------------------------------------
# 重点看files生成过程
# prebuilt 该机制用于早期版本
.PHONY: files
files: prebuilt $(modules_to_install) $(INSTALLED_ANDROID_INFO_TXT_TARGET)
# 描述系统需要安装的模块
# product_FILES各modules安装文件的列表
# tags_to_install 通过标志选择性编译的模块
# get-tagged-modules 判断目标是否有“拒绝”标签,如果有 则不被编译
modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES) $(product_FILES) $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) $(call get-tagged-modules, shell_$(TARGET_SHELL)) $(CUSTOM_MODULES) )
----------------------------------------------------------------------------
------------------------------systemimage-----------------------------------
# 该定义在build/core/Makefile
# BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img 最终生成system.img文件
# $@ 代表target的集合
$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
@echo "Install system fs image: $@"
$(copy-file-to-target)
$(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
systemimage: $(INSTALLED_SYSTEMIMAGE)
----------------------------------------------------------------------------
# 在out目录下生成dist文件夹用于存储多种分发包
# dist_files only for putting your library into the dist directory with a full build.
.PHONY: dist_files
# Copyright 2005 The Android Open Source Project
#
# Android.mk for adb
#
LOCAL_PATH:= $(call my-dir)
# adb host tool
# =========================================================
# CLEAR_VARS清除上百个LOCAL_PATH外的变量
include $(CLEAR_VARS)
# Default to a virtual (sockets) usb interface
# 定义usb驱动
USB_SRCS :=
EXTRA_SRCS :=
ifeq ($(HOST_OS),linux)
USB_SRCS := usb_linux.c
EXTRA_SRCS := get_my_path_linux.c
LOCAL_LDLIBS += -lrt -ldl -lpthread
LOCAL_CFLAGS += -DWORKAROUND_BUG6558362
endif
ifeq ($(HOST_OS),darwin)
USB_SRCS := usb_osx.c
EXTRA_SRCS := get_my_path_darwin.c
LOCAL_LDLIBS += -lpthread -framework CoreFoundation -framework IOKit -framework Carbon
endif
ifeq ($(HOST_OS),freebsd)
USB_SRCS := usb_libusb.c
EXTRA_SRCS := get_my_path_freebsd.c
LOCAL_LDLIBS += -lpthread -lusb
endif
ifeq ($(HOST_OS),windows)
USB_SRCS := usb_windows.c
EXTRA_SRCS := get_my_path_windows.c ../libcutils/list.c
EXTRA_STATIC_LIBS := AdbWinApi
ifneq ($(strip $(USE_CYGWIN)),)
# Pure cygwin case
LOCAL_LDLIBS += -lpthread -lgdi32
LOCAL_C_INCLUDES += /usr/include/w32api/ddk
endif
ifneq ($(strip $(USE_MINGW)),)
# MinGW under Linux case
LOCAL_LDLIBS += -lws2_32 -lgdi32
USE_SYSDEPS_WIN32 := 1
LOCAL_C_INCLUDES += /usr/i586-mingw32msvc/include/ddk
endif
LOCAL_C_INCLUDES += development/host/windows/usb/api/
endif
# 定义本模块所用到的所有源文件 包括上面用的驱动变量
LOCAL_SRC_FILES := adb.c console.c transport.c transport_local.c transport_usb.c commandline.c adb_client.c adb_auth_host.c sockets.c services.c file_sync_client.c $(EXTRA_SRCS) $(USB_SRCS) usb_vendors.c
LOCAL_C_INCLUDES += external/openssl/include
ifneq ($(USE_SYSDEPS_WIN32),)
LOCAL_SRC_FILES += sysdeps_win32.c
else
LOCAL_SRC_FILES += fdevent.c
endif
LOCAL_CFLAGS += -O2 -g -DADB_HOST=1 -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
# 所要生成的模块名称
LOCAL_MODULE := adb
LOCAL_MODULE_TAGS := debug
# 编译需要用到的库
LOCAL_STATIC_LIBRARIES := libzipfile libunz libcrypto_static $(EXTRA_STATIC_LIBS)
ifeq ($(USE_SYSDEPS_WIN32),)
LOCAL_STATIC_LIBRARIES += libcutils
endif
# 表示生成一个Host可执行文件
include $(BUILD_HOST_EXECUTABLE)
$(call dist-for-goals,dist_files sdk,$(LOCAL_BUILT_MODULE))
ifeq ($(HOST_OS),windows)
$(LOCAL_INSTALLED_MODULE): $(HOST_OUT_EXECUTABLES)/AdbWinApi.dll $(HOST_OUT_EXECUTABLES)/AdbWinUsbApi.dll
endif
# adbd device daemon
# =========================================================
# 第二个模块编译开始标志
include $(CLEAR_VARS)
LOCAL_SRC_FILES := adb.c backup_service.c fdevent.c transport.c transport_local.c transport_usb.c adb_auth_client.c sockets.c services.c file_sync_service.c jdwp_service.c framebuffer_service.c remount_service.c usb_linux_client.c log_service.c
LOCAL_CFLAGS := -O2 -g -DADB_HOST=0 -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DALLOW_ADBD_ROOT=1
endif
# 所要生成的模块名称
LOCAL_MODULE := adbd
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
LOCAL_STATIC_LIBRARIES := liblog libcutils libc libmincrypt
# 生成adbd可执行文件
include $(BUILD_EXECUTABLE)
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/qq285016127/article/details/47149247