PUD: use mutex on stop
[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 -DLINUX_NETLINK_ROUTING
41 CPPFLAGS +=     -Dandroid
42
43 # bionic libc: missing declaration
44 CPPFLAGS +=     -DINET_ADDRSTRLEN=16
45 # bionic libc: missing declarations
46 CPPFLAGS +=     -D'IPTOS_PREC(tos)=((tos)&0xe0)'
47 CPPFLAGS +=     -D'IPTOS_TOS(tos)=((tos)&0x1e)'
48 CPPFLAGS +=     -DOLSRD_GLOBAL_CONF_FILE=\"$(CFGFILE)\"
49
50 # Compilation flags from build/toolchains/arm-eabi-4.2.1/setup.mk
51 CPPFLAGS +=  \
52         -march=armv5te -mtune=xscale \
53         -msoft-float -fpic \
54         -mthumb-interwork \
55         -ffunction-sections \
56         -funwind-tables \
57         -fstack-protector \
58         -fno-short-enums \
59         -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ \
60         -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__
61 ifeq ($(DEBUG),0)
62 CPPFLAGS +=  \
63         -fomit-frame-pointer \
64         -fstrict-aliasing \
65         -funswitch-loops \
66         -finline-limit=300
67 else
68 CPPFLAGS += \
69         -fno-omit-frame-pointer \
70         -fno-strict-aliasing
71 endif
72
73 PLUGIN_SONAME ?= $(PLUGIN_NAME)
74 PLUGIN_FULLNAME ?= $(PLUGIN_NAME).so.$(PLUGIN_VER)
75 INSTALL_LIB =   install -D -m 755 $(PLUGIN_FULLNAME) $(LIBDIR)/$(PLUGIN_FULLNAME); \
76                 /sbin/ldconfig -n $(LIBDIR)
77 UNINSTALL_LIB = rm -f $(LIBDIR)/$(PLUGIN_FULLNAME); \
78                 /sbin/ldconfig -n $(LIBDIR)
79
80 ifdef OLSRD_PLUGIN
81 GENERATE_PIC = true
82 endif
83
84 ifdef GENERATE_PIC
85 CFLAGS +=       -fPIC
86 LDFLAGS +=      -fPIC
87 endif
88
89 NDK = /opt/android-ndk-r4b
90 NDK_ARCH = $(NDK)/build/platforms/android-3/arch-arm
91
92 ifneq ($(shell uname -m),armv6l)
93 # You are not compiling with Debian direct on the phone
94 CURRENT_SYSTEM = $(shell uname -s | tr A-Z a-z)
95 CROSS_COMPILE = $(NDK)/build/prebuilt/$(CURRENT_SYSTEM)-x86/arm-eabi-4.2.1/bin/arm-eabi-
96 CC = $(CROSS_COMPILE)gcc
97 ifeq ($(DEBUG),0)
98 STRIP = $(CROSS_COMPILE)strip
99 endif
100 endif
101
102 CFLAGS += -I$(NDK_ARCH)/usr/include
103 CFLAGS += -I$(TOPDIR)/android
104
105 LDFLAGS += -nostartfiles -nodefaultlibs -nostdlib -Bdynamic
106 LDFLAGS += -Wl,--dynamic-linker -Wl,/system/bin/linker
107 LDFLAGS += -L$(NDK_ARCH)/usr/lib
108 LDFLAGS += -Wl,-rpath-link -Wl,$(NDK_ARCH)/usr/lib
109 LDFLAGS += -llog
110 ifndef OLSRD_PLUGIN
111 LDFLAGS += $(NDK_ARCH)/usr/lib/crtbegin_dynamic.o
112 endif
113
114 LIBS += -Wl,-lc -Wl,-lm -Wl,-lgcc
115 ifndef OLSRD_PLUGIN
116 LIBS += $(NDK_ARCH)/usr/lib/crtend_android.o
117 endif
118
119 # Local Variables:
120 # mode: makefile
121 # End: