blob: 1baf5ba3874bbfbe3027672f0972fb8ed394691b [file] [log] [blame]
Stefan Reinauer05082732015-10-21 13:00:41 -07001##
Patrick Georgi7333a112020-05-08 20:48:04 +02002## SPDX-License-Identifier: GPL-2.0-only
Stefan Reinauer05082732015-10-21 13:00:41 -07003
Stefan Reinauer18588442005-01-17 11:08:08 +00004# 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 Reinauer850e7d42015-09-28 13:12:04 -070011TOP ?= ../..
Stefan Reinauer05082732015-10-21 13:00:41 -070012OUT ?= build
Stefan Reinauer850e7d42015-09-28 13:12:04 -070013
14CC ?= gcc
15CFLAGS ?= -O2 -g -fomit-frame-pointer
16
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +000017CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
Stefan Reinauer850e7d42015-09-28 13:12:04 -070018CFLAGS += -Wwrite-strings -Wredundant-decls -Wstrict-aliasing -Wshadow -Wextra
Stefan Reinauer05082732015-10-21 13:00:41 -070019CFLAGS += -Wno-unused-but-set-variable
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +000020
Stefan Reinauer850e7d42015-09-28 13:12:04 -070021# TODO check host architecture
Stefan Reinauer05082732015-10-21 13:00:41 -070022CBCFLAGS = -Wno-sign-compare -Wno-unused-parameter -Wno-format
Li-Ta Lo81521262004-07-08 17:18:27 +000023
Stefan Reinauer05082732015-10-21 13:00:41 -070024INCLUDES = -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
Li-Ta Lo81521262004-07-08 17:18:27 +000030
Stefan Reinauer05082732015-10-21 13:00:41 -070031CBINCLUDES = -I$(TOP)/src -include include/stdtypes.h -include $(TOP)/src/include/endian.h
32CBINCLUDES += -include stdio.h -include sys/io.h
Stefan Reinauer850e7d42015-09-28 13:12:04 -070033
Stefan Reinauer05082732015-10-21 13:00:41 -070034SOURCE = 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
Stefan Reinauer850e7d42015-09-28 13:12:04 -070052X86EMU_SOURCE = $(addprefix $(X86EMU_DIR)/, $(X86EMU))
Stefan Reinauer05082732015-10-21 13:00:41 -070053OBJECTS:=$(addprefix $(OUT)/,$(SOURCE:.c=.o)) $(addprefix $(OUT)/, $(X86EMU:.c=.o))
Stefan Reinauer86051f92010-03-23 15:53:38 +000054
55LIBS=-lpci
Li-Ta Lo81521262004-07-08 17:18:27 +000056
Stefan Reinauer850e7d42015-09-28 13:12:04 -070057all: dep testbios
Li-Ta Lo81521262004-07-08 17:18:27 +000058
Stefan Reinauer05082732015-10-21 13:00:41 -070059$(OBJECTS): includes
60
Stefan Reinauer850e7d42015-09-28 13:12:04 -070061testbios: $(OBJECTS)
62 printf " LINK $(notdir $@)\n"
Stefan Reinauer86051f92010-03-23 15:53:38 +000063 $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
Stefan Reinauer14e22772010-04-27 06:56:47 +000064
Stefan Reinauer850e7d42015-09-28 13:12:04 -070065dep: $(SOURCE) $(X86EMU_SOURCE) Makefile
66 $(CC) $(CFLAGS) $(INCLUDES) -MM $(SOURCE) > .dependencies
67 $(CC) $(CFLAGS) $(INCLUDES) $(CBCFLAGS) $(CBINCLUDES) -MM $(X86EMU_SOURCE) >> .dependencies
Li-Ta Lo81521262004-07-08 17:18:27 +000068
Stefan Reinauer05082732015-10-21 13:00:41 -070069# 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
Li-Ta Lo81521262004-07-08 17:18:27 +000082clean:
Stefan Reinauer05082732015-10-21 13:00:41 -070083 rm -f $(OBJECTS) *~ testbios
84 rm -rf $(OUT)
Li-Ta Lo81521262004-07-08 17:18:27 +000085
Stefan Reinauer850e7d42015-09-28 13:12:04 -070086distclean: clean
87 rm -f .dependencies
88
Stefan Reinauer05082732015-10-21 13:00:41 -070089$(OUT)/%.o: $(X86EMU_DIR)/%.c
Stefan Reinauer850e7d42015-09-28 13:12:04 -070090 printf " CC (x86emu) $(notdir $<)\n"
Stefan Reinauer05082732015-10-21 13:00:41 -070091 mkdir -p $(dir $@)
Stefan Reinauer850e7d42015-09-28 13:12:04 -070092 $(CC) $(CFLAGS) $(CBCFLAGS) $(INCLUDES) $(CBINCLUDES) -c -o $@ $<
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +000093
Stefan Reinauer05082732015-10-21 13:00:41 -070094$(OUT)/%.o: %.c
Stefan Reinauer850e7d42015-09-28 13:12:04 -070095 printf " CC $(notdir $<)\n"
Stefan Reinauer05082732015-10-21 13:00:41 -070096 mkdir -p $(dir $@)
Stefan Reinauer4aeff4f2010-04-16 11:45:16 +000097 $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
Stefan Reinauer850e7d42015-09-28 13:12:04 -070098
Stefan Reinauer05082732015-10-21 13:00:41 -070099.PHONY: all includes clean distclean
Stefan Reinauer850e7d42015-09-28 13:12:04 -0700100.SILENT:
101
102-include .dependencies