xref: /aosp_15_r20/external/coreboot/util/vgabios/Makefile (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1##
2## SPDX-License-Identifier: GPL-2.0-only
3
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
11TOP     ?= ../..
12OUT     ?= build
13
14CC      ?=  gcc
15CFLAGS  ?= -O2 -g -fomit-frame-pointer
16
17CFLAGS  += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
18CFLAGS  += -Wwrite-strings -Wredundant-decls -Wstrict-aliasing -Wshadow -Wextra
19CFLAGS  += -Wno-unused-but-set-variable
20
21# TODO check host architecture
22CBCFLAGS  = -Wno-sign-compare -Wno-unused-parameter -Wno-format
23
24INCLUDES  = -Iinclude -I$(OUT)/include
25INCLUDES += -I$(TOP)/src/device/oprom/include/
26INCLUDES += -I$(TOP)/src/device/oprom/yabel
27INCLUDES += -include $(TOP)/src/commonlib/include/commonlib/loglevel.h
28INCLUDES += -include stdtypes.h -include pci-userspace.h
29INCLUDES += -include $(TOP)/src/include/kconfig.h
30
31CBINCLUDES = -I$(TOP)/src -include include/stdtypes.h -include $(TOP)/src/include/endian.h
32CBINCLUDES += -include stdio.h -include sys/io.h
33
34SOURCE  = testbios.c
35SOURCE += pci-userspace.c
36SOURCE += device.c
37
38X86EMU  = x86emu/sys.c x86emu/decode.c x86emu/ops.c x86emu/ops2.c
39X86EMU += x86emu/prim_ops.c x86emu/fpu.c x86emu/debug.c
40
41X86EMU += yabel/interrupt.c
42X86EMU += yabel/mem.c
43X86EMU += yabel/io.c
44X86EMU += yabel/pmm.c
45X86EMU += yabel/biosemu.c
46X86EMU += yabel/debug.c
47#X86EMU += yabel/device.c # For now we need a local copy :-(
48
49
50
51X86EMU_DIR = $(TOP)/src/device/oprom
52X86EMU_SOURCE = $(addprefix $(X86EMU_DIR)/, $(X86EMU))
53OBJECTS:=$(addprefix $(OUT)/,$(SOURCE:.c=.o)) $(addprefix $(OUT)/, $(X86EMU:.c=.o))
54
55LIBS=-lpci
56
57all: dep testbios
58
59$(OBJECTS): includes
60
61testbios: $(OBJECTS)
62	printf "    LINK  $(notdir $@)\n"
63	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
64
65dep: $(SOURCE) $(X86EMU_SOURCE) Makefile
66	$(CC) $(CFLAGS) $(INCLUDES) -MM $(SOURCE) > .dependencies
67	$(CC) $(CFLAGS) $(INCLUDES) $(CBCFLAGS) $(CBINCLUDES) -MM $(X86EMU_SOURCE) >> .dependencies
68
69# Make all the dummy include files (that are in reality
70# covered by all the -include statements above)
71includes:
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
82clean:
83	rm -f $(OBJECTS) *~ testbios
84	rm -rf $(OUT)
85
86distclean: clean
87	rm -f .dependencies
88
89$(OUT)/%.o: $(X86EMU_DIR)/%.c
90	printf "    CC    (x86emu) $(notdir $<)\n"
91	mkdir -p $(dir $@)
92	$(CC) $(CFLAGS) $(CBCFLAGS) $(INCLUDES) $(CBINCLUDES) -c -o $@ $<
93
94$(OUT)/%.o: %.c
95	printf "    CC    $(notdir $<)\n"
96	mkdir -p $(dir $@)
97	$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
98
99.PHONY: all includes clean distclean
100.SILENT:
101
102-include .dependencies
103