2 # Steps to compile for Android:
4 # 1) Download and extract the Android NDK from
5 # http://developer.android.com/sdk/ndk/index.html
6 # (e.g. into to /opt, otherwise call 'make NDK_BASE=')
8 # 2) Compile olsrd with the make command:
9 # make OS=android DEBUG=0 NDK_BASE=/opt
11 # 3) Install olsrd on your local PC, e.g.
12 # sudo make OS=android DEBUG=0 install_all
13 # which creates a /data directory on your PC.
15 # 4) Change /data/local/etc/olsrd.conf. You need
16 # to adapt the 'Interfaces' line, e.g. to use
17 # the eth0 on your android mobile. Also, the
18 # LoadPlugin lines needs adaption, e.g. you
19 # need "/data/local/lib/olsrd_txtinfo.so.0.1"
21 # 5) Copy all file from /data to your mobile, e.g.
22 # by pushing the files with the 'adb' tool.
26 # LINUX SPECIFIC CONFIGURATION
30 SBINDIR = $(PREFIX)/bin
31 ETCDIR = $(PREFIX)/etc
32 LIBDIR = $(PREFIX)/lib
36 # there probably should be an Android log.c and misc.c to support
37 # Logcat, but this works for now
38 SRCS += $(wildcard src/unix/*.c src/linux/*.c)
39 HDRS += $(wildcard src/unix/*.h src/linux/*.h)
41 # Android didn't add regex until android-8 so include this one
43 android/regex/regcomp.c \
44 android/regex/regerror.c \
45 android/regex/regexec.c \
46 android/regex/regfree.c
47 REGEX_OBJS = $(REGEX_SRCS:.c=.o)
51 CPPFLAGS += -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
52 # bionic libc: missing declarations
53 CPPFLAGS += -DINET_ADDRSTRLEN=16
54 CPPFLAGS += -D'IPTOS_PREC(tos)=((tos)&0xe0)'
55 CPPFLAGS += -D'IPTOS_TOS(tos)=((tos)&0x1e)'
56 # Android NDK is missing some Linux headers and regex, we have them here:
57 CPPFLAGS += -I$(TOPDIR)/android
59 # Compilation flags from build/toolchains/arm-eabi-4.2.1/setup.mk
60 # * removed -fstrict-aliasing since the code has a lot of type-punning
62 -march=armv5te -mtune=xscale \
69 -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
70 -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
73 -fomit-frame-pointer \
78 -fno-omit-frame-pointer
92 PLUGIN_SONAME ?= $(PLUGIN_NAME)
93 PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
94 INSTALL_LIB = install -D -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
95 /sbin/ldconfig -n $(LIBDIR)
96 UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN_FULLNAME); \
97 /sbin/ldconfig -n $(LIBDIR)
99 HOST = arm-linux-androideabi
100 NDK_BASE = /opt/android-ndk
101 CURRENT_SYSTEM := $(shell uname -s | tr A-Z a-z)
102 NDK_TOOLCHAIN_BASE = $(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(CURRENT_SYSTEM)-x86
104 NDK_PLATFORM_VERSION = 4
105 NDK_SYSROOT = $(NDK_BASE)/platforms/android-$(NDK_PLATFORM_VERSION)/arch-arm
106 CROSS_COMPILE = $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-
108 CC = $(CROSS_COMPILE)gcc --sysroot="$(NDK_SYSROOT)"
109 LD = $(CROSS_COMPILE)ld
110 AR = $(CROSS_COMPILE)ar
112 STRIP = $(CROSS_COMPILE)strip
116 # The Android NDK didn't add proper regex support until android-8
117 # (2.2), so we include the Android files here, and build with
118 # -DPOSIX_MISTAKE like Android does.
119 $(REGEX_OBJS): $(REGEX_SRCS)
121 $(CC) $(CFLAGS) $(CPPFLAGS) -DPOSIX_MISTAKE -c -o $@ $<