| 1 | # $Id: testcase-2ndtargetexp.kmk 2243 2009-01-10 02:24:02Z bird $
|
|---|
| 2 | ## @file
|
|---|
| 3 | # kBuild - testcase for the 2nd target expansion feature.
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
|
|---|
| 8 | #
|
|---|
| 9 | # This file is part of kBuild.
|
|---|
| 10 | #
|
|---|
| 11 | # kBuild is free software; you can redistribute it and/or modify
|
|---|
| 12 | # it under the terms of the GNU General Public License as published by
|
|---|
| 13 | # the Free Software Foundation; either version 3 of the License, or
|
|---|
| 14 | # (at your option) any later version.
|
|---|
| 15 | #
|
|---|
| 16 | # kBuild is distributed in the hope that it will be useful,
|
|---|
| 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | # GNU General Public License for more details.
|
|---|
| 20 | #
|
|---|
| 21 | # You should have received a copy of the GNU General Public License
|
|---|
| 22 | # along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 |
|
|---|
| 26 | DEPTH = ../..
|
|---|
| 27 | include $(PATH_KBUILD)/header.kmk
|
|---|
| 28 |
|
|---|
| 29 | #
|
|---|
| 30 | # Enable it.
|
|---|
| 31 | #
|
|---|
| 32 | .SECONDTARGETEXPANSION:
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | #
|
|---|
| 36 | # This is expanded immediately.
|
|---|
| 37 | #
|
|---|
| 38 | foo1 = foo1
|
|---|
| 39 | $(foo1):
|
|---|
| 40 | $(if $(eq $@,foo1),$(ECHO) "foo1 works",$(ECHO) "foo1 is busted @=$@"; exit 1)
|
|---|
| 41 |
|
|---|
| 42 | # Mostly for making sure the ifeq test works below.
|
|---|
| 43 | flush_command_recoding := 1 # see record_waiting_files() in read.c
|
|---|
| 44 | ifeq ($(strip $(commands foo1)),)
|
|---|
| 45 | $(error No commands for foo1: $(commands foo1))
|
|---|
| 46 | endif
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | #
|
|---|
| 50 | # This is expanded in the 2nd round.
|
|---|
| 51 | #
|
|---|
| 52 | $$(foo2):
|
|---|
| 53 | $(if $(eq $@,foo2),$(ECHO) "foo2 works",$(ECHO) "foo2 is busted @=$@"; exit 1)
|
|---|
| 54 |
|
|---|
| 55 | # Check that a $(foo2) file exists.
|
|---|
| 56 | flush_command_recoding := 1 # see record_waiting_files() in read.c
|
|---|
| 57 | # $ (info $$(foo2) commands: $(commands $$(foo2)))
|
|---|
| 58 | ifeq ($(strip $(commands $$(foo2))),)
|
|---|
| 59 | $(error No commands for $$(foo2): $(commands $$(foo2)))
|
|---|
| 60 | endif
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | all_recursive: foo1 foo2
|
|---|
| 64 | $(ECHO) "2nd target expansion passes smoke testing"
|
|---|
| 65 |
|
|---|
| 66 | # define this last
|
|---|
| 67 | foo2 = foo2
|
|---|
| 68 |
|
|---|