summaryrefslogtreecommitdiff
path: root/tests/aslts/Makefile.def
blob: 720eedaea77f689023459787a23df43278656891 (plain)
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
# Makefile.def

# Set variables:
#
# for install:
#    ASL - path name of iASL compiler
#
# Internal variables to be pre-defined:
#   TOP    - relative name of aslts directory
#   AMLMOD - name of resulting AML module (DefinitionBlock->AMLFileName)
#            without .aml extension.

# Two level hierarchy of compilation:
# optimization & (32/64 mode).
#
#  Directory |           Flags
#            |---------------------------
#            | optimization |  32/64 mode
# ---------------------------------------
#    opt/32  |              |  -r 1
#    opt/64  |              |  -r 2
#   nopt/32  |  -oa         |  -r 1
#   nopt/64  |  -oa         |  -r 2

ifndef ASLTS_AMLDIR
ifeq ("$(ASLTS_MODE)", "n32")
	ASLTS_AMLDIR=nopt/32
	ASLTS_ASLFLAGS="-oa -r 1"
endif
ifeq ("$(ASLTS_MODE)", "n64")
	ASLTS_AMLDIR=nopt/64
	ASLTS_ASLFLAGS="-oa -r 2"
endif
ifeq ("$(ASLTS_MODE)", "o32")
	ASLTS_AMLDIR=opt/32
	ASLTS_ASLFLAGS="-r 1"
endif
ifeq ("$(ASLTS_MODE)", "o64")
	ASLTS_AMLDIR=opt/64
	ASLTS_ASLFLAGS="-r 2"
endif
ifeq ("$(ASLTS_MODE)", "aslminus")
	ASLTS_AMLDIR=aslminus/
	ASLTS_ASLFLAGS="-oa -r 2"
endif
ifeq ("$(ASLTS_MODE)", "aslplus")
	ASLTS_AMLDIR=aslplus/
	ASLTS_ASLFLAGS="-oa -r 2"
endif
ifeq ("$(ASLTS_MODE)", "aslconvert")
	ASLTS_AMLDIR=aslconvert/
	ASLTS_ASLFLAGS="-oa -r 2"
endif

endif
ASLTS_VER ?= $(ASLTS_VER)

COMMON_NO_OUTPUT_ASL_FLAGS= "-of -cr -vs"
COMMON_ASL_FLAGS= $(COMMON_NO_OUTPUT_ASL_FLAGS)" -l -sc -sa -ic -ta -ts -so -lm -ln -ls -li"

COMPILER_LOG="$(TOP)/tmp/aml/$(ASLTS_VER)/compile.txt"
COMPILER_ERROR_LOG="$(TOP)/tmp/aml/$(ASLTS_VER)/error.txt"

# Create general directory

GDMODE=775
INST= install
INST.dir= $(INST) -d -m $(GDMODE) $@
ASLMOD= MAIN

# Empty all (specify 'all' target, if needed, before Makefile.def include)

empty_all:	FORCE

# Rule to create directories located into aslts/tmp/aml;

$(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR):
	@$(INST.dir)

# Make-install one particular Test Case for all modes

