|
1 # |
|
2 # Copyright (c) 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 "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 # |
|
16 |
|
17 |
|
18 # This file converts the input stored in $(OPTIONS) variable into several different variables |
|
19 # depending in the content. |
|
20 # |
|
21 # $(OPTIONS) variable is assumed to contain following syntax: |
|
22 # -X,Y filename.ext -X filename.ext |
|
23 # |
|
24 # where X and Y are numbers for the color depth. |
|
25 # The first number is the actual color depth of the file and the second is the color depth |
|
26 # of the mask file. The second number (and the comma) may or may not be defined. |
|
27 # |
|
28 # Since there are color depths defined for both the actual file and it's mask file, we need |
|
29 # to determine also the name of the mask file somehow. |
|
30 # It is assumed that depending on the mask file color depth (Y) |
|
31 # the mask file has a different string appended to it's file name. |
|
32 # |
|
33 # These mask file strings must be defined in the variable $(MASK_OPTION_Y) where Y is the |
|
34 # mask file color depth. |
|
35 # |
|
36 # |
|
37 # Options will be splitted into variables of $(FILES) which contains the filenames after the |
|
38 # options and to OPTION_$(FILE) where $(FILE) is each of the $(FILES) and |
|
39 # $(OPTION1_$(FILE)) and $(OPTION2_$(FILE)) depending whether the option for the file |
|
40 # was infact 2 options separated with comma or not. |
|
41 # |
|
42 # Example: lets consider following variables are defined: |
|
43 # |
|
44 # MASK_OPTION_1=_mask |
|
45 # MASK_OPTION_8=_mask_soft |
|
46 # |
|
47 # And that our input is: |
|
48 # OPTIONS=-c8,1 calc_paper -c8,8 display_side_l -c8 display_center |
|
49 # |
|
50 # The option reader would go through the $(OPTIONS) and fill out following variables: |
|
51 # |
|
52 # FILES=calc_paper display_side_l display_center |
|
53 # |
|
54 # |
|
55 # OPTION_calc_paper=-c8,2 |
|
56 # OPTION1_calc_paper=-c8 |
|
57 # OPTION2_calc_paper=2 |
|
58 # OPTION1_calc_paper_mask=-2 |
|
59 # |
|
60 # OPTION_display_side_l=-c8,8 |
|
61 # OPTION1_display_side_l=-c8 |
|
62 # OPTION2_display_side_l=8 |
|
63 # OPTION1_calc_paper_mask_soft=-8 |
|
64 # |
|
65 # OPTION1_display_center=-c8 |
|
66 |
|
67 |
|
68 # Get files from the option list, i.e. everything that does not start with '-' |
|
69 FILES := $(foreach OPTION,\ |
|
70 $(OPTIONS),\ |
|
71 $(filter-out -%, $(OPTION))) |
|
72 #$(warning FILES $(FILES)) |
|
73 |
|
74 |
|
75 # Option list without files |
|
76 OPTION_LIST_WITHOUT_FILES:=$(filter-out $(FILES), $(OPTIONS)) |
|
77 #$(warning OPTION_LIST_WITHOUT_FILES $(OPTION_LIST_WITHOUT_FILES)) |
|
78 |
|
79 |
|
80 # Strip out possible suffixes from all files |
|
81 FILES:=$(basename $(FILES)) |
|
82 #$(warning FILES $(FILES)) |
|
83 |
|
84 |
|
85 # Get options for each file, in the form of OPTION_$FILE |
|
86 $(foreach FILE,\ |
|
87 $(FILES),\ |
|
88 $(eval OPTION_$(FILE):=$(firstword $(OPTION_LIST_WITHOUT_FILES))) \ |
|
89 $(eval OPTION_LIST_WITHOUT_FILES:=$(wordlist 2, $(words $(OPTION_LIST_WITHOUT_FILES)), $(OPTION_LIST_WITHOUT_FILES))) \ |
|
90 ) |
|
91 |
|
92 |
|
93 # If option consists of anything like *X,Y separate the parts from comma |
|
94 # The part before the comma is in OPTION1_file, if no comma it is same as OPTION_file |
|
95 # The possible part after the comma is in OPTION2_file |
|
96 COMMA:=, |
|
97 $(foreach FILE,\ |
|
98 $(FILES),\ |
|
99 $(eval SPACE_OPTIONS:=$(subst $(COMMA), ,$(OPTION_$(FILE)))) \ |
|
100 $(eval OPTION1_$(FILE):=$(firstword $(SPACE_OPTIONS))) \ |
|
101 $(eval OPTION2_$(FILE):=$(word 2,$(SPACE_OPTIONS))) \ |
|
102 ) |
|
103 |
|
104 |
|
105 # Generate mask files (from those files which had options after the comma) |
|
106 $(foreach FILE,\ |
|
107 $(FILES),\ |
|
108 $(eval $(FILE)_MASKFILE:=$(FILE)$(MASK_OPTION_$(OPTION2_$(FILE)))) \ |
|
109 ) |
|
110 |
|
111 |
|
112 # Filter out other than mask files |
|
113 MASKFILES:=$(filter %$(MASK_OPTION_1) %$(MASK_OPTION_8), $(foreach FILE, $(FILES), $($(FILE)_MASKFILE))) |
|
114 #$(warning MASKFILES $(MASKFILES)) |
|
115 |
|
116 |
|
117 # Create options to mask files based on the option given after comma to the corresponding original file |
|
118 $(foreach MASKFILE,\ |
|
119 $(MASKFILES),\ |
|
120 $(eval OPTION1_$(MASKFILE):=-$(OPTION2_$(subst $(MASK_OPTION_1),,$(subst $(MASK_OPTION_8),,$(MASKFILE))))) \ |
|
121 ) |