arch/arm64: Support FEAT_CCIDX
[coreboot2.git] / util / superiotool / Makefile
blob39839d9aa64752e8653654540008971eb732b751
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 PROGRAM = superiotool
5 TOP ?= $(abspath ../..)
6 CC ?= gcc
7 INSTALL ?= /usr/bin/env install
8 PREFIX ?= /usr/local
10 # Set the superiotool version string to the output of 'git describe'.
12 VERSION := -D'SUPERIOTOOL_VERSION="$(shell git describe 2>/dev/null)"'
14 CFLAGS += -O2 -Wall -Wstrict-prototypes -Wundef -Wstrict-aliasing \
15 -Werror-implicit-function-declaration -std=c11 -pedantic $(VERSION) \
16 -Wno-variadic-macros -I $(TOP)/src/commonlib/bsd/include
17 LDFLAGS += -lz
19 OBJS = superiotool.o serverengines.o ali.o exar.o fintek.o ite.o nsc.o \
20 nuvoton.o smsc.o winbond.o infineon.o aspeed.o
22 OS_ARCH ?= $(shell uname)
23 ifeq ($(OS_ARCH), Darwin)
24 LIBS = -framework IOKit -framework DirectHW -lpci -lz
25 endif
26 ifeq ($(OS_ARCH), FreeBSD)
27 CFLAGS = -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing \
28 -Werror-implicit-function-declaration -std=c11 $(VERSION) \
29 -I/usr/local/include
30 LDFLAGS += -L/usr/local/lib
31 LIBS = -lz
32 endif
33 ifeq ($(OS_ARCH), NetBSD)
34 CFLAGS += -I/usr/pkg/include
35 LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib
36 LIBS = -lz -l$(shell uname -p)
37 endif
39 # Support for PCI-attached "Super I/Os" (e.g. in VIA VT82686A/B).
40 CONFIG_PCI = yes
42 ifeq ($(CONFIG_PCI), yes)
43 CFLAGS += -DPCI_SUPPORT
44 OBJS += pci.o via.o amd.o
45 LIBS += -lpci
46 ifeq ($(OS_ARCH),NetBSD)
47 LIBS += -lpciutils
48 endif
49 endif
51 all: pciutils $(PROGRAM)
53 superiotool.o: *.c superiotool.h
55 $(PROGRAM): $(OBJS) superiotool.h
56 $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
58 install: $(PROGRAM)
59 $(INSTALL) -d $(DESTDIR)$(PREFIX)/sbin
60 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
61 $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man8
62 $(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
64 clean:
65 rm -f $(PROGRAM) *.o junit.xml
67 distclean: clean
69 .PHONY: all install clean distclean
71 ifeq ($(CONFIG_PCI), yes)
72 define LIBPCI_TEST
73 /* Avoid a failing test due to libpci header symbol shadowing breakage */
74 #define index shadow_workaround_index
75 #ifdef __NetBSD__
76 #include <pciutils/pci.h>
77 #else
78 #include <pci/pci.h>
79 #endif
80 struct pci_access *pacc;
81 int main(int argc, char **argv)
83 (void) argc;
84 (void) argv;
85 pacc = pci_alloc();
86 return 0;
88 endef
89 export LIBPCI_TEST
91 pciutils:
92 @printf "\nChecking for pciutils and zlib... "
93 @echo "$$LIBPCI_TEST" > .test.c
94 @$(CC) $(CFLAGS) .test.c -o .test $(LIBS) $(LDFLAGS) >/dev/null 2>&1 && \
95 printf "found.\n" || ( printf "not found.\n\n"; \
96 printf "Please install pciutils-devel and zlib-devel.\n"; \
97 printf "See README for more information.\n\n"; \
98 rm -f .test.c .test; exit 1)
99 @rm -rf .test.c .test .test.dSYM
100 endif