GPS GPS - 1 year ago 147
Android Question

Error building Android kernel: "multiple target patterns"

I attempted to build a fresh kernel for Nexus 5X following Google's instructions on this page

  • Build system: Ubuntu 14.04 x86_64

  • Target system: MTC19T/bullhead (Actually any marshmallow version on 5X)

  • Toolchain: android-6.0.1_r25/prebuilts/gcc/linux-x86/aarch64/

Exact sequence of commands I executed are:

$ git clone
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-linux-android-
$ cd msm
$ git checkout -b android-msm-bullhead-3.10-marshmallow-mr1 origin/android-msm-bullhead-3.10-marshmallow-mr1
$ make bullhead_defconfig
$ make

I am greeted with following error after last command:

Makefile:796: *** multiple target patterns. Stop.


Now line 796 in makefile is:

vmlinux: scripts/ $(vmlinux-deps) FORCE

and other relevant lines are:


export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y)
export KBUILD_LDS := arch/$(SRCARCH)/kernel/

I found that if I remove
this error disappears, and build continues for some time. I am sure I wil find some or other issue later, so I decided to debug further.

Disclaimer: Rest of this is a bit gray area for me

is defined as:

libs-y := lib/
libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
libs-y := $(libs-y1) $(libs-y2)

So I called
with parameters
lib/lib.a lib/built-in.o FORCE
and am greeted with this error:

gps@gps-HP-ProBook-4540s:~/andsrc/kernel/msm$ ./scripts/ lib/lib.a lib/built-in.o FORCE
trap: SIGHUP: bad trap

Since this output has
, this probably explains the original make error.

Now, disabling the line containing trap does not help, we get another error:

gps@gps-HP-ProBook-4540s:~/andsrc/kernel/msm$ ./scripts/ lib/lib.a lib/built-in.o FORCE
LD vmlinux.o
./scripts/ 44: ./scripts/ -r: not found

I am not very sure what to try next. Any help is appreciated.

Answer Source

Lines 44 and 45 look something like this:

${LD} ${LDFLAGS} -r -o ${1} ${KBUILD_VMLINUX_INIT}  \
        --start-group ${KBUILD_VMLINUX_MAIN} --end-group

So what's happening is that $LD and $LDFLAGS are undefined which leaves the command to just be -r ..., and -r isn't a command on your system, hence the command not found.

Define $LD and $LDFLAGS then it will run whatever $LD is with the $LDFLAGS + the remainder of the other command.

If you still have problems, add a comment and I'll look into it further.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download