Android.mk与Linux Makefile研究心得

一、Android NDK中列出的部分库文件:



|-- crtbegin_dynamic.o

|-- crtbegin_static.o

|-- crtend_android.o



|-- libc.a



|-- libc.so



|-- libdl.so



|-- liblog.so



|-- libm.a



|-- libm.so



|-- libstdc++.a



|-- libstdc++.so



|-- libthread_db.a



|-- libthread_db.so



`-- libz.so









二、libstdc++.a编译过程分析



$ ar x libstdc++.a

libstdc++.a




|-- new.o

|-- one_time_construction.o

|-- pure_virtual.o

`-- typeinfo.o







target thumb C++: libstdc++ <= bionic/libstdc++/src/one_time_construction.cpp

prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++ -I system/core/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I dalvik/libnativehelper/include -I frameworks/base/include -I frameworks/base/opengl/include -I external/skia/include -I out/target/product/generic/obj/include -I bionic/libc/arch-arm/include -I bionic/libc/include -I bionic/libstdc++/include -I bionic/libc/kernel/common -I bionic/libc/kernel/arch-arm -I bionic/libm/include -I bionic/libm/include/arch/arm -I bionic/libthread_db/include -I bionic/libstdc++ -I out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates -c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-rtti -MD -o out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/one_time_construction.o bionic/libstdc++/src/one_time_construction.cpp

target thumb C++: libstdc++ <= bionic/libstdc++/src/new.cpp

prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++ -I system/core/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I dalvik/libnativehelper/include -I frameworks/base/include -I frameworks/base/opengl/include -I external/skia/include -I out/target/product/generic/obj/include -I bionic/libc/arch-arm/include -I bionic/libc/include -I bionic/libstdc++/include -I bionic/libc/kernel/common -I bionic/libc/kernel/arch-arm -I bionic/libm/include -I bionic/libm/include/arch/arm -I bionic/libthread_db/include -I bionic/libstdc++ -I out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates -c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-rtti -MD -o out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/new.o bionic/libstdc++/src/new.cpp

target thumb C++: libstdc++ <= bionic/libstdc++/src/pure_virtual.cpp

prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++ -I system/core/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I dalvik/libnativehelper/include -I frameworks/base/include -I frameworks/base/opengl/include -I external/skia/include -I out/target/product/generic/obj/include -I bionic/libc/arch-arm/include -I bionic/libc/include -I bionic/libstdc++/include -I bionic/libc/kernel/common -I bionic/libc/kernel/arch-arm -I bionic/libm/include -I bionic/libm/include/arch/arm -I bionic/libthread_db/include -I bionic/libstdc++ -I out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates -c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-rtti -MD -o out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/pure_virtual.o bionic/libstdc++/src/pure_virtual.cpp

target thumb C++: libstdc++ <= bionic/libstdc++/src/typeinfo.cpp

prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++ -I system/core/include -I hardware/libhardware/include -I hardware/libhardware_legacy/include -I hardware/ril/include -I dalvik/libnativehelper/include -I frameworks/base/include -I frameworks/base/opengl/include -I external/skia/include -I out/target/product/generic/obj/include -I bionic/libc/arch-arm/include -I bionic/libc/include -I bionic/libstdc++/include -I bionic/libc/kernel/common -I bionic/libc/kernel/arch-arm -I bionic/libm/include -I bionic/libm/include/arch/arm -I bionic/libthread_db/include -I bionic/libstdc++ -I out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates -c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__ -include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -fno-rtti -MD -o out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/typeinfo.o bionic/libstdc++/src/typeinfo.cpp

target StaticLib: libstdc++ (out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/libstdc++.a)

prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-ar crs out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/libstdc++.a out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/one_time_construction.o out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/new.o out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/pure_virtual.o out/target/product/generic/obj/STATIC_LIBRARIES/libstdc++_intermediates/src/typeinfo.o









三、libstdc++.so的编译过程分析




target thumb C++



: libstdc++ <= bionic/libstdc++/src/one_time_construction.cpp





prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++



-I system/core/include



-I hardware/libhardware/include



-I hardware/libhardware_legacy/include



-I hardware/ril/include



-I dalvik/libnativehelper/include



-I frameworks/base/include



-I frameworks/base/opengl/include



-I external/skia/include



-I out/target/product/generic/obj/include



-I bionic/libc/arch-arm/include



-I bionic/libc/include



-I bionic/libstdc++/include



-I bionic/libc/kernel/common



-I bionic/libc/kernel/arch-arm



-I bionic/libm/include



-I bionic/libm/include/arch/arm



-I bionic/libthread_db/include



-I bionic/libstdc++



-I out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates



-c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums



-march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__



-include system/core/include/arch/linux-arm/AndroidConfig.h



-I system/core/include/arch/linux-arm/ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG



-g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop



-frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer



-fno-strict-aliasing -finline-limit=64 -fno-rtti -MD



-o out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/one_time_construction.o bionic/libstdc++/src/one_time_construction.cpp







