Makefile: Rework CUSTOM_KERNEL_IMAGE

Use a conditional variable assignment instead of relying on setting an
intermediate CUSTOM_KERNEL_IMAGE variable to conditionally create a rule
for KERNEL_IMAGE: if a custom KERNEL_IMAGE is passed, it should exist
and if it doesn't, it is the responsibility of the user (not make) to
create it beforehand.

Introduce a DEFAULT_KERNEL_IMAGE location and make a (non-conditionally
existing) rule create it from LINUX_MAKE. Note that, if later on we need
to have a condition that would have checked CUSTOM_KERNEL_IMAGE, we will
be able to instead test ifeq($(KERNEL_IMAGE),$(DEFAULT_KERNEL_IMAGE)).

Define linux_image and KERNEL_IMAGE as targets of the same rule: this
results in make not calling the Linux build system if the image already
exists, stopping tests from pointlessly spending 10+ seconds in the
kernel build system every time they run. Of course, this also means that
new changes in the linux source will not be picked up by this top-level
make and that a user having changed the kernel source while an image of
the kernel exists will be expected to manually rebuild it (or simply
delete the existing image), which they could easily force through

    make linux_image

Bug: 195395681
Test: make KERNEL_IMAGE=<...> test
Change-Id: I3a8f512b35a2c6c85bb493a370c46e629232eea5
1 file changed
tree: 77f1eaddb2a5deb2f78db5acd0bab47a428d6ff2
  1. aarch64/
  2. crosvm/
  3. cuttlefish/
  4. kvm-unit-tests/
  5. common.inc
  6. Makefile