blob: 45a7259cb73aafc3ed74ca411b33fe4213b919e5 [file] [log] [blame]
Stefan Reinauer05082732015-10-21 13:00:41 -07001##
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 Reinauer18588442005-01-17 11:08:08 +000016#
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 Reinauer850e7d42015-09-28 13:12:04 -070024TOP ?= ../..
Stefan Reinauer05082732015-10-21 13:00:41 -070025OUT ?= build
Stefan Reinauer850e7d42015-09-28 13:12:04 -070026
27CC ?= gcc
28CFLAGS ?= -O2 -g -fomit-frame-pointer
29
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +000030CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
Stefan Reinauer850e7d42015-09-28 13:12:04 -070031CFLAGS += -Wwrite-strings -Wredundant-decls -Wstrict-aliasing -Wshadow -Wextra
Stefan Reinauer05082732015-10-21 13:00:41 -070032CFLAGS += -Wno-unused-but-set-variable
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +000033
Stefan Reinauer850e7d42015-09-28 13:12:04 -070034# TODO check host architecture
Stefan Reinauer05082732015-10-21 13:00:41 -070035CBCFLAGS = -Wno-sign-compare -Wno-unused-parameter -Wno-format
Li-Ta Lo81521262004-07-08 17:18:27 +000036
Stefan Reinauer05082732015-10-21 13:00:41 -070037INCLUDES = -Iinclude -I$(OUT)/include
38INCLUDES += -I$(TOP)/src/device/oprom/include/
39INCLUDES += -I$(TOP)/src/device/oprom/yabel
40INCLUDES += -include $(TOP)/src/commonlib/include/commonlib/loglevel.h
41INCLUDES += -include stdtypes.h -include pci-userspace.h
42INCLUDES += -include $(TOP)/src/include/kconfig.h
Li-Ta Lo81521262004-07-08 17:18:27 +000043
Stefan Reinauer05082732015-10-21 13:00:41 -070044CBINCLUDES = -I$(TOP)/src -include include/stdtypes.h -include $(TOP)/src/include/endian.h
45CBINCLUDES += -include stdio.h -include sys/io.h
Stefan Reinauer850e7d42015-09-28 13:12:04 -070046
Stefan Reinauer05082732015-10-21 13:00:41 -070047SOURCE = testbios.c
48SOURCE += pci-userspace.c
49SOURCE += device.c
50
51X86EMU = x86emu/sys.c x86emu/decode.c x86emu/ops.c x86emu/ops2.c
52X86EMU += x86emu/prim_ops.c x86emu/fpu.c x86emu/debug.c
53
54X86EMU += yabel/interrupt.c
55X86EMU += yabel/mem.c
56X86EMU += yabel/io.c
57X86EMU += yabel/pmm.c
58X86EMU += yabel/biosemu.c
59X86EMU += yabel/debug.c
60#X86EMU += yabel/device.c # For now we need a local copy :-(
61
62
63
64X86EMU_DIR = $(TOP)/src/device/oprom
Stefan Reinauer850e7d42015-09-28 13:12:04 -070065X86EMU_SOURCE = $(addprefix $(X86EMU_DIR)/, $(X86EMU))
Stefan Reinauer05082732015-10-21 13:00:41 -070066OBJECTS:=$(addprefix $(OUT)/,$(SOURCE:.c=.o)) $(addprefix $(OUT)/, $(X86EMU:.c=.o))
Stefan Reinauer86051f92010-03-23 15:53:38 +000067
68LIBS=-lpci
Li-Ta Lo81521262004-07-08 17:18:27 +000069
Stefan Reinauer850e7d42015-09-28 13:12:04 -070070all: dep testbios
Li-Ta Lo81521262004-07-08 17:18:27 +000071
Stefan Reinauer05082732015-10-21 13:00:41 -070072$(OBJECTS): includes
73
Stefan Reinauer850e7d42015-09-28 13:12:04 -070074testbios: $(OBJECTS)
75 printf " LINK $(notdir $@)\n"
Stefan Reinauer86051f92010-03-23 15:53:38 +000076 $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
Stefan Reinauer14e22772010-04-27 06:56:47 +000077
Stefan Reinauer850e7d42015-09-28 13:12:04 -070078dep: $(SOURCE) $(X86EMU_SOURCE) Makefile
79 $(CC) $(CFLAGS) $(INCLUDES) -MM $(SOURCE) > .dependencies
80 $(CC) $(CFLAGS) $(INCLUDES) $(CBCFLAGS) $(CBINCLUDES) -MM $(X86EMU_SOURCE) >> .dependencies
Li-Ta Lo81521262004-07-08 17:18:27 +000081
Stefan Reinauer05082732015-10-21 13:00:41 -070082# Make all the dummy include files (that are in reality
83# covered by all the -include statements above)
84includes:
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 Lo81521262004-07-08 17:18:27 +000095clean:
Stefan Reinauer05082732015-10-21 13:00:41 -070096 rm -f $(OBJECTS) *~ testbios
97 rm -rf $(OUT)
Li-Ta Lo81521262004-07-08 17:18:27 +000098
Stefan Reinauer850e7d42015-09-28 13:12:04 -070099distclean: clean
100 rm -f .dependencies
101
Stefan Reinauer05082732015-10-21 13:00:41 -0700102$(OUT)/%.o: $(X86EMU_DIR)/%.c
Stefan Reinauer850e7d42015-09-28 13:12:04 -0700103 printf " CC (x86emu) $(notdir $<)\n"
Stefan Reinauer05082732015-10-21 13:00:41 -0700104 mkdir -p $(dir $@)
Stefan Reinauer850e7d42015-09-28 13:12:04 -0700105 $(CC) $(CFLAGS) $(CBCFLAGS) $(INCLUDES) $(CBINCLUDES) -c -o $@ $<
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +0000106
Stefan Reinauer05082732015-10-21 13:00:41 -0700107$(OUT)/%.o: %.c
Stefan Reinauer850e7d42015-09-28 13:12:04 -0700108 printf " CC $(notdir $<)\n"
Stefan Reinauer05082732015-10-21 13:00:41 -0700109 mkdir -p $(dir $@)
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +0000110 $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
Stefan Reinauer850e7d42015-09-28 13:12:04 -0700111
Stefan Reinauer05082732015-10-21 13:00:41 -0700112.PHONY: all includes clean distclean
Stefan Reinauer850e7d42015-09-28 13:12:04 -0700113.SILENT:
114
115-include .dependencies