install_all_modes_of_test_case:	$(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR)
	@rval=0; \
	if [ -f "$(ASL)" ]; then \
		dd=`pwd`; \
		echo "---- Test path: $$dd" >> $(COMPILER_LOG); \
		echo "---- Test path: $$dd" >> $(COMPILER_ERROR_LOG); \
		>&2 echo "Test path: $$dd"; \
		echo "---- Test type: $(ASLTS_AMLDIR)   (Flags $(COMMON_ASL_FLAGS) $(ASLTS_ASLFLAGS) $(ADD_ASLFLAGS))" >> $(COMPILER_LOG); \
		echo "---- Test type: $(ASLTS_AMLDIR)   (Flags $(COMMON_ASL_FLAGS) $(ASLTS_ASLFLAGS) $(ADD_ASLFLAGS))" >> $(COMPILER_ERROR_LOG); \
		for j in ${AMLMOD}; do \
			rm -f $$j.aml; \
		done; \
		for j in ${ASLMOD} $(ASLMODADD); do \
			echo "---- Compile: $$j.asl" >> $(COMPILER_LOG); \
			>&2 printf "%-18s" "    Type: $(ASLTS_AMLDIR) "; \
			>&2 printf  "Compile"; \
			"$(ASL)" $(ASLTS_ASLFLAGS) "$(COMMON_ASL_FLAGS)" $(ADD_ASLFLAGS) $$j.asl >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); \
			ret=$$?; \
			echo "" >> $(COMPILER_LOG); \
			>&2 printf " => Removing files"; \
			rm $$j.asm; \
			rm $$j.c; \
			rm $$j.h; \
			rm $$j.i; \
			rm $$j.hex; \
			rm $$j.lst; \
			rm $$j.map; \
			rm $$j.nsp; \
			rm $$j.offset.h; \
			rm $$j.src; \
			>&2 printf " => Done "; \
			if [ $$ret != 0 ]; then \
				rval=1; \
				>&2 echo "**** Unexpected iASL failure in $$dd/$$j.asl!"; \
			fi; \
		done; \
		>&2 echo ""; \
		if [ $$ret != 0 ]; then break; fi; \
		for j in ${AMLMOD}; do \
			ls -l $$j.aml >> $(COMPILER_LOG); \
			echo "---- Move: $$j.aml $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR)" >> $(COMPILER_LOG); \
			mv $$j.aml $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR); \
			ret=$$?; \
			if [ $$ret != 0 ]; then rval=2; echo "**** mv failed!" >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); break; fi; \
		done; \
	else \
		echo "Bad iASL 0: <$(ASL)> does not exist"; \
		exit 1; \
	fi;

# Make-install one particular Test Case for all modes.

install_test_case:
	@if [ ! -f "$(ASL)" ]; then \
		echo "Bad iASL 1: <$(ASL)> does not exist"; exit 1; \
	fi; \
	if [ "$(ASLTS_MODE)" = "aslminus" ]; then \
		make install_disasm_test_case DISASM_FLAG="-dl" ASLTS_MODE=$(ASLTS_MODE) ASLTS_VER=$(ASLTS_VER); \
	elif [ "$(ASLTS_MODE)" = "aslplus" ]; then \
		make install_disasm_test_case DISASM_FLAG="-d" ASLTS_MODE=$(ASLTS_MODE) ASLTS_VER=$(ASLTS_VER); \
	elif [ "$(ASLTS_MODE)" = "aslconvert" ]; then \
		make install_converter_test_case ASLTS_MODE=$(ASLTS_MODE) ASLTS_VER=$(ASLTS_VER); \
	else \
		make install_all_modes_of_test_case ASLTS_MODE=$(ASLTS_MODE) ASLTS_VER=$(ASLTS_VER); \
	fi


TEST_SEQUENCE_ASL_FLAGS="$(ASLTS_ASLFLAGS) $(COMMON_NO_OUTPUT_ASL_FLAGS)"

disasm_test_compile: $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR)
	@rval=0; \
	for j in ${ASLMOD} $(ASLMODADD); do \
		for k in ${AMLMOD}; do \
			>&2 printf  " => Compile with externals in place"; \
			"$(ASL)" -p $$k-extInPlace -oE $(ADD_ASLFLAGS) $(TEST_SEQUENCE_ASL_FLAGS) $$j.asl >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); \
			ret=$$?; \
			if [ $$ret != 0 ]; then \
				rval=2; \
				>&2 printf " [[ Error: compiling $$k.aml with externals in place failed ]]\n"; \
				>&2 printf "          Flags used: -p $$k-extInPlace -oE $(ADD_ASLFLAGS) $(TEST_SEQUENCE_ASL_FLAGS)\n\n"; \
			fi; \
		done; \
	done; \
	if [ $$rval != 0 ]; then exit 1; fi

disasm_test_disassemble: disasm_test_compile
	@rval=0; \
	for k in ${AMLMOD}; do \
		>&2 printf " => Disassemble"; \
		"$(ASL)" -p $$k -oe -od $(COMMON_NO_OUTPUT_ASL_FLAGS) $(ADD_ASLFLAGS) $(DISASM_FLAG) $$k-extInPlace.aml >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); \
		ret=$$?; \
		if [ $$ret != 0 ]; then \
			retval=2; \
			>&2 printf " [[ Error: disassembly of $$k-extInPlace.aml failed ]]\n"; \
			>&2 printf "          Flags used: -oe -od $(COMMON_NO_OUTPUT_ASL_FLAGS) $(ADD_ASLFLAGS) $(DISASM_FLAG)\n\n"; \
		fi; \
	done; \
	if [ $$rval != 0 ]; then exit 1; fi

