library Makefiles

libpng library Makefile

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LS_C=$(subst $(1)/,,$(wildcard $(1)/*.c))

LOCAL_MODULE := png
LOCAL_SRC_FILES := \
    $(filter-out example.c pngtest.c,$(call LS_C,$(LOCAL_PATH)))
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lz

include $(BUILD_STATIC_LIBRARY)

 Here, the libpng library Makefile selects all the C files with the help of a custom macro LS_C. This macro is invoked from the LOCAL_SRC_FILES directive. We exclude example.c and pngtest.c, which are just test files, using the standard "Make" function filter-out().

All the prerequisites include files that are made available to client modules with the directive LOCAL_EXPORT_C_INCLUDES, which refers to the source directory LOCAL_PATH here. The prerequisite libraries like libzip (op on -lz) are also provided to the client modules using the LOCAL_EXPORT_LDLIBS directive this time. All directives containing the _EXPORT_ term exports directives that are appended to the client module's own directives. 

[注] 在 Properties->C/C++ General->Paths and Symbols->Add $ANDROID_NDK/sources/libpng/ 时需加上 "is a workspace path" 选择框,否则会出现诸如 Function png_read_image can not resoloved 这样的 sematic error。

Box2D Makefile

 1 LOCAL_PATH:= $(call my-dir)
 2 
 3 LS_CPP=$(subst $(1)/,,$(wildcard $(1)/$(2)/*.cpp))
 4 BOX2D_CPP:= $(call LS_CPP,$(LOCAL_PATH),Box2D/Collision) \
 5             $(call LS_CPP,$(LOCAL_PATH),Box2D/Collision/Shapes) \
 6             $(call LS_CPP,$(LOCAL_PATH),Box2D/Common) \
 7             $(call LS_CPP,$(LOCAL_PATH),Box2D/Dynamics) \
 8             $(call LS_CPP,$(LOCAL_PATH),Box2D/Dynamics/Contacts) \
 9             $(call LS_CPP,$(LOCAL_PATH),Box2D/Dynamics/Joints) \
10             $(call LS_CPP,$(LOCAL_PATH),Box2D/Rope)
11 
12 
13 
14 include $(CLEAR_VARS)
15 
16 LOCAL_MODULE := box2d_static
17 LOCAL_SRC_FILES := $(BOX2D_CPP)
18 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
19 LOCAL_C_INCLUDES := $(LOCAL_EXPORT_C_INCLUDES)
20 
21 include $(BUILD_STATIC_LIBRARY)
22 
23 
24 
25 include $(CLEAR_VARS)
26 
27 LOCAL_MODULE := box2d_shared
28 LOCAL_SRC_FILES := $(BOX2D_CPP)
29 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
30 LOCAL_C_INCLUDES := $(LOCAL_EXPORT_C_INCLUDES)
31 
32 include $(BUILD_SHARED_LIBRARY)

 [注] 编译 Box2D 前需在 Box2D/Common/b2GrowableStack.h 文件中加上 #include <string.h>

Boost  修正后的 user-config.jam

  1 # Copyright 2003, 2005 Douglas Gregor
  2 # Copyright 2004 John Maddock
  3 # Copyright 2002, 2003, 2004, 2007 Vladimir Prus
  4 # Distributed under the Boost Software License, Version 1.0.
  5 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  6 
  7 #   This file is used to configure your Boost.Build installation. You can modify
  8 # this file in place, or you can place it in a permanent location so that it
  9 # does not get overwritten should you get a new version of Boost.Build. See:
 10 #
 11 #   http://www.boost.org/boost-build2/doc/html/bbv2/overview/configuration.html
 12 #
 13 # for documentation about possible permanent locations.
 14 
 15 #   This file specifies which toolsets (C++ compilers), libraries, and other
 16 # tools are available. Often, you should be able to just uncomment existing
 17 # example lines and adjust them to taste. The complete list of supported tools,
 18 # and configuration instructions can be found at:
 19 #
 20 #   http://boost.org/boost-build2/doc/html/bbv2/reference/tools.html
 21 #
 22 
 23 #   This file uses Jam language syntax to describe available tools. Mostly,
 24 # there are 'using' lines, that contain the name of the used tools, and
 25 # parameters to pass to those tools -- where paremeters are separated by
 26 # semicolons. Important syntax notes:
 27 #
 28 #   - Both ':' and ';' must be separated from other tokens by whitespace
 29 #   - The '\' symbol is a quote character, so when specifying Windows paths you
 30 #     should use '/' or '\\' instead.
 31 #
 32 # More details about the syntax can be found at:
 33 #
 34 #   http://boost.org/boost-build2/doc/html/bbv2/advanced.html#bbv2.advanced.jam_language
 35 #
 36 
 37 # ------------------
 38 # GCC configuration.
 39 # ------------------
 40 
 41 # Configure gcc (default version).
 42 # using gcc ;
 43 
 44 # Configure specific gcc version, giving alternative name to use.
 45 # using gcc : 3.2 : g++-3.2 ;
 46 
 47 
 48 # -------------------
 49 # MSVC configuration.
 50 # -------------------
 51 
 52 # Configure msvc (default version, searched for in standard locations and PATH).
 53 # using msvc ;
 54 
 55 # Configure specific msvc version (searched for in standard locations and PATH).
 56 # using msvc : 8.0 ;
 57 
 58 
 59 # ----------------------
 60 # Borland configuration.
 61 # ----------------------
 62 # using borland ;
 63 
 64 
 65 # ----------------------
 66 # STLPort configuration.
 67 # ----------------------
 68 
 69 #   Configure specifying location of STLPort headers. Libraries must be either
 70 # not needed or available to the compiler by default.
 71 # using stlport : : /usr/include/stlport ;
 72 
 73 # Configure specifying location of both headers and libraries explicitly.
 74 # using stlport : : /usr/include/stlport /usr/lib ;
 75 
 76 
 77 # -----------------
 78 # QT configuration.
 79 # -----------------
 80 
 81 # Configure assuming QTDIR gives the installation prefix.
 82 # using qt ;
 83 
 84 # Configure with an explicit installation prefix.
 85 # using qt : /usr/opt/qt ;
 86 
 87 # ---------------------
 88 # Python configuration.
 89 # ---------------------
 90 
 91 # Configure specific Python version.
 92 # using python : 3.1 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;
 93 
 94 import feature ;
 95 import os ;
 96 
 97 if [ os.name ] = CYGWIN || [ os.name ] = NT {
 98     androidPlatform = windows ;
 99 } else if [ os.name ] = LINUX {
100     if [ os.platform ] = X86_64 {
101         androidPlatform = linux-x86_64 ;
102     } else {
103         androidPlatform = linux-x86 ;
104     }
105 } else if [ os.name ] = MACOSX {
106     androidPlatform = darwin-x86_64 ;
107 }
108 
109 modules.poke : NO_BZIP2 : 1 ;
110 android_ndk = [ os.environ ANDROID_NDK ] ;
111 
112 # Compilation: ./b2 --without-python toolset=gcc-android4.9_armeabi link=static runtime-link=static target-os=linux architecture=arm --stagedir=android-armeabi threading=multi
113 using gcc : android4.9_armeabi :
114     $(android_ndk)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ :
115     <archiver>$(android_ndk)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar
116     <ranlib>$(android_ndk)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib
117     <compileflags>--sysroot=$(android_ndk)/platforms/android-16/arch-arm
118     <compileflags>-I$(android_ndk)/sources/cxx-stl/gnu-libstdc++/4.9/include
119     <compileflags>-I$(android_ndk)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include
120     <compileflags>-fexceptions
121     <compileflags>-frtti
122     <compileflags>-march=armv5te
123     <compileflags>-mthumb
124     <compileflags>-mtune=xscale
125     <compileflags>-msoft-float
126     <compileflags>-fno-strict-aliasing
127     <compileflags>-finline-limit=64
128     <compileflags>-D__arm__
129     <compileflags>-D__ARM_ARCH_5__
130     <compileflags>-D__ARM_ARCH_5T__
131     <compileflags>-D__ARM_ARCH_5E__
132     <compileflags>-D__ARM_ARCH_5TE__
133     <compileflags>-MMD
134     <compileflags>-MP
135     <compileflags>-MF
136     <compileflags>-fpic
137     <compileflags>-ffunction-sections
138     <compileflags>-funwind-tables
139     <compileflags>-fstack-protector
140     <compileflags>-no-canonical-prefixes
141     <compileflags>-Os
142     <compileflags>-fomit-frame-pointer
143     <compileflags>-fno-omit-frame-pointer
144     <compileflags>-DANDROID
145     <compileflags>-D__ANDROID__
146     <compileflags>-DNDEBUG
147     <compileflags>-D__GLIBC__
148     <compileflags>-DBOOST_ASIO_DISABLE_STD_ATOMIC
149     <compileflags>-D_GLIBCXX__PTHREADS
150     <compileflags>-Wa,--noexecstack
151     <compileflags>-Wformat
152     <compileflags>-Werror=format-security
153     <compileflags>-lstdc++
154     <compileflags>-Wno-long-long
155         ;
156 
157 # Compilation: ./b2 --without-python toolset=gcc-android4.6_armeabiv7a link=static runtime-link=static target-os=linux architecture=arm --stagedir=android-armeabi-v7a threading=multi
158 using gcc : android4.6_armeabiv7a :
159     $(android_ndk)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-g++ :
160     <archiver>$(android_ndk)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ar
161     <ranlib>$(android_ndk)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(androidPlatform)/bin/arm-linux-androideabi-ranlib
162     <compileflags>--sysroot=$(android_ndk)/platforms/android-16/arch-arm
163     <compileflags>-I$(android_ndk)/sources/cxx-stl/gnu-libstdc++/4.9/include
164     <compileflags>-I$(android_ndk)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include
165     <compileflags>-fexceptions
166     <compileflags>-frtti
167     <compileflags>-march=armv7-a
168     <compileflags>-marm
169     <compileflags>-mthumb
170     <compileflags>-mfpu=vfpv3-d16
171     <compileflags>-mfloat-abi=softfp
172     <compileflags>-fno-strict-aliasing
173     <compileflags>-finline-limit=64
174     <compileflags>-D__arm__
175     <compileflags>-D__ARM_ARCH_7__
176     <compileflags>-D__ARM_ARCH_7A__
177     <compileflags>-D__ARM_ARCH_7R__
178     <compileflags>-D__ARM_ARCH_7M__
179     <compileflags>-D__ARM_ARCH_7EM__
180     <compileflags>-D__ARM_ARCH_7S__
181     <compileflags>-MMD
182     <compileflags>-MP
183     <compileflags>-MF
184     <compileflags>-fpic
185     <compileflags>-ffunction-sections
186     <compileflags>-funwind-tables
187     <compileflags>-fstack-protector
188     <compileflags>-no-canonical-prefixes
189     <compileflags>-Os
190     <compileflags>-fomit-frame-pointer
191     <compileflags>-fno-omit-frame-pointer
192     <compileflags>-DANDROID
193     <compileflags>-D__ANDROID__
194     <compileflags>-DNDEBUG
195     <compileflags>-D__GLIBC__
196     <compileflags>-DBOOST_ASIO_DISABLE_STD_ATOMIC
197     <compileflags>-D_GLIBCXX__PTHREADS
198     <compileflags>-Wa,--noexecstack
199     <compileflags>-Wformat
200     <compileflags>-Werror=format-security
201     <compileflags>-lstdc++
202     <compileflags>-Wno-long-long
203         ;
204 
205 # Compilation: ./b2 --without-python toolset=gcc-android4.9_x86 link=static runtime-link=static target-os=linux architecture=x86 --stagedir=android-x86 threading=multi
206 using gcc : android4.9_x86 :
207     $(android_ndk)/toolchains/x86-4.9/prebuilt/$(androidPlatform)/bin/i686-linux-android-g++ :
208     <archiver>$(android_ndk)/toolchains/x86-4.9/prebuilt/$(androidPlatform)/bin/i686-linux-android-ar
209     <ranlib>$(android_ndk)/toolchains/x86-4.9/prebuilt/$(androidPlatform)/bin/i686-linux-android-ranlib
210     <compileflags>--sysroot=$(android_ndk)/platforms/android-16/arch-x86
211     <compileflags>-I$(android_ndk)/sources/cxx-stl/gnu-libstdc++/4.9/include
212     <compileflags>-I$(android_ndk)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include
213     <compileflags>-fexceptions
214     <compileflags>-frtti
215     <compileflags>-fstrict-aliasing
216     <compileflags>-funswitch-loops
217     <compileflags>-finline-limit=300
218     <compileflags>-MMD
219     <compileflags>-MP
220     <compileflags>-MF
221     <compileflags>-ffunction-sections
222     <compileflags>-funwind-tables
223     <compileflags>-fstack-protector
224     <compileflags>-no-canonical-prefixes
225     <compileflags>-Os
226     <compileflags>-fomit-frame-pointer
227     <compileflags>-fno-omit-frame-pointer
228     <compileflags>-DANDROID
229     <compileflags>-D__ANDROID__
230     <compileflags>-DNDEBUG
231     <compileflags>-D__GLIBC__
232     <compileflags>-DBOOST_ASIO_DISABLE_STD_ATOMIC
233     <compileflags>-D_GLIBCXX__PTHREADS
234     <compileflags>-Wa,--noexecstack
235     <compileflags>-Wformat
236     <compileflags>-Werror=format-security
237     <compileflags>-lstdc++
238     <compileflags>-Wno-long-long
239         ;

 

posted @ 2016-04-14 13:01  壬子木  阅读(262)  评论(0编辑  收藏  举报