@@ -15,10 +15,33 @@ endfunction ()
15
15
# Reads a Makefile into CMake vars.
16
16
macro (ParseMakefileVars MAKEFILE_IN )
17
17
message (STATUS "Reading vars from ${MAKEFILE_IN} ..." )
18
+ set (IfElse 0 )
19
+ set (ElseSeen 0 )
18
20
file (STRINGS ${MAKEFILE_IN} makefile_contents )
19
21
foreach (makefile_line ${makefile_contents} )
22
+ #message(STATUS "parsing ${makefile_line}")
23
+ if (${IfElse} GREATER 0 )
24
+ string (REGEX MATCH "endif[ \t ]*" line_match "${makefile_line} " )
25
+ if (NOT "${line_match} " STREQUAL "" )
26
+ # message(STATUS "ENDIF ${makefile_line}")
27
+ set (IfElse 0 )
28
+ set (ElseSeen 0 )
29
+ continue ()
30
+ endif ()
31
+ string (REGEX MATCH "else[ \t ]*" line_match "${makefile_line} " )
32
+ if (NOT "${line_match} " STREQUAL "" )
33
+ # message(STATUS "ELSE ${makefile_line}")
34
+ set (ElseSeen 1 )
35
+ continue ()
36
+ endif ()
37
+ if ( (${IfElse} EQUAL 2 AND ${ElseSeen} EQUAL 0 ) OR ( ${IfElse} EQUAL 1 AND ${ElseSeen} EQUAL 1 ))
38
+ # message(STATUS "skipping ${makefile_line}")
39
+ continue ()
40
+ endif ()
41
+ endif ()
20
42
string (REGEX MATCH "([0-9_a-zA-Z]+)[ \t ]*=[ \t ]*(.+)$" line_match "${makefile_line} " )
21
43
if (NOT "${line_match} " STREQUAL "" )
44
+ #message(STATUS "match on ${line_match}")
22
45
set (var_name ${CMAKE_MATCH_1} )
23
46
set (var_value ${CMAKE_MATCH_2} )
24
47
# check for Makefile variables in the string, e.g. $(TSUFFIX)
@@ -33,7 +56,31 @@ macro(ParseMakefileVars MAKEFILE_IN)
33
56
else ()
34
57
string (REGEX MATCH "include \\ $\\ (KERNELDIR\\ )/(.+)$" line_match "${makefile_line} " )
35
58
if (NOT "${line_match} " STREQUAL "" )
59
+ #message(STATUS "match on include ${line_match}")
36
60
ParseMakefileVars (${KERNELDIR} /${CMAKE_MATCH_1} )
61
+ else ()
62
+ # message(STATUS "unmatched line ${line_match}")
63
+ string (REGEX MATCH "ifeq \\ (\\ $\\ (([_A-Z]+)\\ ),[ \t ]*([0-9_A-Z]+)\\ )" line_match "${makefile_line} " )
64
+ if (NOT "${line_match} " STREQUAL "" )
65
+ # message(STATUS "IFEQ: ${line_match} first: ${CMAKE_MATCH_1} second: ${CMAKE_MATCH_2}")
66
+ if (${${CMAKE_MATCH_1}} STREQUAL ${CMAKE_MATCH_2} )
67
+ # message (STATUS "condition is true")
68
+ set (IfElse 1 )
69
+ else ()
70
+ set (IfElse 2 )
71
+ endif ()
72
+ else ()
73
+ string (REGEX MATCH "ifneq \\ (\\ $\\ (([_A-Z]+)\\ ),[ \t ]*([0-9_A-Z]+)\\ )" line_match "${makefile_line} " )
74
+ if (NOT "${line_match} " STREQUAL "" )
75
+ # message(STATUS "IFNEQ: ${line_match} first: ${CMAKE_MATCH_1} second: ${CMAKE_MATCH_2}")
76
+ if (NOT ( ${${CMAKE_MATCH_1}} STREQUAL ${CMAKE_MATCH_2} ))
77
+ # message (STATUS "condition is true")
78
+ set (IfElse 1 )
79
+ else ()
80
+ set (IfElse 2 )
81
+ endif ()
82
+ endif ()
83
+ endif ()
37
84
endif ()
38
85
endif ()
39
86
endforeach ()
0 commit comments