Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 1 | ## |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 2 | ## SPDX-License-Identifier: GPL-2.0-only |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 3 | |
Stefan Reinauer | 1858844 | 2005-01-17 11:08:08 +0000 | [diff] [blame] | 4 | # NOTE: You need to add your libpci.a version to CFLAGS below if |
| 5 | # pci-userspace.c does not build. |
| 6 | # |
| 7 | # If you are building on AMD64, you have to use /usr/lib64/libpci.a instead of |
| 8 | # /usr/lib/... |
| 9 | # |
| 10 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 11 | TOP ?= ../.. |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 12 | OUT ?= build |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 13 | |
| 14 | CC ?= gcc |
| 15 | CFLAGS ?= -O2 -g -fomit-frame-pointer |
| 16 | |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 17 | CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 18 | CFLAGS += -Wwrite-strings -Wredundant-decls -Wstrict-aliasing -Wshadow -Wextra |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 19 | CFLAGS += -Wno-unused-but-set-variable |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 20 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 21 | # TODO check host architecture |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 22 | CBCFLAGS = -Wno-sign-compare -Wno-unused-parameter -Wno-format |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 23 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 24 | INCLUDES = -Iinclude -I$(OUT)/include |
| 25 | INCLUDES += -I$(TOP)/src/device/oprom/include/ |
| 26 | INCLUDES += -I$(TOP)/src/device/oprom/yabel |
| 27 | INCLUDES += -include $(TOP)/src/commonlib/include/commonlib/loglevel.h |
| 28 | INCLUDES += -include stdtypes.h -include pci-userspace.h |
| 29 | INCLUDES += -include $(TOP)/src/include/kconfig.h |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 30 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 31 | CBINCLUDES = -I$(TOP)/src -include include/stdtypes.h -include $(TOP)/src/include/endian.h |
| 32 | CBINCLUDES += -include stdio.h -include sys/io.h |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 33 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 34 | SOURCE = testbios.c |
| 35 | SOURCE += pci-userspace.c |
| 36 | SOURCE += device.c |
| 37 | |
| 38 | X86EMU = x86emu/sys.c x86emu/decode.c x86emu/ops.c x86emu/ops2.c |
| 39 | X86EMU += x86emu/prim_ops.c x86emu/fpu.c x86emu/debug.c |
| 40 | |
| 41 | X86EMU += yabel/interrupt.c |
| 42 | X86EMU += yabel/mem.c |
| 43 | X86EMU += yabel/io.c |
| 44 | X86EMU += yabel/pmm.c |
| 45 | X86EMU += yabel/biosemu.c |
| 46 | X86EMU += yabel/debug.c |
| 47 | #X86EMU += yabel/device.c # For now we need a local copy :-( |
| 48 | |
| 49 | |
| 50 | |
| 51 | X86EMU_DIR = $(TOP)/src/device/oprom |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 52 | X86EMU_SOURCE = $(addprefix $(X86EMU_DIR)/, $(X86EMU)) |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 53 | OBJECTS:=$(addprefix $(OUT)/,$(SOURCE:.c=.o)) $(addprefix $(OUT)/, $(X86EMU:.c=.o)) |
Stefan Reinauer | 86051f9 | 2010-03-23 15:53:38 +0000 | [diff] [blame] | 54 | |
| 55 | LIBS=-lpci |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 56 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 57 | all: dep testbios |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 58 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 59 | $(OBJECTS): includes |
| 60 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 61 | testbios: $(OBJECTS) |
| 62 | printf " LINK $(notdir $@)\n" |
Stefan Reinauer | 86051f9 | 2010-03-23 15:53:38 +0000 | [diff] [blame] | 63 | $(CC) $(CFLAGS) -o $@ $^ $(LIBS) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 64 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 65 | dep: $(SOURCE) $(X86EMU_SOURCE) Makefile |
| 66 | $(CC) $(CFLAGS) $(INCLUDES) -MM $(SOURCE) > .dependencies |
| 67 | $(CC) $(CFLAGS) $(INCLUDES) $(CBCFLAGS) $(CBINCLUDES) -MM $(X86EMU_SOURCE) >> .dependencies |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 68 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 69 | # Make all the dummy include files (that are in reality |
| 70 | # covered by all the -include statements above) |
| 71 | includes: |
| 72 | mkdir -p $(OUT)/include/device |
| 73 | mkdir -p $(OUT)/include/arch |
| 74 | touch $(OUT)/include/device/device.h |
| 75 | touch $(OUT)/include/device/pci.h |
| 76 | touch $(OUT)/include/device/pci_ops.h |
| 77 | touch $(OUT)/include/device/resource.h |
| 78 | touch $(OUT)/include/arch/io.h |
| 79 | touch $(OUT)/include/timer.h |
| 80 | touch $(OUT)/include/types.h |
| 81 | |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 82 | clean: |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 83 | rm -f $(OBJECTS) *~ testbios |
| 84 | rm -rf $(OUT) |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 85 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 86 | distclean: clean |
| 87 | rm -f .dependencies |
| 88 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 89 | $(OUT)/%.o: $(X86EMU_DIR)/%.c |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 90 | printf " CC (x86emu) $(notdir $<)\n" |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 91 | mkdir -p $(dir $@) |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 92 | $(CC) $(CFLAGS) $(CBCFLAGS) $(INCLUDES) $(CBINCLUDES) -c -o $@ $< |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 93 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 94 | $(OUT)/%.o: %.c |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 95 | printf " CC $(notdir $<)\n" |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 96 | mkdir -p $(dir $@) |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 97 | $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 98 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 99 | .PHONY: all includes clean distclean |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 100 | .SILENT: |
| 101 | |
| 102 | -include .dependencies |