Android.mk 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. ###########################################################################
  22. # Google Android makefile for curl and libcurl
  23. #
  24. # This file can be used when building curl using the full Android source
  25. # release or the NDK. Most users do not want or need to do this; please
  26. # instead read the Android section in docs/INSTALL for alternate
  27. # methods.
  28. #
  29. # Place the curl source (including this makefile) into external/curl/ in the
  30. # Android source tree. Then build them with 'make curl' or just 'make libcurl'
  31. # from the Android root. Tested with Android versions 1.5, 2.1-2.3
  32. #
  33. # Note: you must first create a curl_config.h file by running configure in the
  34. # Android environment. The only way I've found to do this is tricky. Perform a
  35. # normal Android build with libcurl in the source tree, providing the target
  36. # "showcommands" to make. The build will eventually fail (because curl_config.h
  37. # doesn't exist yet), but the compiler commands used to build curl will be
  38. # shown. Now, from the external/curl/ directory, run curl's normal configure
  39. # command with flags that match what Android itself uses. This will mean
  40. # putting the compiler directory into the PATH, putting the -I, -isystem and
  41. # -D options into CPPFLAGS, putting the -W, -m, -f, -O and -nostdlib options
  42. # into CFLAGS, and putting the -Wl, -L and -l options into LIBS, along with the
  43. # path to the files libgcc.a, crtbegin_dynamic.o, and ccrtend_android.o.
  44. # Remember that the paths must be absolute since you will not be running
  45. # configure from the same directory as the Android make. The normal
  46. # cross-compiler options must also be set. Note that the -c, -o, -MD and
  47. # similar flags must not be set.
  48. #
  49. # To see all the LIBS options, you'll need to do the "showcommands" trick on an
  50. # executable that's already buildable and watch what flags Android uses to link
  51. # it (dhcpcd is a good choice to watch). You'll also want to add -L options to
  52. # LIBS that point to the out/.../obj/lib/ and out/.../obj/system/lib/
  53. # directories so that additional libraries can be found and used by curl.
  54. #
  55. # The end result will be a configure command that looks something like this
  56. # (the environment variable A is set to the Android root path which makes the
  57. # command shorter):
  58. #
  59. # A=`realpath ../..` && \
  60. # PATH="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/bin:$PATH" \
  61. # ./configure --host=arm-linux CC=arm-eabi-gcc \
  62. # CPPFLAGS="-I $A/system/core/include ..." \
  63. # CFLAGS="-nostdlib -fno-exceptions -Wno-multichar ..." \
  64. # LIBS="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/lib/gcc/arm-eabi/X\
  65. # /interwork/libgcc.a ..."
  66. #
  67. # Finally, copy the file COPYING to NOTICE so that the curl license gets put
  68. # into the right place (but see the note about this below).
  69. #
  70. # Dan Fandrich
  71. # November 2011
  72. LOCAL_PATH:= $(call my-dir)/../..
  73. 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
  74. #########################
  75. # Build the libcurl library
  76. include $(CLEAR_VARS)
  77. include $(LOCAL_PATH)/lib/Makefile.inc
  78. CURL_HEADERS := \
  79. curl.h \
  80. system.h \
  81. curlver.h \
  82. easy.h \
  83. mprintf.h \
  84. multi.h \
  85. stdcheaders.h \
  86. typecheck-gcc.h
  87. LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES))
  88. LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/
  89. LOCAL_CFLAGS += $(common_CFLAGS)
  90. LOCAL_COPY_HEADERS_TO := libcurl/curl
  91. LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS))
  92. LOCAL_MODULE:= libcurl
  93. LOCAL_MODULE_TAGS := optional
  94. # Copy the licence to a place where Android will find it.
  95. # Actually, this doesn't quite work because the build system searches
  96. # for NOTICE files before it gets to this point, so it will only be seen
  97. # on subsequent builds.
  98. ALL_PREBUILT += $(LOCAL_PATH)/NOTICE
  99. $(LOCAL_PATH)/NOTICE: $(LOCAL_PATH)/COPYING | $(ACP)
  100. $(copy-file-to-target)
  101. include $(BUILD_STATIC_LIBRARY)
  102. #########################
  103. # Build the curl binary
  104. include $(CLEAR_VARS)
  105. include $(LOCAL_PATH)/src/Makefile.inc
  106. LOCAL_SRC_FILES := $(addprefix src/,$(CURL_CFILES))
  107. LOCAL_MODULE := curl
  108. LOCAL_MODULE_TAGS := optional
  109. LOCAL_STATIC_LIBRARIES := libcurl
  110. LOCAL_SYSTEM_SHARED_LIBRARIES := libc
  111. LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/lib
  112. # This may also need to include $(CURLX_CFILES) in order to correctly link
  113. # if libcurl is changed to be built as a dynamic library
  114. LOCAL_CFLAGS += $(common_CFLAGS)
  115. include $(BUILD_EXECUTABLE)