2020-05-10 17:34:15 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2007-09-01 22:20:41 +02:00
|
|
|
|
|
|
|
PROGRAM = superiotool
|
|
|
|
|
2013-03-28 11:44:19 +01:00
|
|
|
CC ?= gcc
|
2018-10-07 03:58:27 +02:00
|
|
|
INSTALL ?= /usr/bin/env install
|
2013-03-28 11:44:19 +01:00
|
|
|
PREFIX ?= /usr/local
|
2007-09-01 22:20:41 +02:00
|
|
|
|
2012-06-29 21:25:46 +02:00
|
|
|
# Set the superiotool version string to the output of 'git describe'.
|
|
|
|
|
|
|
|
VERSION := -D'SUPERIOTOOL_VERSION="$(shell git describe 2>/dev/null)"'
|
2007-10-13 20:06:12 +02:00
|
|
|
|
2011-03-09 11:37:16 +01:00
|
|
|
CFLAGS += -O2 -Wall -Wstrict-prototypes -Wundef -Wstrict-aliasing \
|
2012-06-29 21:25:46 +02:00
|
|
|
-Werror-implicit-function-declaration -ansi -pedantic $(VERSION)
|
2010-08-22 21:39:04 +02:00
|
|
|
LDFLAGS += -lz
|
2007-09-01 22:20:41 +02:00
|
|
|
|
2016-04-14 19:13:48 +02:00
|
|
|
OBJS = superiotool.o serverengines.o ali.o exar.o fintek.o ite.o nsc.o \
|
2019-05-24 09:07:04 +02:00
|
|
|
nuvoton.o smsc.o winbond.o infineon.o aspeed.o
|
2007-09-16 20:11:03 +02:00
|
|
|
|
2022-04-21 08:28:01 +02:00
|
|
|
OS_ARCH ?= $(shell uname)
|
2009-09-01 11:57:55 +02:00
|
|
|
ifeq ($(OS_ARCH), Darwin)
|
2011-03-18 23:08:39 +01:00
|
|
|
LIBS = -framework IOKit -framework DirectHW -lpci -lz
|
2009-09-01 11:57:55 +02:00
|
|
|
endif
|
2010-10-24 15:42:32 +02:00
|
|
|
ifeq ($(OS_ARCH), FreeBSD)
|
|
|
|
CFLAGS = -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing \
|
2012-10-03 08:19:34 +02:00
|
|
|
-Werror-implicit-function-declaration -ansi $(VERSION) \
|
2010-10-24 15:42:32 +02:00
|
|
|
-I/usr/local/include
|
|
|
|
LDFLAGS += -L/usr/local/lib
|
|
|
|
LIBS = -lz
|
|
|
|
endif
|
2010-10-24 16:10:35 +02:00
|
|
|
ifeq ($(OS_ARCH), NetBSD)
|
2016-01-04 00:20:04 +01:00
|
|
|
CFLAGS += -I/usr/pkg/include
|
|
|
|
LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib
|
|
|
|
LIBS = -lz -l$(shell uname -p)
|
2010-10-24 16:10:35 +02:00
|
|
|
endif
|
2009-09-01 11:57:55 +02:00
|
|
|
|
2010-01-24 02:40:46 +01:00
|
|
|
# Support for PCI-attached "Super I/Os" (e.g. in VIA VT82686A/B).
|
|
|
|
CONFIG_PCI = yes
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_PCI), yes)
|
|
|
|
CFLAGS += -DPCI_SUPPORT
|
2011-10-27 20:42:11 +02:00
|
|
|
OBJS += pci.o via.o amd.o
|
2016-01-04 00:20:04 +01:00
|
|
|
LIBS += -lpci
|
|
|
|
ifeq ($(OS_ARCH),NetBSD)
|
|
|
|
LIBS += -lpciutils
|
|
|
|
endif
|
2010-01-24 02:40:46 +01:00
|
|
|
endif
|
|
|
|
|
2017-04-02 23:21:53 +02:00
|
|
|
all: pciutils $(PROGRAM)
|
2007-09-01 22:20:41 +02:00
|
|
|
|
2007-10-13 20:06:12 +02:00
|
|
|
superiotool.o: *.c superiotool.h
|
|
|
|
|
2007-09-19 01:30:24 +02:00
|
|
|
$(PROGRAM): $(OBJS) superiotool.h
|
2010-03-21 22:22:51 +01:00
|
|
|
$(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
|
2007-09-01 22:20:41 +02:00
|
|
|
|
|
|
|
install: $(PROGRAM)
|
2022-04-21 08:28:01 +02:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(PREFIX)/sbin
|
2009-09-01 11:57:55 +02:00
|
|
|
$(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
|
2022-04-21 08:28:01 +02:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man8
|
2014-01-28 17:52:48 +01:00
|
|
|
$(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
|
2007-09-01 22:20:41 +02:00
|
|
|
|
2007-01-17 11:57:42 +01:00
|
|
|
clean:
|
2015-10-21 22:50:00 +02:00
|
|
|
rm -f $(PROGRAM) *.o junit.xml
|
2007-09-01 22:20:41 +02:00
|
|
|
|
2015-10-21 22:50:00 +02:00
|
|
|
distclean: clean
|
|
|
|
|
|
|
|
.PHONY: all install clean distclean
|
2017-04-02 23:21:53 +02:00
|
|
|
|
|
|
|
ifeq ($(CONFIG_PCI), yes)
|
|
|
|
define LIBPCI_TEST
|
|
|
|
/* Avoid a failing test due to libpci header symbol shadowing breakage */
|
|
|
|
#define index shadow_workaround_index
|
|
|
|
#ifdef __NetBSD__
|
|
|
|
#include <pciutils/pci.h>
|
|
|
|
#else
|
|
|
|
#include <pci/pci.h>
|
|
|
|
#endif
|
|
|
|
struct pci_access *pacc;
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
|
|
|
pacc = pci_alloc();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
endef
|
|
|
|
export LIBPCI_TEST
|
|
|
|
|
|
|
|
pciutils:
|
|
|
|
@printf "\nChecking for pciutils and zlib... "
|
|
|
|
@echo "$$LIBPCI_TEST" > .test.c
|
2019-12-16 15:39:00 +01:00
|
|
|
@$(CC) $(CFLAGS) .test.c -o .test $(LIBS) $(LDFLAGS) >/dev/null 2>&1 && \
|
2018-05-29 22:23:48 +02:00
|
|
|
printf "found.\n" || ( printf "not found.\n\n"; \
|
2017-04-02 23:21:53 +02:00
|
|
|
printf "Please install pciutils-devel and zlib-devel.\n"; \
|
|
|
|
printf "See README for more information.\n\n"; \
|
|
|
|
rm -f .test.c .test; exit 1)
|
|
|
|
@rm -rf .test.c .test .test.dSYM
|
|
|
|
endif
|