disasm_test_recompile: disasm_test_disassemble
	@rval=0; \
	for k in ${AMLMOD}; do \
		>&2 printf " => Recompile\n"; \
		"$(ASL)" $(ADD_ASLFLAGS) $(TEST_SEQUENCE_ASL_FLAGS) $$k.dsl >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); \
		ret=$$?; \
		if [ $$ret != 0 ]; then \
			rval=2; \
			>&2 printf " [[ Error: re-compilation of $$k-$$l.dsl failed]]\n"; \
			>&2 printf "          Flags used: $(ADD_ASLFLAGS) $(TEST_SEQUENCE_ASL_FLAGS)\n\n"; \
		fi; \
		rm $$k.dsl; \
		echo "---- Move: $$k.aml $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR)" >> $(COMPILER_LOG); \
		mv $$k.aml $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR); \
		ret=$$?; \
		if [ $$ret != 0 ]; then rval=2; echo "**** mv failed!" >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); break; fi; \
	done; \

install_disasm_test_case:
	if [ "x$(ADD_ASLFLAGS)" != "x-f" ]; then \
		make disasm_test_recompile; \
		make clean; \
	else \
		>&2 echo "Skipping disassembler test for this test case"; \
	fi;

converter_test_convert: $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR)
	@rval=0; \
	for j in ${ASLMOD} $(ASLMODADD); do \
		>&2 printf  "  Convert"; \
		"$(ASL)" $(ADD_ASLFLAGS) -cr -ca $$j.asl >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); \
		ret=$$?; \
		if [ $$ret != 0 ]; then \
			rval=2; \
			>&2 printf " [[ Error: conversion of $$j.asl failed ]]\n"; \
			>&2 printf "          Flags used: -ca\n\n"; \
		fi; \
	done; \
	if [ $$rval != 0 ]; then exit 1; fi

converter_test_recompile: converter_test_convert
	@rval=0; \
	for j in ${ASLMOD} $(ASLMODADD); do \
		for k in ${AMLMOD}; do \
			>&2 printf " => Recompile"; \
			"$(ASL)" $(ADD_ASLFLAGS) $(TEST_SEQUENCE_ASL_FLAGS) -p $$k $$j.dsl >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); \
			ret=$$?; \
			if [ $$ret != 0 ]; then \
				rval=2; \
				>&2 printf " [[ Error: re-compilation of $$j.dsl failed]]\n"; \
				>&2 printf "          Flags used: $(ADD_ASLFLAGS) $(TEST_SEQUENCE_ASL_FLAGS) -p $$k\n\n"; \
			else \
				>&2 printf " => Done\n"; \
			fi; \
			echo "---- Move: $$k.aml $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR)" >> $(COMPILER_LOG); \
			mv $$k.aml $(TOP)/tmp/aml/$(ASLTS_VER)/$(ASLTS_AMLDIR); \
			ret=$$?; \
			if [ $$ret != 0 ]; then rval=2; echo "**** mv failed!" >> $(COMPILER_LOG) 2>> $(COMPILER_ERROR_LOG); break; fi; \
		done; \
	done; \

install_converter_test_case:
	if [ "x$(ADD_ASLFLAGS)" != "x-f" ]; then \
		make converter_test_recompile; \
		make clean; \
	else \
		>&2 echo "Skipping converter test for this test case"; \
	fi;



# Compile one particular Test Case for all modes.
# No moving results to aslts/tmp/aml directory.

compile_test_case:
	@rval=0; \

	echo "Compile_test_case"

	if [ -f "$(ASL)" ]; then \
		for j in ${ASLMOD} $(ASLMODADD); do \
			"$(ASL)" $(ASLTS_ASLFLAGS) $(ADD_ASLFLAGS) $$j.asl; \
			ret=$$?; \
			if [ $$ret != 0 ]; then rval=1; echo "**** Unexpected iASL failure!"; exit 1; fi; \
		done; \
	else \
		echo "Bad iASL 4: <$(ASL)> does not exist"; \
		rval=1; \
	fi; \
	if [ $$rval != 0 ]; then exit 1; fi