aboutsummaryrefslogtreecommitdiff
path: root/Makefile.target
blob: 67d355ca35b39df5ec23ab64dd52c14ed65ed5d4 (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
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# This file is included several times to build target-specific
# modules for the Android emulator. It will be called several times
# for arm, x86 and mips
#

ifndef EMULATOR_TARGET_ARCH
$(error EMULATOR_TARGET_ARCH is not defined!)
endif

EMULATOR_TARGET_CPU := $(EMULATOR_TARGET_ARCH)
ifeq ($(EMULATOR_TARGET_CPU),x86)
  EMULATOR_TARGET_CPU := i386
endif

##############################################################################
##############################################################################
###
###  emulator-target-$CPU: target-specific emulation code.
###
###  Used by both the core and standalone programs.
###

# Common compiler flags for all target-dependent libraries
EMULATOR_TARGET_CFLAGS := \
    -I$(LOCAL_PATH)/android/config/target-$(EMULATOR_TARGET_ARCH) \
    -I$(LOCAL_PATH)/target-$(EMULATOR_TARGET_CPU) \
    -I$(LOCAL_PATH)/fpu \
    -DNEED_CPU_H

TCG_TARGET := $(HOST_ARCH)
ifeq ($(HOST_ARCH),x86)
  TCG_TARGET := i386
endif
ifeq ($(HOST_ARCH),x86_64)
  TCG_TARGET := i386
endif

EMULATOR_TARGET_CFLAGS += \
    -I$(LOCAL_PATH)/tcg \
    -I$(LOCAL_PATH)/tcg/$(TCG_TARGET) \
    -DTARGET_ARCH=\"$(EMULATOR_TARGET_ARCH)\"


common_LOCAL_CFLAGS =
common_LOCAL_SRC_FILES =

common_LOCAL_CFLAGS += -I$(GLIB_INCLUDE_DIR) $(EMULATOR_COMMON_CFLAGS)

# The following is to ensure that "config.h" will map to a target-specific
# configuration file header.
common_LOCAL_CFLAGS += $(EMULATOR_TARGET_CFLAGS)

common_LOCAL_SRC_FILES += \
    tcg/optimize.c \
    tcg/tcg.c \
    tcg-runtime.c \
    util/bitops.c \
    util/host-utils.c \

##############################################################################
# Emulated hardware devices.
#

HW_SOURCES := \
    core/irq.c \
    core/qdev.c \
    core/sysbus.c \
    core/dma.c \
    android/goldfish/audio.c \
    android/goldfish/device.c \
    android/goldfish/events_device.c \
    android/goldfish/fb.c \
    android/goldfish/battery.c \
    android/goldfish/mmc.c   \
    android/goldfish/nand.c \
    android/goldfish/pipe.c \
    android/goldfish/tty.c \
    android/goldfish/vmem.c \
    android/goldfish/trace.c \
    android/goldfish/profile.c \
    pci/pci.c \
    watchdog/watchdog.c


ifeq ($(EMULATOR_TARGET_ARCH),arm)
HW_SOURCES += \
    android/android_arm.c \
    arm/pic.c \
    arm/boot.c \
    android/goldfish/interrupt.c \
    android/goldfish/timer.c

# The following sources must be compiled with the final executables
# because they contain device_init() or machine_init() statements.
HW_OBJ_SOURCES := hw/net/smc91c111.c
HW_OBJ_CFLAGS  := $(EMULATOR_TARGET_CFLAGS)

common_LOCAL_SRC_FILES += disas/arm.c

# smc91c111.c requires <zlib.h>
common_LOCAL_CFLAGS += $(ZLIB_CFLAGS)
endif

# required to ensure we properly initialize virtual audio hardware
common_LOCAL_CFLAGS += -DHAS_AUDIO

ifeq ($(EMULATOR_TARGET_ARCH),x86)
HW_SOURCES += \
    intc/apic.c \
    intc/i8259.c \
    timer/mc146818rtc.c \
    pci-host/piix.c \
    timer/i8254.c \
    input/pckbd.c \
    intc/ioapic.c \
    input/ps2.c \
    i386/smbios.c \
    nvram/fw_cfg.c

# The following sources must be compiled with the final executables
# because they contain device_init() or machine_init() statements.
HW_OBJ_SOURCES := \
    hw/net/ne2000.c \
    hw/i386/pc.c

HW_OBJ_CFLAGS  := $(EMULATOR_TARGET_CFLAGS)

endif

ifeq ($(EMULATOR_TARGET_ARCH),mips)
HW_SOURCES += \
    android/android_mips.c \
    mips/mips_pic.c \
    android/goldfish/interrupt.c \
    android/goldfish/timer.c \
    mips/cputimer.c \
    mips/mips_int.c

# The following sources must be compiled with the final executables
# because they contain device_init() or machine_init() statements.
HW_OBJ_SOURCES := hw/net/smc91c111.c
HW_OBJ_CFLAGS  := $(EMULATOR_TARGET_CFLAGS)

common_LOCAL_SRC_FILES += disas/mips.c

# smc91c111.c requires <zlib.h>
LOCAL_CFLAGS += $(ZLIB_CFLAGS)
ifeq ($(ARCH_HAS_BIGENDIAN),true)
  LOCAL_CFLAGS += -DTARGET_WORDS_BIGENDIAN
endif

endif
common_LOCAL_SRC_FILES += $(HW_SOURCES:%=hw/%)

common_LOCAL_SRC_FILES += \
    backends/msmouse.c \
    cpu-exec.c  \
    cputlb.c \
    exec.c \
    main-loop.c \
    memory-android.c \
    monitor-android.c \
    translate-all.c \
    code-profile.c \

##############################################################################
# CPU-specific emulation.
#
common_LOCAL_CFLAGS += -fno-PIC -fomit-frame-pointer -Wno-sign-compare

ifeq ($(HOST_ARCH),ppc)
    common_LOCAL_CFLAGS += -D__powerpc__
endif

ifeq ($(EMULATOR_TARGET_ARCH),arm)
common_LOCAL_SRC_FILES += \
    target-arm/arm-semi.c \
    target-arm/op_helper.c \
    target-arm/iwmmxt_helper.c \
    target-arm/neon_helper.c \
    target-arm/helper.c \
    target-arm/translate.c \
    target-arm/machine.c \
    hw/arm/armv7m.c \
    hw/arm/armv7m_nvic.c
endif  # EMULATOR_TARGET_ARCH == arm

ifeq ($(EMULATOR_TARGET_ARCH), x86)
common_LOCAL_SRC_FILES += \
    target-i386/cc_helper.c \
    target-i386/excp_helper.c \
    target-i386/fpu_helper.c \
    target-i386/int_helper.c \
    target-i386/mem_helper.c \
    target-i386/misc_helper.c \
    target-i386/seg_helper.c \
    target-i386/smm_helper.c \
    target-i386/svm_helper.c \
    target-i386/helper.c \
    target-i386/translate.c \
    target-i386/machine.c \

ifeq ($(HOST_OS),darwin)
common_LOCAL_SRC_FILES += \
      target-i386/hax-all.c       \
      target-i386/hax-darwin.c
endif

ifeq ($(HOST_OS),windows)
common_LOCAL_SRC_FILES += \
      target-i386/hax-all.c       \
      target-i386/hax-windows.c
endif
endif  # EMULATOR_TARGET_ARCH == x86

ifeq ($(EMULATOR_TARGET_ARCH), mips)
common_LOCAL_SRC_FILES += \
    target-mips/op_helper.c \
    target-mips/helper.c \
    target-mips/translate.c \
    target-mips/machine.c
endif  # EMULATOR_TARGET_ARCH == mips

common_LOCAL_SRC_FILES += fpu/softfloat.c

# compile KVM only if target is x86 on x86 Linux
QEMU_KVM_TAG := $(QEMU_HOST_TAG)-$(EMULATOR_TARGET_ARCH)
QEMU_DO_KVM := $(if $(filter linux-x86-x86 linux-x86_64-x86,$(QEMU_KVM_TAG)),true,false)
ifeq ($(QEMU_DO_KVM),true)
    common_LOCAL_SRC_FILES += \
        target-i386/kvm.c \
        target-i386/kvm-gs-restore.c \
        kvm-all.c \
        kvm-android.c
endif

common_LOCAL_SRC_FILES += \
    cpus.c \
    arch_init.c

# What a mess, os-posix.c depends on the exact values of options
# which are target specific.
ifeq ($(HOST_OS),windows)
    common_LOCAL_SRC_FILES += os-win32.c util/oslib-win32.c
else
    common_LOCAL_SRC_FILES += os-posix.c util/oslib-posix.c
endif


## one for 32-bit
$(call start-emulator-library, emulator-target-$(EMULATOR_TARGET_CPU))
LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
$(call gen-hw-config-defs)
$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c)
$(call end-emulator-library)

