Search code examples
android-ndknativegnu-makeandroid-ndk-r5jnienv

How to use make trace option from ndk


****This question is about invoking make trace option from ndk-build*********

I am trying to trace through a make file, and I get an error. It is my understanding that ndk is shell, which calls make. So I should be able to invoke make switches; and I can do some of them. But trace option just does not work:-( Please see the output below; what am I doing wrong pelase?

@MadScientist - I downloaded and intalled version 4.0. But I still see the same error. Can anyone run it on their system, and post the command they use? I think I may be triggering the switch out of order or something. If I can see a working instance, I can fine tune the command from there. Also; I had a look at the link you posted for make-4.0 updates; debug is listed there too. Sooo I am not sure why or how debug is working for 3.81; maybe an earlier version of it. Also I am not sure why debug works but not trace. I think this is an ndk issue. What I did was to issue make directly, and not only I see trace working; I don't see the error which prompted me to post this question. Which was a complaint that all is used with ":" and "::". I am going to put a ndk tag on this post and hope that a someone with ndk expertise would chime in. I greatly appreciate your help.

sansari@ubuntu:~/AndroidStudioProjects/ThirdNDK/app/src/main$ make -version
GNU Make 4.0
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
sansari@ubuntu:~/AndroidStudioProjects/ThirdNDK/app/src/main$ ~/ndk/android-ndk-r10d/ndk-build --trace  -I /home/sansari/mytree2/TBT  --just-print 
/home/sansari/ndk/android-ndk-r10d/prebuilt/linux-x86_64/bin/make: unrecognized option '--trace'
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from commands.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any commands; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no commands; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo commands.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for x86_64-pc-linux-gnu
Report bugs to <[email protected]>
sansari@ubuntu:~/AndroidStudioProjects/ThirdNDK/app/src/main$ 

@ Alex Cohn - Thanks again. This explains a lot. I am gonna first look into getting the latest ndk; and then try to use the latest version of make. One outstanding question for me is that my native C project, the one which I am trying to port into jni compiles with one of the toolchains in an earlier version of ndk. So for me to get the "::" error message now seems to suggest that it is caused by something else. I suspect it has something to do with me trying to include the make file of C project into my Android.mk. Although my Android.mk does not have an all target, is there one implied perhaps? I just read the make manual once like a newspaper; I do not recall if that is the case. But there are a lot of implied rules. Do you have any thoughts on that?


Solution

  • Google uses a custom version of GNU Make in ndk package. You can try to launch ndk-build with your downloaded make

    GNUMAKE=`which make` ndk-build
    

    But there may be some minor inconsistencies between the .mk files that constitute the core of ndk and the make on your path.