|
| 1 | +# |
| 2 | +# TinyEMU |
| 3 | +# |
| 4 | +# Copyright (c) 2016-2018 Fabrice Bellard |
| 5 | +# |
| 6 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | +# of this software and associated documentation files (the "Software"), to deal |
| 8 | +# in the Software without restriction, including without limitation the rights |
| 9 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | +# copies of the Software, and to permit persons to whom the Software is |
| 11 | +# furnished to do so, subject to the following conditions: |
| 12 | +# |
| 13 | +# The above copyright notice and this permission notice shall be included in |
| 14 | +# all copies or substantial portions of the Software. |
| 15 | +# |
| 16 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | +# THE SOFTWARE. |
| 23 | +# |
| 24 | + |
| 25 | +# if set, network filesystem is enabled. libcurl and libcrypto |
| 26 | +# (openssl) must be installed. |
| 27 | +CONFIG_FS_NET=y |
| 28 | +# SDL support (optional) |
| 29 | +CONFIG_SDL=y |
| 30 | +# if set, compile the 128 bit emulator. Note: the 128 bit target does |
| 31 | +# not compile if gcc does not support the int128 type (32 bit hosts). |
| 32 | +CONFIG_INT128=y |
| 33 | +# build x86 emulator |
| 34 | +CONFIG_X86EMU=y |
| 35 | +# win32 build (not usable yet) |
| 36 | +#CONFIG_WIN32=y |
| 37 | +# user space network redirector |
| 38 | +CONFIG_SLIRP=y |
| 39 | + |
| 40 | +ifdef CONFIG_WIN32 |
| 41 | +CROSS_PREFIX=i686-w64-mingw32- |
| 42 | +EXE=.exe |
| 43 | +else |
| 44 | +CROSS_PREFIX= |
| 45 | +EXE= |
| 46 | +endif |
| 47 | +CC=$(CROSS_PREFIX)gcc |
| 48 | +STRIP=$(CROSS_PREFIX)strip |
| 49 | +CFLAGS=-O2 -Wall -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD |
| 50 | +CFLAGS+=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat VERSION)\" |
| 51 | +LDFLAGS= |
| 52 | + |
| 53 | +bindir=/usr/local/bin |
| 54 | +INSTALL=install |
| 55 | + |
| 56 | +PROGS+= temu$(EXE) |
| 57 | +ifndef CONFIG_WIN32 |
| 58 | +ifdef CONFIG_FS_NET |
| 59 | +PROGS+=build_filelist splitimg |
| 60 | +endif |
| 61 | +endif |
| 62 | + |
| 63 | +all: $(PROGS) |
| 64 | + |
| 65 | +EMU_OBJS:=virtio.o pci.o fs.o cutils.o iomem.o simplefb.o \ |
| 66 | + json.o machine.o temu.o |
| 67 | + |
| 68 | +ifdef CONFIG_SLIRP |
| 69 | +CFLAGS+=-DCONFIG_SLIRP |
| 70 | +EMU_OBJS+=$(addprefix slirp/, bootp.o ip_icmp.o mbuf.o slirp.o tcp_output.o cksum.o ip_input.o misc.o socket.o tcp_subr.o udp.o if.o ip_output.o sbuf.o tcp_input.o tcp_timer.o) |
| 71 | +endif |
| 72 | + |
| 73 | +ifndef CONFIG_WIN32 |
| 74 | +EMU_OBJS+=fs_disk.o |
| 75 | +EMU_LIBS=-lrt |
| 76 | +endif |
| 77 | +ifdef CONFIG_FS_NET |
| 78 | +CFLAGS+=-DCONFIG_FS_NET |
| 79 | +EMU_OBJS+=fs_net.o fs_wget.o fs_utils.o block_net.o |
| 80 | +EMU_LIBS+=-lcurl -lcrypto |
| 81 | +ifdef CONFIG_WIN32 |
| 82 | +EMU_LIBS+=-lwsock32 |
| 83 | +endif # CONFIG_WIN32 |
| 84 | +endif # CONFIG_FS_NET |
| 85 | +ifdef CONFIG_SDL |
| 86 | +EMU_LIBS+=-lSDL |
| 87 | +EMU_OBJS+=sdl.o |
| 88 | +CFLAGS+=-DCONFIG_SDL |
| 89 | +ifdef CONFIG_WIN32 |
| 90 | +LDFLAGS+=-mwindows |
| 91 | +endif |
| 92 | +endif |
| 93 | + |
| 94 | +EMU_OBJS+=riscv_machine.o softfp.o riscv_cpu32.o riscv_cpu64.o |
| 95 | +ifdef CONFIG_INT128 |
| 96 | +CFLAGS+=-DCONFIG_RISCV_MAX_XLEN=128 |
| 97 | +EMU_OBJS+=riscv_cpu128.o |
| 98 | +else |
| 99 | +CFLAGS+=-DCONFIG_RISCV_MAX_XLEN=64 |
| 100 | +endif |
| 101 | +ifdef CONFIG_X86EMU |
| 102 | +EMU_OBJS+=x86_cpu.o x86_machine.o ide.o ps2.o vmmouse.o pckbd.o vga.o |
| 103 | +endif |
| 104 | + |
| 105 | +temu$(EXE): $(EMU_OBJS) |
| 106 | + $(CC) $(LDFLAGS) -o $@ $^ $(EMU_LIBS) |
| 107 | + |
| 108 | +riscv_cpu32.o: riscv_cpu.c |
| 109 | + $(CC) $(CFLAGS) -DMAX_XLEN=32 -c -o $@ $< |
| 110 | + |
| 111 | +riscv_cpu64.o: riscv_cpu.c |
| 112 | + $(CC) $(CFLAGS) -DMAX_XLEN=64 -c -o $@ $< |
| 113 | + |
| 114 | +riscv_cpu128.o: riscv_cpu.c |
| 115 | + $(CC) $(CFLAGS) -DMAX_XLEN=128 -c -o $@ $< |
| 116 | + |
| 117 | +build_filelist: build_filelist.o fs_utils.o cutils.o |
| 118 | + $(CC) $(LDFLAGS) -o $@ $^ -lm |
| 119 | + |
| 120 | +splitimg: splitimg.o |
| 121 | + $(CC) $(LDFLAGS) -o $@ $^ |
| 122 | + |
| 123 | +install: $(PROGS) |
| 124 | + $(STRIP) $(PROGS) |
| 125 | + $(INSTALL) -m755 $(PROGS) "$(DESTDIR)$(bindir)" |
| 126 | + |
| 127 | +%.o: %.c |
| 128 | + $(CC) $(CFLAGS) -c -o $@ $< |
| 129 | + |
| 130 | +clean: |
| 131 | + rm -f *.o *.d *~ $(PROGS) slirp/*.o slirp/*.d slirp/*~ |
| 132 | + |
| 133 | +-include $(wildcard *.d) |
| 134 | +-include $(wildcard slirp/*.d) |
0 commit comments