Can Android.mk echo?

12,718 views
Skip to first unread message

ezmora

unread,
May 4, 2011, 11:01:23 PM5/4/11
to android-ndk
I'd like my Android.mk to print out some debug output as the
compilation advances.
I tried inserting
echo "some text"
into my Android.mk, but compilation failed.
Is there a way to achieve that?

mic _

unread,
May 5, 2011, 3:17:27 AM5/5/11
to andro...@googlegroups.com
Let's say the library you're building is called libfoobar. Then this would work inside your Android.mk:

libfoobar:
    @echo "blah blah"


/Michael


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Jocelyn Houle

unread,
May 5, 2011, 8:43:54 AM5/5/11
to andro...@googlegroups.com
I believe:

  shell> ndk-build V=1

spews out information that is typically sufficient to reproduce compile issue.


If that fails, make can spit out even more information with:

  shell> ndk-build -d

but that can quickly get unwieldy.


The @echo trick is useful, but only when you create your own Makefile targets, which is normally not the case in Android.mk files.


If it's a syntactical issue in the Makefile, you can peek at current variable values using something like the following:

  $(warning Value of MY_VAR is '$(MY_VAR)')

(formatting only meant to be an example)


Note that those warnings are printed when make parses the line; the execution happens once all the files are parsed.  In that sense, it's akin to #warning in a C file.  The @echo trick is the runtime printf() equivalent.

eyal zmora

unread,
May 5, 2011, 12:13:04 PM5/5/11
to andro...@googlegroups.com
Thanks for your reply.
I tried the @echo trick in my Android.mk but it didn't work.
I receive:      Android.mk:10: *** missing separator.  Stop.
Any ideas?

2011/5/5 Jocelyn Houle <ludosap...@gmail.com>

Jocelyn Houle

unread,
May 5, 2011, 12:25:09 PM5/5/11
to andro...@googlegroups.com
> Thanks for your reply.
> I tried the @echo trick in my Android.mk but it didn't work.
> I receive: Android.mk:10: *** missing separator. Stop.
> Any ideas?

@echo can only be called in targets (those are indented by a tab after the target declaration).

If you simply want a trace anywhere in your file, use the $(warning ...) function.

eyal zmora

unread,
May 5, 2011, 12:31:15 PM5/5/11
to andro...@googlegroups.com
$(warning ) is working.
Thanks a lot.

2011/5/5 Jocelyn Houle <ludosap...@gmail.com>

--

Patrick Tsai

unread,
May 5, 2011, 9:12:12 AM5/5/11
to android-ndk
Try $(info YOUR MESSAGE)
Reply all
Reply to author
Forward
0 new messages