$(call start-emulator64-library, emulator64-target-$(EMULATOR_TARGET_CPU))
LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
$(call gen-hw-config-defs)
$(call gen-hx-header,qemu-options.hx,qemu-options.def,os-posix.c os-win32.c)
$(call end-emulator-library)

##############################################################################
##############################################################################
###
###  emulator-$ARCH: Standalone emulator program
###
###

common_LOCAL_LDFLAGS =
common_LOCAL_LDFLAGS_64 =
common_LOCAL_LDLIBS =
common_LOCAL_CFLAGS =
common_LOCAL_SRC_FILES =

common_LOCAL_LDFLAGS += \
    $(EMULATOR_LIBUI_LDFLAGS)

common_LOCAL_LDFLAGS_64 += \
    $(EMULATOR_LIBUI_LDFLAGS_64)

common_LOCAL_LDLIBS += \
    $(EMULATOR_COMMON_LDLIBS) \
    $(EMULATOR_LIBQEMU_LDLIBS) \
    $(EMULATOR_LIBUI_LDLIBS) \
    $(ELFF_LDLIBS)

common_LOCAL_CFLAGS += \
    $(EMULATOR_TARGET_CFLAGS) \
    $(EMULATOR_COMMON_CFLAGS) \
    $(EMULATOR_LIBQEMU_CFLAGS) \
    $(EMULATOR_LIBUI_CFLAGS)

