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