615620b8c9ee59ead65e3f1dbbc8435e69edef68
[olsrd.git] / make / Makefile.android
1 #
2 # Steps to compile for Android:
3 #
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=')
7 #
8 # 2) Compile olsrd with the make command:
9 #    make OS=android DEBUG=0 build_all
10 #    (expect lots of warnings which is normal)
11 #
12 # 3) Install olsrd on your local PC, e.g.
13 #    sudo make OS=android DEBUG=0 install_all
14 #    which creates a /data directory on your PC.
15 #
16 # 4) Change /data/local/etc/olsrd.conf. You need
17 #    to adapt the 'Interfaces' line, e.g. to use
18 #    the eth0 on your android mobile. Also, the
19 #    LoadPlugin lines needs adaption, e.g. you
20 #    need "/data/local/lib/olsrd_txtinfo.so.0.1"
21 #
22 # 5) Copy all file from /data to your mobile, e.g.
23 #    by pushing the files with the 'adb' tool.
24 #
25
26 #
27 # LINUX SPECIFIC CONFIGURATION
28 #
29
30 PREFIX ?= /data/local
31 SBINDIR = $(PREFIX)/bin
32 ETCDIR = $(PREFIX)/etc
33 LIBDIR = $(PREFIX)/lib
34 DOCDIR =
35 MANDIR =
36
37 SRCS +=         $(wildcard src/linux/*.c src/unix/*.c)
38 HDRS +=         $(wildcard src/linux/*.h src/unix/*.h)
39
40 CPPFLAGS +=     -Dlinux
41
42 # bionic libc: missing declaration
43 CPPFLAGS +=     -DINET_ADDRSTRLEN=16
44 # bionic libc: missing declarations
45 CPPFLAGS +=     -D'IPTOS_PREC(tos)=((tos)&0xe0)'
46 CPPFLAGS +=     -D'IPTOS_TOS(tos)=((tos)&0x1e)'
47 CPPFLAGS +=     -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
48
49 # Compilation flags from build/toolchains/arm-eabi-4.2.1/setup.mk
50 CPPFLAGS +=  \
51         -march=armv5te -mtune=xscale \
52         -msoft-float -fpic \
53         -mthumb-interwork \
54         -ffunction-sections \
55         -funwind-tables \
56         -fstack-protector \
57         -fno-short-enums \
58         -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
59         -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
60 ifeq ($(DEBUG),0)
61 CPPFLAGS +=  \
62         -fomit-frame-pointer \
63         -fstrict-aliasing \
64         -funswitch-loops \
65         -finline-limit=300
66 else
67 CPPFLAGS += \
68         -fno-omit-frame-pointer \
69         -fno-strict-aliasing
70 endif
71
72 PLUGIN_SONAME ?= $(PLUGIN_NAME)
73 PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
74 INSTALL_LIB =   install -D -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
75                 /sbin/ldconfig -n $(LIBDIR)
76 UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN_FULLNAME); \
77                 /sbin/ldconfig -n $(LIBDIR)
78
79 ifdef OLSRD_PLUGIN
80 GENERATE_PIC = true
81 endif
82
83 ifdef GENERATE_PIC
84 CFLAGS +=       -fPIC
85 LDFLAGS +=      -fPIC
86 endif
87
88 NDK = /opt/android-ndk-r4b
89 NDK_ARCH = $(NDK)/build/platforms/android-3/arch-arm
90
91 ifneq ($(shell uname -m),armv6l)
92 # You are not compiling with Debian direct on the phone
93 CURRENT_SYSTEM = $(shell uname -s | tr A-Z a-z)
94 CROSS_COMPILE = $(NDK)/build/prebuilt/$(CURRENT_SYSTEM)-x86/arm-eabi-4.2.1/bin/arm-eabi-
95 CC = $(CROSS_COMPILE)gcc
96 ifeq ($(DEBUG),0)
97 STRIP = $(CROSS_COMPILE)strip
98 endif
99 endif
100
101 CFLAGS += -I$(NDK_ARCH)/usr/include
102 CFLAGS += -I$(TOPDIR)/android
103
104 LDFLAGS += -nostartfiles -nodefaultlibs -nostdlib -Bdynamic
105 LDFLAGS += -Wl,--dynamic-linker -Wl,/system/bin/linker
106 LDFLAGS += -L$(NDK_ARCH)/usr/lib
107 LDFLAGS += -Wl,-rpath-link -Wl,$(NDK_ARCH)/usr/lib
108 LDFLAGS += -llog
109 ifndef OLSRD_PLUGIN
110 LDFLAGS += $(NDK_ARCH)/usr/lib/crtbegin_dynamic.o
111 endif
112
113 LIBS += -Wl,-lc -Wl,-lm -Wl,-lgcc
114 ifndef OLSRD_PLUGIN
115 LIBS += $(NDK_ARCH)/usr/lib/crtend_android.o
116 endif
117
118 # Local Variables:
119 # mode: makefile
120 # End: