1 # SPDX-License-Identifier: GPL-2.0-or-later
5 TOP ?
= $(abspath ..
/..
)
7 INSTALL ?
= /usr
/bin
/env
install
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
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
26 ifeq ($(OS_ARCH
), FreeBSD
)
27 CFLAGS
= -O2
-Wall
-Werror
-Wstrict-prototypes
-Wundef
-Wstrict-aliasing \
28 -Werror-implicit-function-declaration
-std
=c11
$(VERSION
) \
30 LDFLAGS
+= -L
/usr
/local
/lib
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
)
39 # Support for PCI-attached "Super I/Os" (e.g. in VIA VT82686A/B).
42 ifeq ($(CONFIG_PCI
), yes
)
43 CFLAGS
+= -DPCI_SUPPORT
44 OBJS
+= pci.o via.o amd.o
46 ifeq ($(OS_ARCH
),NetBSD
)
51 all: pciutils
$(PROGRAM
)
53 superiotool.o
: *.c superiotool.h
55 $(PROGRAM
): $(OBJS
) superiotool.h
56 $(CC
) $(LDFLAGS
) -o
$(PROGRAM
) $(OBJS
) $(LIBS
)
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
65 rm -f
$(PROGRAM
) *.o junit.xml
69 .PHONY
: all install clean distclean
71 ifeq ($(CONFIG_PCI
), yes
)
73 /* Avoid a failing
test due to libpci header symbol shadowing breakage
*/
74 #define index shadow_workaround_index
76 #include <pciutils/pci.h>
80 struct pci_access
*pacc
;
81 int main
(int argc
, char
**argv
)
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