1 # Google Android makefile for curl and libcurl
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
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 -m, -f, -O and -nostdlib options into
16 # CFLAGS, and putting the -Wl, -L and -l options into LIBS, along with the path
17 # to the files libgcc.a, crtbegin_dynamic.o, and ccrtend_android.o. Remember
18 # that the paths must be absolute since you will not be running configure from
19 # the same directory as the Android make. The normal cross-compiler options
22 # The end result will be a configure command that looks something like this
23 # (the environment variable A is set to the Android root path):
25 # A=`realpath ../..` && \
26 # PATH="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/bin:$PATH" \
27 # ./configure --host=arm-linux CC=arm-eabi-gcc \
28 # CPPFLAGS="-I $A/system/core/include ..." \
29 # CFLAGS="-nostdlib -fno-exceptions -Wno-multichar ..." \
30 # LIB="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/lib/gcc/arm-eabi/X\
31 # /interwork/libgcc.a ..." \
33 # Finally, copy the file COPYING to NOTICE so that the curl license gets put
34 # into the right place (see the note about this below).
39 LOCAL_PATH:= $(call my-dir)
41 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
43 #########################
44 # Build the libcurl library
47 include $(LOCAL_PATH)/lib/Makefile.inc
60 LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES))
61 LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/
62 LOCAL_CFLAGS += $(common_CFLAGS)
64 LOCAL_COPY_HEADERS_TO := libcurl/curl
65 LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS))
67 LOCAL_MODULE:= libcurl
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)
77 include $(BUILD_STATIC_LIBRARY)
80 #########################
81 # Build the curl binary
84 include $(LOCAL_PATH)/src/Makefile.inc
85 LOCAL_SRC_FILES := $(addprefix src/,$(CURL_SOURCES))
88 LOCAL_STATIC_LIBRARIES := libcurl
89 LOCAL_SYSTEM_SHARED_LIBRARIES := libc
91 LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/lib
93 # This will also need to include $(CURLX_ONES) in order to correctly link
94 # against a dynamic library
95 LOCAL_CFLAGS += $(common_CFLAGS)
97 include $(BUILD_EXECUTABLE)