|
1 # |
|
2 # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of the License "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # # Implements a stack mechanism for FLMS |
|
16 # # Author: Timothy Murphy |
|
17 # # CHANGE THIS FILE AT YOUR PERIL! :-) |
|
18 # # It is very sensitive to spaces on the end of variables. |
|
19 # # It took a lot of trouble to get this exactly right so |
|
20 # # be careful about changing it. |
|
21 # # A "call stack" is necessary for variables which are used |
|
22 # # in an append-manner by glue makefiles. This behavior |
|
23 # # is only needed where and FLM call has the form: |
|
24 # # OUTPUTPATH:=$(OUTPUTPATH)/subdir |
|
25 # # include $(FLMHOME)/exefile.flm |
|
26 # # This is because the outputpath setting must be undone |
|
27 # # before the next call to an FLM that uses OUTPUTPATH (otherwise it keeps growing) |
|
28 # # USAGE: |
|
29 # # $(call vsave,VARIABLE1 VARIABLE2) |
|
30 # # $(call vrestore) |
|
31 # |
|
32 |
|
33 ifeq ($(VARIABLE_STACK_NAME),) |
|
34 VARIABLE_STACK_NAME:=STACK |
|
35 endif |
|
36 # $(1) should list the variables |
|
37 |
|
38 # vadd must be exactly of the form of 3 lines, the middle one containing "$(1)" |
|
39 # Otherwise the extra return will be treated like a character rather than as whitespace |
|
40 |
|
41 define LINEFEED |
|
42 |
|
43 |
|
44 endef |
|
45 |
|
46 define vadd |
|
47 $(1):=$(2) |
|
48 |
|
49 endef |
|
50 |
|
51 # |
|
52 # Create a kind of stack "frame" |
|
53 # The parameters are names of variables whose values are to be stored in the frame |
|
54 # so that these values may be restored later. |
|
55 # |
|
56 # use thus: |
|
57 # $(call vsave,OUTPUTPATH SOURCEPATH CDEFS) |
|
58 # |
|
59 define vsave |
|
60 $(eval |
|
61 VARIABLE_STACK_NAME:=$(VARIABLE_STACK_NAME).F |
|
62 $$(VARIABLE_STACK_NAME):=$$(foreach VAR,$(1),$$(call vadd,$$(VAR),$$($$(VAR))))) |
|
63 endef |
|
64 |
|
65 # |
|
66 # Pop the top stack frame. |
|
67 # |
|
68 # use thus: |
|
69 # $(call vrestore) |
|
70 # |
|
71 define vrestore |
|
72 $(eval $($(VARIABLE_STACK_NAME)) |
|
73 VARIABLE_STACK_NAME:=$(patsubst %.F,%,$(VARIABLE_STACK_NAME)) |
|
74 ) |
|
75 endef |
|
76 |