target thumb C++


: libstdc++ <= bionic/libstdc++/src/new.cpp







prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++



-I system/core/include



-I hardware/libhardware/include



-I hardware/libhardware_legacy/include



-I hardware/ril/include



-I dalvik/libnativehelper/include



-I frameworks/base/include



-I frameworks/base/opengl/include



-I external/skia/include



-I out/target/product/generic/obj/include



-I bionic/libc/arch-arm/include



-I bionic/libc/include



-I bionic/libstdc++/include



-I bionic/libc/kernel/common



-I bionic/libc/kernel/arch-arm



-I bionic/libm/include



-I bionic/libm/include/arch/arm



-I bionic/libthread_db/include



-I bionic/libstdc++



-I out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates



-c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te



-mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__



-include system/core/include/arch/linux-arm/AndroidConfig.h



-I system/core/include/arch/linux-arm/ -mthumb-interwork



-DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG



-g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop



-frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer



-fno-strict-aliasing -finline-limit=64 -fno-rtti -MD



-o out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/new.o bionic/libstdc++/src/new.cpp







target thumb C++


: libstdc++ <= bionic/libstdc++/src/pure_virtual.cpp







prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++



-I system/core/include -I hardware/libhardware/include



-I hardware/libhardware_legacy/include



-I hardware/ril/include



-I dalvik/libnativehelper/include



-I frameworks/base/include



-I frameworks/base/opengl/include



-I external/skia/include



-I out/target/product/generic/obj/include



-I bionic/libc/arch-arm/include



-I bionic/libc/include



-I bionic/libstdc++/include



-I bionic/libc/kernel/common



-I bionic/libc/kernel/arch-arm



-I bionic/libm/include



-I bionic/libm/include/arch/arm



-I bionic/libthread_db/include -I bionic/libstdc++



-I out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates



-c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums



-march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__



-include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork



-DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG



-g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop



-frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer



-fno-strict-aliasing -finline-limit=64 -fno-rtti -MD



-o out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/pure_virtual.o bionic/libstdc++/src/pure_virtual.cpp







target thumb C++


: libstdc++ <= bionic/libstdc++/src/typeinfo.cpp







prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++



-I system/core/include



-I hardware/libhardware/include



-I hardware/libhardware_legacy/include



-I hardware/ril/include



-I dalvik/libnativehelper/include



-I frameworks/base/include



-I frameworks/base/opengl/include



-I external/skia/include



-I out/target/product/generic/obj/include



-I bionic/libc/arch-arm/include



-I bionic/libc/include



-I bionic/libstdc++/include



-I bionic/libc/kernel/common



-I bionic/libc/kernel/arch-arm



-I bionic/libm/include



-I bionic/libm/include/arch/arm



-I bionic/libthread_db/include



-I bionic/libstdc++



-I out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates



-c -fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv5te -mtune=xscale



-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5TE__



-include system/core/include/arch/linux-arm/AndroidConfig.h -I system/core/include/arch/linux-arm/ -mthumb-interwork



-DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Werror=return-type -DSK_RELEASE -DNDEBUG



-g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop



-frename-registers -DNDEBUG -UDEBUG -fvisibility-inlines-hidden -Werror=return-type -mthumb -Os -fomit-frame-pointer



-fno-strict-aliasing -finline-limit=64 -fno-rtti -MD



-o out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/typeinfo.o bionic/libstdc++/src/typeinfo.cpp







target SharedLib


: libstdc++ (out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/LINKED/libstdc++.so)







prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-g++



-nostdlib -Wl,-soname,libstdc++.so -Wl,-T,build/core/armelf.xsc -Wl,--gc-sections -Wl,-shared,-Bsymbolic



-Lout/target/product/generic/obj/lib



out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/one_time_construction.o



out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/new.o



out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/pure_virtual.o



out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/src/typeinfo.o



-Wl,--whole-archive -Wl,--no-whole-archive -lc



-o out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/LINKED/libstdc++.so



-Wl,--no-undefined /home/san/Download/android_src/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/../lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a







target Prelink


: libstdc++ (out/target/product/generic/symbols/system/lib/libstdc++.so)







out/host/linux-x86/bin/apriori






--prelinkmap build/core/prelink-linux-arm.map --locals-only



--quiet out/target/product/generic/obj/SHARED_LIBRARIES/libstdc++_intermediates/LINKED/libstdc++.so



--output out/target/product/generic/symbols/system/lib/libstdc++.so







target Strip



: libstdc++ (out/target/product/generic/obj/lib/libstdc++.so)







out/host/linux-x86/bin/soslim






--strip --shady --quiet out/target/product/generic/symbols/system/lib/libstdc++.so



--outfile out/target/product/generic/obj/lib/libstdc++.so







四、Android.mk文件内容










五、Android.mk改写成linux Makefile


六、编译成静态库和动态库的Makefile的主要区别





























你可能感兴趣的:(linux)