Skip to content

Instantly share code, notes, and snippets.

@kristianlm
Created April 17, 2015 08:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristianlm/dcb3e35ce8705b13cea7 to your computer and use it in GitHub Desktop.
Save kristianlm/dcb3e35ce8705b13cea7 to your computer and use it in GitHub Desktop.
# build nanomsg for Android's aosp
# hope this is useful for someone! :D
LOCAL_PATH := $(ANDROID_BUILD_TOP)/external/nanomsg/src
include $(CLEAR_VARS)
LOCAL_SRC_FILES := core/epbase.c core/sock.c core/poll.c \
core/symbol.c core/ep.c core/pipe.c \
core/sockbase.c core/global.c devices/device.c \
transports/inproc/ins.c transports/inproc/inproc.c \
transports/inproc/cinproc.c transports/inproc/binproc.c \
transports/inproc/sinproc.c transports/inproc/msgqueue.c \
transports/utils/dns.c transports/utils/literal.c \
transports/utils/streamhdr.c transports/utils/backoff.c \
transports/utils/iface.c transports/utils/port.c \
transports/tcp/tcp.c transports/tcp/stcp.c \
transports/tcp/ctcp.c transports/tcp/atcp.c \
transports/tcp/btcp.c transports/ipc/aipc.c \
transports/ipc/bipc.c transports/ipc/cipc.c \
transports/ipc/ipc.c transports/ipc/sipc.c \
protocols/survey/xrespondent.c \
protocols/survey/surveyor.c protocols/survey/xsurveyor.c \
protocols/survey/respondent.c protocols/pair/pair.c \
protocols/pair/xpair.c protocols/utils/dist.c \
protocols/utils/priolist.c protocols/utils/fq.c \
protocols/utils/excl.c protocols/utils/lb.c \
protocols/bus/xbus.c protocols/bus/bus.c \
protocols/pipeline/xpull.c protocols/pipeline/push.c \
protocols/pipeline/pull.c protocols/pipeline/xpush.c \
protocols/reqrep/rep.c protocols/reqrep/req.c \
protocols/reqrep/xrep.c protocols/reqrep/task.c \
protocols/reqrep/xreq.c protocols/pubsub/sub.c \
protocols/pubsub/xpub.c protocols/pubsub/xsub.c \
protocols/pubsub/trie.c protocols/pubsub/pub.c \
aio/worker.c aio/fsm.c aio/ctx.c aio/usock.c \
aio/poller.c aio/pool.c aio/timerset.c \
aio/timer.c utils/err.c utils/thread.c \
utils/closefd.c utils/atomic.c utils/list.c \
utils/stopwatch.c utils/random.c utils/wire.c \
utils/mutex.c utils/msg.c utils/clock.c \
utils/queue.c utils/chunk.c utils/efd.c \
utils/hash.c utils/alloc.c utils/glock.c \
utils/sleep.c utils/chunkref.c utils/sem.c
LOCAL_CFLAGS := \
-DNN_HAVE_EVENTFD \
-DNN_HAVE_SEMAPHORE \
-DNN_HAVE_POLL \
-DNN_USE_POLL \
-DNN_USE_LITERAL_IFADDR
#-DNN_HAVE_EVENTFD
LOCAL_MODULE := libnanomsg
LOCAL_MODULE_TAGS := optional
# make these beautful includes available for other projects. inspired
# by libpng.
LOCAL_COPY_HEADERS_TO := nanomsg
LOCAL_COPY_HEADERS := nn.h bus.h reqrep.h pipeline.h pair.h survey.h pubsub.h
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
../tools/nanocat.c \
../tools/options.c
#pthread-test.c
LOCAL_MODULE := nanocat
LOCAL_SHARED_LIBRARIES := libnanomsg
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
@kroggen
Copy link

kroggen commented Dec 16, 2015

In my ndk (r10e on Windows, with Android-15) it failed with the message: undefined reference to 'eventfd'

So I replaced the -DNN_HAVE_EVENTFD for -DNN_HAVE_PIPE or even -DNN_HAVE_SOCKETPAIR. Both worked separately, but I ended using both.

I also added NN_HAVE_STDINT and NN_HAVE_CLOCK_MONOTONIC, so my definitions block was this:

LOCAL_CFLAGS :=  \
    -DNN_HAVE_STDINT \
    -DNN_HAVE_CLOCK_MONOTONIC \
    -DNN_HAVE_PIPE \
    -DNN_HAVE_SOCKETPAIR \
    -DNN_HAVE_SEMAPHORE \
    -DNN_HAVE_POLL \
    -DNN_USE_POLL \
    -DNN_USE_LITERAL_IFADDR \
    -DNN_HAVE_MSG_CONTROL

Working fine.

Thanks for sharing! You helped me a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment