stack.mk 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. ifeq ($(VARIABLE_STACK_NAME),)
  33. VARIABLE_STACK_NAME:=STACK
  34. endif
  35. # $(1) should list the variables
  36. # vadd must be exactly of the form of 3 lines, the middle one containing "$(1)"
  37. # Otherwise the extra return will be treated like a character rather than as whitespace
  38. define LINEFEED
  39. endef
  40. define vadd
  41. $(1):=$(2)
  42. endef
  43. #
  44. # Create a kind of stack "frame"
  45. # The parameters are names of variables whose values are to be stored in the frame
  46. # so that these values may be restored later.
  47. #
  48. # use thus:
  49. # $(call vsave,OUTPUTPATH SOURCEPATH CDEFS)
  50. #
  51. define vsave
  52. $(eval
  53. VARIABLE_STACK_NAME:=$(VARIABLE_STACK_NAME).F
  54. $$(VARIABLE_STACK_NAME):=$$(foreach VAR,$(1),$$(call vadd,$$(VAR),$$($$(VAR)))))
  55. endef
  56. #
  57. # Pop the top stack frame.
  58. #
  59. # use thus:
  60. # $(call vrestore)
  61. #
  62. define vrestore
  63. $(eval $($(VARIABLE_STACK_NAME))
  64. VARIABLE_STACK_NAME:=$(patsubst %.F,%,$(VARIABLE_STACK_NAME))
  65. )
  66. endef