Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

GmtGenExtraHeaders.cmake 11 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
  1. #
  2. # $Id$
  3. #
  4. # - Generates extra header files
  5. # GMT_CREATE_HEADERS ()
  6. #
  7. # Copyright (c) 1991-2015 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
  8. # See LICENSE.TXT file for copying and redistribution conditions.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU Lesser General Public License as published by
  12. # the Free Software Foundation; version 3 or any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU Lesser General Public License for more details.
  18. #
  19. # Contact info: gmt.soest.hawaii.edu
  20. #-------------------------------------------------------------------------------
  21. include (ManageString)
  22. # gmt_datums.h
  23. macro (gen_gmt_datums_h)
  24. file2list (_datums_file ${GMT_SRC}/src/Datums.txt)
  25. list_regex_replace (
  26. "^([^#\t]+)[\t]+([^\t]+)[\t]+([^\t]+)[\t]+([^\t]+)[\t]+([^\t]+)[\t]+(.+)"
  27. "\t\t{\"\\\\1\", \"\\\\2\", \"\\\\6\", {\\\\3, \\\\4, \\\\5}}"
  28. _datums ${_datums_file}
  29. MATCHES_ONLY)
  30. list (REMOVE_DUPLICATES _datums)
  31. string (REPLACE ";" ",\n" _datums "${_datums}")
  32. string_unescape (_datums "${_datums}" NOESCAPE_SEMICOLON)
  33. file (WRITE gmt_datums.h "${_datums}\n")
  34. endmacro (gen_gmt_datums_h)
  35. macro (gen_gmt_colors_h)
  36. # gmt_colornames.h
  37. file2list (_color_file ${GMT_SRC}/src/Colors.txt)
  38. list_regex_replace (
  39. "^[0-9 \t]+([a-z]+[0-9]*).*"
  40. "\"\\\\1\""
  41. _color_names ${_color_file}
  42. MATCHES_ONLY)
  43. string (REPLACE ";" ",\n" _color_names "${_color_names}")
  44. file (WRITE gmt_colornames.h "${_color_names}\n")
  45. # gmt_color_rgb.h
  46. list_regex_replace (
  47. "^[ ]*([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+).*"
  48. "{\\\\1, \\\\2, \\\\3}"
  49. _colors_rgb ${_color_file}
  50. MATCHES_ONLY)
  51. string (REPLACE ";" ",\n" _colors_rgb "${_colors_rgb}")
  52. file (WRITE gmt_color_rgb.h "${_colors_rgb}\n")
  53. # # Colors.i
  54. # list_regex_replace (
  55. # "^([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([a-z]+[0-9]*).*"
  56. # "\\\\1\t\\\\2\t\\\\3\t\\\\4"
  57. # _colors_man ${_color_file}
  58. # MATCHES_ONLY)
  59. # string (REPLACE ";" "\n.br\n" _colors_man "${_colors_man}")
  60. # file (WRITE Colors.i ".br\n${_colors_man}\n")
  61. endmacro (gen_gmt_colors_h)
  62. # Fonts.i
  63. #macro (gen_ps_font_info)
  64. # file2list (_fonts_file ${GMT_SRC}/share/pslib/PS_font_info.d)
  65. # list_regex_replace (
  66. # "^([^# \t]+).*"
  67. # "\\\\1"
  68. # _fonts_list ${_fonts_file}
  69. # MATCHES_ONLY)
  70. # set (_fonts_man)
  71. # set (_fontnum 0)
  72. # foreach (_font ${_fonts_list})
  73. # list (APPEND _fonts_man "${_fontnum}\t${_font}")
  74. # math (EXPR _fontnum "${_fontnum} + 1")
  75. # endforeach (_font ${_fonts_list})
  76. # string (REPLACE ";" "\n.br\n" _fonts_man "${_fonts_man}")
  77. # file (WRITE Fonts.i ".br\n${_fonts_man}\n")
  78. #endmacro (gen_ps_font_info)
  79. macro (gen_gmt_ellipsoids)
  80. # gmt_ellipsoids.h
  81. file2list (_ellipsnames_file ${GMT_SRC}/src/Ellipsoids.txt)
  82. list_regex_replace (
  83. "^([^#\t]+)[ \t]+([0-9]+)[ \t]+([0-9.]+)[ \t]+([0-9.]+)[ \t]+:.*"
  84. "\t\t{\"\\\\1\", \\\\2, \\\\3, 1.0/\\\\4}"
  85. _ellipsnames ${_ellipsnames_file}
  86. MATCHES_ONLY)
  87. list (REMOVE_DUPLICATES _ellipsnames)
  88. string (REPLACE "1.0/0}" "0}" _ellipsnames "${_ellipsnames}")
  89. string (REPLACE ";" ",\n" _ellipsnames "${_ellipsnames}")
  90. file (WRITE gmt_ellipsoids.h "${_ellipsnames}\n")
  91. # # Ellipsoids.i
  92. # list_regex_replace (
  93. # "^([^#\t]+)[ \t]+([0-9]+)[ \t]+[0-9.]+[ \t]+[0-9.]+[ \t]+:[ \t]+(.*)"
  94. # "\\\\1: \\\\3 (\\\\2)"
  95. # _ellipsnames ${_ellipsnames_file}
  96. # MATCHES_ONLY)
  97. # list (REMOVE_DUPLICATES _ellipsnames)
  98. # string (REPLACE ";" "\n.br\n" _ellipsnames "${_ellipsnames}")
  99. # file (WRITE Ellipsoids.i "${_ellipsnames}\n")
  100. endmacro (gen_gmt_ellipsoids)
  101. macro (gen_gmt_keywords_h)
  102. # gmt_keycases.h
  103. file2list (_gmtkeywords_file
  104. ${GMT_SRC}/src/gmt_keywords.txt
  105. ${GMT_SRC}/src/gmt_keywords.d)
  106. list_regex_replace (
  107. "^([^#\t ]+).*"
  108. "\\\\1 "
  109. _gmtkeycases ${_gmtkeywords_file}
  110. MATCHES_ONLY)
  111. list (SORT _gmtkeycases)
  112. list (REMOVE_DUPLICATES _gmtkeycases)
  113. set (_gmtkeycasedef)
  114. set (_casenum 0)
  115. foreach (_case ${_gmtkeycases})
  116. list (APPEND _gmtkeycasedef "#define GMTCASE_${_case}${_casenum}")
  117. math (EXPR _casenum "${_casenum} + 1")
  118. endforeach (_case ${_gmtkeycases})
  119. string (REPLACE ";" "\n" _gmtkeycasedef "${_gmtkeycasedef}")
  120. file (WRITE gmt_keycases.h "${_gmtkeycasedef}\n")
  121. # gmt_keywords.h
  122. list_regex_replace (
  123. "^([^\t ]+)[\t ]*$"
  124. "\"\\\\1\""
  125. _gmtkeywords ${_gmtkeycases})
  126. string (REPLACE ";" ",\n" _gmtkeywords "${_gmtkeywords}")
  127. file (WRITE gmt_keywords.h "${_gmtkeywords}\n")
  128. endmacro (gen_gmt_keywords_h)
  129. # gmt_media_name.h gmt_pennames.h gmt_unique.h
  130. macro (gen_gmt_dimensions_h)
  131. file2list (_file_lines ${GMT_SRC}/src/gmt_media_name.h)
  132. list (REMOVE_DUPLICATES _file_lines)
  133. list (LENGTH _file_lines GMT_N_MEDIA)
  134. file2list (_file_lines ${GMT_SRC}/src/gmt_pennames.h)
  135. list (REMOVE_DUPLICATES _file_lines)
  136. list (LENGTH _file_lines GMT_N_PEN_NAMES)
  137. file2list (_file_lines ${GMT_SRC}/src/gmt_unique.h)
  138. list (REMOVE_DUPLICATES _file_lines)
  139. list (LENGTH _file_lines GMT_N_UNIQUE)
  140. # count lines in generated heders
  141. file2list (_file_lines gmt_datums.h)
  142. list (LENGTH _file_lines GMT_N_DATUMS)
  143. file2list (_file_lines gmt_ellipsoids.h)
  144. list (LENGTH _file_lines GMT_N_ELLIPSOIDS)
  145. file2list (_file_lines gmt_colornames.h)
  146. list (LENGTH _file_lines GMT_N_COLOR_NAMES)
  147. file2list (_file_lines gmt_keycases.h)
  148. list (LENGTH _file_lines GMT_N_KEYS)
  149. # gmt_dimensions.h
  150. configure_file (${GMT_SRC}/src/gmt_dimensions.h.in gmt_dimensions.h)
  151. endmacro (gen_gmt_dimensions_h)
  152. # gmtmath.h gmtmath_op.h gmtmath_explain.h gmtmath_man.i
  153. # GMTMATH_OPERATOR_INIT GMTMATH_OPERATOR_ARRAY GMTMATH_OPERATOR_EXPLAIN
  154. # GMTMATH_N_OPERATORS
  155. macro (gen_gmt_math_h)
  156. grep (
  157. "^/[* ]+OPERATOR:"
  158. _raw_op_descriptions
  159. ${GMT_SRC}/src/gmtmath.c)
  160. # gmtmath.h
  161. list_regex_replace (
  162. "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  163. "\tops[OP_NUM] = table_\\\\1#S\tn_args[OP_NUM] = \\\\2#S\tn_out[OP_NUM] = \\\\3#S"
  164. _raw_op_init ${_raw_op_descriptions}
  165. MATCHES_ONLY)
  166. list (LENGTH _raw_op_init GMTMATH_N_OPERATORS)
  167. set (_op_init)
  168. set (_opnum 0)
  169. foreach (_op ${_raw_op_init})
  170. string (REPLACE "OP_NUM" "${_opnum}" _op ${_op})
  171. list (APPEND _op_init ${_op})
  172. math (EXPR _opnum "${_opnum} + 1")
  173. endforeach (_op ${_raw_op_init})
  174. string (REPLACE ";" "\n" _op_init "${_op_init}")
  175. string_unescape (GMTMATH_OPERATOR_INIT "${_op_init}" NOESCAPE_SEMICOLON)
  176. configure_file (${GMT_SRC}/src/gmtmath.h.in gmtmath.h)
  177. # gmtmath_op.h
  178. list_regex_replace (
  179. "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  180. "\t\"\\\\1\",\t/* id = OP_NUM */"
  181. _raw_op_array ${_raw_op_descriptions}
  182. MATCHES_ONLY)
  183. set (_op_array)
  184. set (_opnum 0)
  185. foreach (_op ${_raw_op_array})
  186. string (REPLACE "OP_NUM" "${_opnum}" _op ${_op})
  187. list (APPEND _op_array ${_op})
  188. math (EXPR _opnum "${_opnum} + 1")
  189. endforeach (_op ${_raw_op_array})
  190. string (REPLACE ";" "\n" GMTMATH_OPERATOR_ARRAY "${_op_array}")
  191. configure_file (${GMT_SRC}/src/gmtmath_op.h.in gmtmath_op.h)
  192. # gmtmath_explain.h
  193. list_regex_replace (
  194. "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  195. "\t\t\"\t\\\\1PADDING\\\\2 \\\\3 \\\\4#Bn\""
  196. _op_explain ${_raw_op_descriptions}
  197. MATCHES_ONLY)
  198. set (_padded_lines)
  199. foreach (_line ${_op_explain})
  200. string_pad (_line 15 PADDING)
  201. list (APPEND _padded_lines ${_line})
  202. endforeach (_line ${_op_explain})
  203. string (REPLACE ";" "\n" _op_explain "${_padded_lines}")
  204. string_unescape (GMTMATH_OPERATOR_EXPLAIN "${_op_explain}" NOESCAPE_SEMICOLON)
  205. configure_file (${GMT_SRC}/src/gmtmath_explain.h.in gmtmath_explain.h)
  206. # # gmtmath_man.i
  207. # list_regex_replace (
  208. # "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  209. # "#BfB\\\\1#BfP\t\\\\2 \\\\3\t\\\\4"
  210. # _op_man ${_raw_op_descriptions}
  211. # MATCHES_ONLY)
  212. # string (REPLACE ";" "\n" _op_man "${_op_man}")
  213. # string_unescape (_op_man "${_op_man}" NOESCAPE_SEMICOLON)
  214. # set (_op_man "Choose among the following ${GMTMATH_N_OPERATORS} operators.\n"
  215. # "\"args\" are the number of input and output arguments.\n"
  216. # ".TS\nl l l .\nOperator\targs\tReturns\n${_op_man}\n.TE\n")
  217. # file (WRITE gmtmath_man.i ${_op_man})
  218. endmacro (gen_gmt_math_h)
  219. # grdmath.h grdmath_op.h grdmath_explain.h grdmath_man.i
  220. # GRDMATH_OPERATOR_INIT GRDMATH_OPERATOR_ARRAY GRDMATH_OPERATOR_EXPLAIN
  221. # GRDMATH_N_OPERATORS
  222. macro (gen_grd_math_h)
  223. grep (
  224. "^/[* ]+OPERATOR:"
  225. _raw_op_descriptions
  226. ${GMT_SRC}/src/grdmath.c)
  227. # grdmath.h
  228. list_regex_replace (
  229. "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  230. "\tops[OP_NUM] = grd_\\\\1#S\tn_args[OP_NUM] = \\\\2#S\tn_out[OP_NUM] = \\\\3#S"
  231. _raw_op_init ${_raw_op_descriptions}
  232. MATCHES_ONLY)
  233. list (LENGTH _raw_op_init GRDMATH_N_OPERATORS)
  234. set (_op_init)
  235. set (_opnum 0)
  236. foreach (_op ${_raw_op_init})
  237. string (REPLACE "OP_NUM" "${_opnum}" _op ${_op})
  238. list (APPEND _op_init ${_op})
  239. math (EXPR _opnum "${_opnum} + 1")
  240. endforeach (_op ${_raw_op_init})
  241. string (REPLACE ";" "\n" _op_init "${_op_init}")
  242. string_unescape (GRDMATH_OPERATOR_INIT "${_op_init}" NOESCAPE_SEMICOLON)
  243. configure_file (${GMT_SRC}/src/grdmath.h.in grdmath.h)
  244. # grdmath_op.h
  245. list_regex_replace (
  246. "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  247. "\t\"\\\\1\",\t/* id = OP_NUM */"
  248. _raw_op_array ${_raw_op_descriptions}
  249. MATCHES_ONLY)
  250. set (_op_array)
  251. set (_opnum 0)
  252. foreach (_op ${_raw_op_array})
  253. string (REPLACE "OP_NUM" "${_opnum}" _op ${_op})
  254. list (APPEND _op_array ${_op})
  255. math (EXPR _opnum "${_opnum} + 1")
  256. endforeach (_op ${_raw_op_array})
  257. string (REPLACE ";" "\n" GRDMATH_OPERATOR_ARRAY "${_op_array}")
  258. configure_file (${GMT_SRC}/src/grdmath_op.h.in grdmath_op.h)
  259. # grdmath_explain.h
  260. list_regex_replace (
  261. "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  262. "\t\t\"\t\\\\1PADDING\\\\2 \\\\3 \\\\4#Bn\""
  263. _op_explain ${_raw_op_descriptions}
  264. MATCHES_ONLY)
  265. set (_padded_lines)
  266. foreach (_line ${_op_explain})
  267. string_pad (_line 15 PADDING)
  268. list (APPEND _padded_lines ${_line})
  269. endforeach (_line ${_op_explain})
  270. string (REPLACE ";" "\n" _op_explain "${_padded_lines}")
  271. string_unescape (GRDMATH_OPERATOR_EXPLAIN "${_op_explain}" NOESCAPE_SEMICOLON)
  272. configure_file (${GMT_SRC}/src/grdmath_explain.h.in grdmath_explain.h)
  273. # # grdmath_man.i
  274. # list_regex_replace (
  275. # "^[^:]+:[ ]+([^ ]+)[ ]+([0-9]+)[ ]+([0-9]+)[ ]+(.+)[.][ *]+/.*"
  276. # "#BfB\\\\1#BfP\t\\\\2 \\\\3\t\\\\4"
  277. # _op_man ${_raw_op_descriptions}
  278. # MATCHES_ONLY)
  279. # string (REPLACE ";" "\n" _op_man "${_op_man}")
  280. # string_unescape (_op_man "${_op_man}" NOESCAPE_SEMICOLON)
  281. # set (_op_man "Choose among the following ${GRDMATH_N_OPERATORS} operators.\n"
  282. # "\"args\" are the number of input and output arguments.\n"
  283. # ".TS\nl l l .\nOperator\targs\tReturns\n${_op_man}\n.TE\n")
  284. # file (WRITE grdmath_man.i ${_op_man})
  285. endmacro (gen_grd_math_h)
  286. # Get something done
  287. if (GENERATE_COMMAND STREQUAL gen_gmt_datums_h)
  288. gen_gmt_datums_h ()
  289. elseif (GENERATE_COMMAND STREQUAL gen_gmt_colors_h)
  290. gen_gmt_colors_h ()
  291. elseif (GENERATE_COMMAND STREQUAL gen_ps_font_info)
  292. gen_ps_font_info ()
  293. elseif (GENERATE_COMMAND STREQUAL gen_gmt_ellipsoids)
  294. gen_gmt_ellipsoids ()
  295. elseif (GENERATE_COMMAND STREQUAL gen_gmt_keywords_h)
  296. gen_gmt_keywords_h ()
  297. elseif (GENERATE_COMMAND STREQUAL gen_gmt_dimensions_h)
  298. gen_gmt_dimensions_h ()
  299. elseif (GENERATE_COMMAND STREQUAL gen_gmt_math_h)
  300. gen_gmt_math_h ()
  301. elseif (GENERATE_COMMAND STREQUAL gen_grd_math_h)
  302. gen_grd_math_h ()
  303. elseif (DEFINED GENERATE_COMMAND)
  304. message (SEND_ERROR "Unknown command: ${GENERATE_COMMAND}")
  305. endif (GENERATE_COMMAND STREQUAL gen_gmt_datums_h)
  306. # vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...