Android.mk 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # Google Android makefile for curl and libcurl
  2. #
  3. # Place the curl source (including this makefile) into external/curl/ in the
  4. # Android source tree. Then build them with 'make curl' or just 'make libcurl'
  5. # from the Android root. Tested with Android 1.5 and 2.1
  6. #
  7. # Note: you must first create a curl_config.h file by running configure in the
  8. # Android environment. The only way I've found to do this is tricky. Perform a
  9. # normal Android build with libcurl in the source tree, providing the target
  10. # "showcommands" to make. The build will eventually fail (because curl_config.h
  11. # doesn't exist yet), but the compiler commands used to build curl will be
  12. # shown. Now, from the external/curl/ directory, run curl's normal configure
  13. # command with flags that match what Android itself uses. This will mean
  14. # putting the compiler directory into the PATH, putting the -I, -isystem and
  15. # -D options into CPPFLAGS, putting the -W, -m, -f, -O and -nostdlib options
  16. # into CFLAGS, and putting the -Wl, -L and -l options into LIBS, along with the
  17. # path to the files libgcc.a, crtbegin_dynamic.o, and ccrtend_android.o.
  18. # Remember that the paths must be absolute since you will not be running
  19. # configure from the same directory as the Android make. The normal
  20. # cross-compiler options must also be set. Note that the -c, -o, -MD and
  21. # similar flags must not be set.
  22. #
  23. # To see all the LIBS options, you'll need to do the "showcommands" trick on an
  24. # executable that's already buildable and watch what flags Android uses to link
  25. # it (dhcpcd is a good choice to watch). You'll also want to add -L options to
  26. # LIBS that point to the out/.../obj/lib/ and out/.../obj/system/lib/
  27. # directories so that additional libraries can be found and used by curl.
  28. #
  29. # The end result will be a configure command that looks something like this
  30. # (the environment variable A is set to the Android root path which makes the
  31. # command shorter):
  32. #
  33. # A=`realpath ../..` && \
  34. # PATH="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/bin:$PATH" \
  35. # ./configure --host=arm-linux CC=arm-eabi-gcc \
  36. # CPPFLAGS="-I $A/system/core/include ..." \
  37. # CFLAGS="-nostdlib -fno-exceptions -Wno-multichar ..." \
  38. # LIBS="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/lib/gcc/arm-eabi/X\
  39. # /interwork/libgcc.a ..."
  40. #
  41. # Finally, copy the file COPYING to NOTICE so that the curl license gets put
  42. # into the right place (but see the note about this below).
  43. #
  44. # Dan Fandrich
  45. # August 2010
  46. LOCAL_PATH:= $(call my-dir)
  47. common_CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wno-system-headers -DHAVE_CONFIG_H
  48. #########################
  49. # Build the libcurl library
  50. include $(CLEAR_VARS)
  51. include $(LOCAL_PATH)/lib/Makefile.inc
  52. CURL_HEADERS := \
  53. curlbuild.h \
  54. curl.h \
  55. curlrules.h \
  56. curlver.h \
  57. easy.h \
  58. mprintf.h \
  59. multi.h \
  60. stdcheaders.h \
  61. typecheck-gcc.h
  62. LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES))
  63. LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/
  64. LOCAL_CFLAGS += $(common_CFLAGS)
  65. LOCAL_COPY_HEADERS_TO := libcurl/curl
  66. LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS))
  67. LOCAL_MODULE:= libcurl
  68. LOCAL_MODULE_TAGS := optional
  69. # Copy the licence to a place where Android will find it.
  70. # Actually, this doesn't quite work because the build system searches
  71. # for NOTICE files before it gets to this point, so it will only be seen
  72. # on subsequent builds.
  73. ALL_PREBUILT += $(LOCAL_PATH)/NOTICE
  74. $(LOCAL_PATH)/NOTICE: $(LOCAL_PATH)/COPYING | $(ACP)
  75. $(copy-file-to-target)
  76. include $(BUILD_STATIC_LIBRARY)
  77. #########################
  78. # Build the curl binary
  79. include $(CLEAR_VARS)
  80. include $(LOCAL_PATH)/src/Makefile.inc
  81. LOCAL_SRC_FILES := $(addprefix src/,$(CURL_CFILES))
  82. LOCAL_MODULE := curl
  83. LOCAL_MODULE_TAGS := optional
  84. LOCAL_STATIC_LIBRARIES := libcurl
  85. LOCAL_SYSTEM_SHARED_LIBRARIES := libc
  86. LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/lib
  87. # This may also need to include $(CURLX_ONES) in order to correctly link
  88. # if libcurl is changed to be built as a dynamic library
  89. LOCAL_CFLAGS += $(common_CFLAGS)
  90. include $(BUILD_EXECUTABLE)