common_LOCAL_SRC_FILES := \
    audio/audio.c \
    disas.c \
    dma-helpers.c \
    gdbstub.c \
    qemu-timer.c \
    log-rotate-android.c \
    vl-android.c \
    android/cmdline-option.c \
    android/console.c \
    android/cpu_accelerator.cpp \
    android/display.c \
    android/display-core.c \
    android/help.c \
    android/main-common.c \
    android/main-common-ui.c \
    android/main.c \
    android/opengles.c \
    android/user-events-qemu.c \
    hw/core/loader.c \
    util/bitmap.c \
    util/bitops.c \
    ui/keymaps.c \
    util/qemu-timer-common.c \
    util/iov.c \

# The following files cannot be in static libraries because they contain
# constructor functions that are otherwise stripped by the final linker
common_LOCAL_SRC_FILES += $(HW_OBJ_SOURCES)
common_LOCAL_CFLAGS    += $(HW_OBJ_CFLAGS)

common_LOCAL_SRC_FILES += $(BLOCK_SOURCES)
common_LOCAL_CFLAGS    += $(BLOCK_CFLAGS)

common_LOCAL_LDLIBS += -lstdc++

## one for 32-bit
$(call start-emulator-program, emulator-$(EMULATOR_TARGET_ARCH))
LOCAL_STATIC_LIBRARIES += \
    emulator-libui \
    emulator-libqemu \
    emulator-target-$(EMULATOR_TARGET_CPU) \
    emulator-libjpeg \
    libandroid-wear-agent \
    emulator-common \
    emulator-libext4_utils \
    emulator-libsparse \
    emulator-libselinux \
    emulator-zlib \
    $(EMULATOR_LIBUI_STATIC_LIBRARIES)

LOCAL_LDLIBS += $(common_LOCAL_LDLIBS)
LOCAL_LDFLAGS += $(common_LOCAL_LDFLAGS)
LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
$(call gen-hw-config-defs)

ifeq ($(HOST_OS),windows)
  $(eval $(call insert-windows-icon))
endif

$(call end-emulator-program)


$(call start-emulator64-program, emulator64-$(EMULATOR_TARGET_ARCH))
LOCAL_STATIC_LIBRARIES += \
    emulator64-libui \
    emulator64-libqemu \
    emulator64-target-$(EMULATOR_TARGET_CPU) \
    emulator64-libjpeg \
    lib64android-wear-agent \
    emulator64-common \
    emulator64-libext4_utils \
    emulator64-libsparse \
    emulator64-libselinux \
    emulator64-zlib \
    $(EMULATOR_LIBUI_STATIC_LIBRARIES_64)

LOCAL_LDLIBS += $(common_LOCAL_LDLIBS)
LOCAL_LDFLAGS += $(common_LOCAL_LDFLAGS_64)
LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
$(call gen-hx-header,qemu-options.hx,qemu-options.def,vl-android.c qemu-options.h)
$(call gen-hw-config-defs)

ifeq ($(HOST_OS),windows)
  $(eval $(call insert-windows-icon))
  # Special exception for Windows: -lmingw32 must appear before libSDLmain
  # on the link command-line, because it depends on _WinMain@16 which is
  # exported by the latter.
  LOCAL_LDFLAGS += -lmingw32
endif

$(call end-emulator-program)