Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 1 | ## |
| 2 | ## This file is part of the coreboot project. |
| 3 | ## |
| 4 | ## Copyright (C) 2016 Google Inc. |
| 5 | ## |
| 6 | ## This program is free software; you can redistribute it and/or modify |
| 7 | ## it under the terms of the GNU General Public License as published by |
| 8 | ## the Free Software Foundation; version 2 of the License. |
| 9 | ## |
| 10 | ## This program is distributed in the hope that it will be useful, |
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ## GNU General Public License for more details. |
| 14 | ## |
| 15 | |
Stefan Reinauer | 1858844 | 2005-01-17 11:08:08 +0000 | [diff] [blame] | 16 | # |
| 17 | # NOTE: You need to add your libpci.a version to CFLAGS below if |
| 18 | # pci-userspace.c does not build. |
| 19 | # |
| 20 | # If you are building on AMD64, you have to use /usr/lib64/libpci.a instead of |
| 21 | # /usr/lib/... |
| 22 | # |
| 23 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 24 | TOP ?= ../.. |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 25 | OUT ?= build |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 26 | |
| 27 | CC ?= gcc |
| 28 | CFLAGS ?= -O2 -g -fomit-frame-pointer |
| 29 | |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 30 | CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 31 | CFLAGS += -Wwrite-strings -Wredundant-decls -Wstrict-aliasing -Wshadow -Wextra |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 32 | CFLAGS += -Wno-unused-but-set-variable |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 33 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 34 | # TODO check host architecture |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 35 | CBCFLAGS = -Wno-sign-compare -Wno-unused-parameter -Wno-format |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 36 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 37 | INCLUDES = -Iinclude -I$(OUT)/include |
| 38 | INCLUDES += -I$(TOP)/src/device/oprom/include/ |
| 39 | INCLUDES += -I$(TOP)/src/device/oprom/yabel |
| 40 | INCLUDES += -include $(TOP)/src/commonlib/include/commonlib/loglevel.h |
| 41 | INCLUDES += -include stdtypes.h -include pci-userspace.h |
| 42 | INCLUDES += -include $(TOP)/src/include/kconfig.h |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 43 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 44 | CBINCLUDES = -I$(TOP)/src -include include/stdtypes.h -include $(TOP)/src/include/endian.h |
| 45 | CBINCLUDES += -include stdio.h -include sys/io.h |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 46 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 47 | SOURCE = testbios.c |
| 48 | SOURCE += pci-userspace.c |
| 49 | SOURCE += device.c |
| 50 | |
| 51 | X86EMU = x86emu/sys.c x86emu/decode.c x86emu/ops.c x86emu/ops2.c |
| 52 | X86EMU += x86emu/prim_ops.c x86emu/fpu.c x86emu/debug.c |
| 53 | |
| 54 | X86EMU += yabel/interrupt.c |
| 55 | X86EMU += yabel/mem.c |
| 56 | X86EMU += yabel/io.c |
| 57 | X86EMU += yabel/pmm.c |
| 58 | X86EMU += yabel/biosemu.c |
| 59 | X86EMU += yabel/debug.c |
| 60 | #X86EMU += yabel/device.c # For now we need a local copy :-( |
| 61 | |
| 62 | |
| 63 | |
| 64 | X86EMU_DIR = $(TOP)/src/device/oprom |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 65 | X86EMU_SOURCE = $(addprefix $(X86EMU_DIR)/, $(X86EMU)) |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 66 | OBJECTS:=$(addprefix $(OUT)/,$(SOURCE:.c=.o)) $(addprefix $(OUT)/, $(X86EMU:.c=.o)) |
Stefan Reinauer | 86051f9 | 2010-03-23 15:53:38 +0000 | [diff] [blame] | 67 | |
| 68 | LIBS=-lpci |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 69 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 70 | all: dep testbios |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 71 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 72 | $(OBJECTS): includes |
| 73 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 74 | testbios: $(OBJECTS) |
| 75 | printf " LINK $(notdir $@)\n" |
Stefan Reinauer | 86051f9 | 2010-03-23 15:53:38 +0000 | [diff] [blame] | 76 | $(CC) $(CFLAGS) -o $@ $^ $(LIBS) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 77 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 78 | dep: $(SOURCE) $(X86EMU_SOURCE) Makefile |
| 79 | $(CC) $(CFLAGS) $(INCLUDES) -MM $(SOURCE) > .dependencies |
| 80 | $(CC) $(CFLAGS) $(INCLUDES) $(CBCFLAGS) $(CBINCLUDES) -MM $(X86EMU_SOURCE) >> .dependencies |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 81 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 82 | # Make all the dummy include files (that are in reality |
| 83 | # covered by all the -include statements above) |
| 84 | includes: |
| 85 | mkdir -p $(OUT)/include/device |
| 86 | mkdir -p $(OUT)/include/arch |
| 87 | touch $(OUT)/include/device/device.h |
| 88 | touch $(OUT)/include/device/pci.h |
| 89 | touch $(OUT)/include/device/pci_ops.h |
| 90 | touch $(OUT)/include/device/resource.h |
| 91 | touch $(OUT)/include/arch/io.h |
| 92 | touch $(OUT)/include/timer.h |
| 93 | touch $(OUT)/include/types.h |
| 94 | |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 95 | clean: |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 96 | rm -f $(OBJECTS) *~ testbios |
| 97 | rm -rf $(OUT) |
Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 98 | |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 99 | distclean: clean |
| 100 | rm -f .dependencies |
| 101 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 102 | $(OUT)/%.o: $(X86EMU_DIR)/%.c |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 103 | printf " CC (x86emu) $(notdir $<)\n" |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 104 | mkdir -p $(dir $@) |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 105 | $(CC) $(CFLAGS) $(CBCFLAGS) $(INCLUDES) $(CBINCLUDES) -c -o $@ $< |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 106 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 107 | $(OUT)/%.o: %.c |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 108 | printf " CC $(notdir $<)\n" |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 109 | mkdir -p $(dir $@) |
Stefan Reinauer | 4aeff4f | 2010-04-16 11:45:16 +0000 | [diff] [blame] | 110 | $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 111 | |
Stefan Reinauer | 0508273 | 2015-10-21 13:00:41 -0700 | [diff] [blame] | 112 | .PHONY: all includes clean distclean |
Stefan Reinauer | 850e7d4 | 2015-09-28 13:12:04 -0700 | [diff] [blame] | 113 | .SILENT: |
| 114 | |
| 115 | -include .dependencies |