Patrick Georgi | 1afe286 | 2020-05-10 17:34:15 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0-or-later |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 2 | |
| 3 | PROGRAM = superiotool |
| 4 | |
Konrad Adamczyk | d6b4db1 | 2023-04-11 10:26:12 +0000 | [diff] [blame] | 5 | TOP ?= $(abspath ../..) |
Paul Menzel | be2c634 | 2013-03-28 11:44:19 +0100 | [diff] [blame] | 6 | CC ?= gcc |
Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 7 | INSTALL ?= /usr/bin/env install |
Paul Menzel | be2c634 | 2013-03-28 11:44:19 +0100 | [diff] [blame] | 8 | PREFIX ?= /usr/local |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 9 | |
Guenter Roeck | 3397cef | 2012-06-29 12:25:46 -0700 | [diff] [blame] | 10 | # Set the superiotool version string to the output of 'git describe'. |
| 11 | |
| 12 | VERSION := -D'SUPERIOTOOL_VERSION="$(shell git describe 2>/dev/null)"' |
Ulf Jordan | 39a5bf7 | 2007-10-13 18:06:12 +0000 | [diff] [blame] | 13 | |
Mathias Krause | 14b67f7 | 2011-03-09 11:37:16 +0100 | [diff] [blame] | 14 | CFLAGS += -O2 -Wall -Wstrict-prototypes -Wundef -Wstrict-aliasing \ |
Konrad Adamczyk | d6b4db1 | 2023-04-11 10:26:12 +0000 | [diff] [blame] | 15 | -Werror-implicit-function-declaration -ansi -pedantic $(VERSION) \ |
| 16 | -Wno-variadic-macros -I $(TOP)/src/commonlib/bsd/include |
Anders Juel Jensen | 280275d | 2010-08-22 19:39:04 +0000 | [diff] [blame] | 17 | LDFLAGS += -lz |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 18 | |
Derek Waldner | 3b42119 | 2016-04-14 12:13:48 -0500 | [diff] [blame] | 19 | OBJS = superiotool.o serverengines.o ali.o exar.o fintek.o ite.o nsc.o \ |
Patrick Rudolph | 674bb3b | 2019-05-24 09:07:04 +0200 | [diff] [blame] | 20 | nuvoton.o smsc.o winbond.o infineon.o aspeed.o |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 21 | |
Maciej Gabryelski | 1fc12db | 2022-04-21 08:28:01 +0200 | [diff] [blame] | 22 | OS_ARCH ?= $(shell uname) |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 23 | ifeq ($(OS_ARCH), Darwin) |
Stefan Reinauer | cff573d | 2011-03-18 22:08:39 +0000 | [diff] [blame] | 24 | LIBS = -framework IOKit -framework DirectHW -lpci -lz |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 25 | endif |
Idwer Vollering | a4d77dc | 2010-10-24 13:42:32 +0000 | [diff] [blame] | 26 | ifeq ($(OS_ARCH), FreeBSD) |
| 27 | CFLAGS = -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing \ |
Andriy Gapon | 89397fc | 2012-10-03 08:19:34 +0200 | [diff] [blame] | 28 | -Werror-implicit-function-declaration -ansi $(VERSION) \ |
Idwer Vollering | a4d77dc | 2010-10-24 13:42:32 +0000 | [diff] [blame] | 29 | -I/usr/local/include |
| 30 | LDFLAGS += -L/usr/local/lib |
| 31 | LIBS = -lz |
| 32 | endif |
Jonathan Kollasch | 51ac838 | 2010-10-24 14:10:35 +0000 | [diff] [blame] | 33 | ifeq ($(OS_ARCH), NetBSD) |
Andrey Korolyov | decefea | 2016-01-04 02:20:04 +0300 | [diff] [blame] | 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) |
Jonathan Kollasch | 51ac838 | 2010-10-24 14:10:35 +0000 | [diff] [blame] | 37 | endif |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 38 | |
Carl-Daniel Hailfinger | bb38f32 | 2010-01-24 01:40:46 +0000 | [diff] [blame] | 39 | # Support for PCI-attached "Super I/Os" (e.g. in VIA VT82686A/B). |
| 40 | CONFIG_PCI = yes |
| 41 | |
| 42 | ifeq ($(CONFIG_PCI), yes) |
| 43 | CFLAGS += -DPCI_SUPPORT |
Rudolf Marek | 113c349 | 2011-10-27 20:42:11 +0200 | [diff] [blame] | 44 | OBJS += pci.o via.o amd.o |
Andrey Korolyov | decefea | 2016-01-04 02:20:04 +0300 | [diff] [blame] | 45 | LIBS += -lpci |
| 46 | ifeq ($(OS_ARCH),NetBSD) |
| 47 | LIBS += -lpciutils |
| 48 | endif |
Carl-Daniel Hailfinger | bb38f32 | 2010-01-24 01:40:46 +0000 | [diff] [blame] | 49 | endif |
| 50 | |
Arthur Heymans | 4988af8 | 2017-04-02 23:21:53 +0200 | [diff] [blame] | 51 | all: pciutils $(PROGRAM) |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 52 | |
Ulf Jordan | 39a5bf7 | 2007-10-13 18:06:12 +0000 | [diff] [blame] | 53 | superiotool.o: *.c superiotool.h |
| 54 | |
Uwe Hermann | d754d2c | 2007-09-18 23:30:24 +0000 | [diff] [blame] | 55 | $(PROGRAM): $(OBJS) superiotool.h |
Christian Ruppert | 121f0b8 | 2010-03-21 21:22:51 +0000 | [diff] [blame] | 56 | $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 57 | |
| 58 | install: $(PROGRAM) |
Maciej Gabryelski | 1fc12db | 2022-04-21 08:28:01 +0200 | [diff] [blame] | 59 | $(INSTALL) -d $(DESTDIR)$(PREFIX)/sbin |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 60 | $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin |
Maciej Gabryelski | 1fc12db | 2022-04-21 08:28:01 +0200 | [diff] [blame] | 61 | $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man8 |
Lubomir Rintel | ba1f9aa | 2014-01-28 16:52:48 +0000 | [diff] [blame] | 62 | $(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8 |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 63 | |
Stefan Reinauer | 6a5bc46 | 2007-01-17 10:57:42 +0000 | [diff] [blame] | 64 | clean: |
Martin Roth | 0be83c0 | 2015-10-21 14:50:00 -0600 | [diff] [blame] | 65 | rm -f $(PROGRAM) *.o junit.xml |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 66 | |
Martin Roth | 0be83c0 | 2015-10-21 14:50:00 -0600 | [diff] [blame] | 67 | distclean: clean |
| 68 | |
| 69 | .PHONY: all install clean distclean |
Arthur Heymans | 4988af8 | 2017-04-02 23:21:53 +0200 | [diff] [blame] | 70 | |
| 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) |
| 82 | { |
| 83 | (void) argc; |
| 84 | (void) argv; |
| 85 | pacc = pci_alloc(); |
| 86 | return 0; |
| 87 | } |
| 88 | endef |
| 89 | export LIBPCI_TEST |
| 90 | |
| 91 | pciutils: |
| 92 | @printf "\nChecking for pciutils and zlib... " |
| 93 | @echo "$$LIBPCI_TEST" > .test.c |
Idwer Vollering | 7abc037 | 2019-12-16 15:39:00 +0100 | [diff] [blame] | 94 | @$(CC) $(CFLAGS) .test.c -o .test $(LIBS) $(LDFLAGS) >/dev/null 2>&1 && \ |
Elyes HAOUAS | b9585c5 | 2018-05-29 22:23:48 +0200 | [diff] [blame] | 95 | printf "found.\n" || ( printf "not found.\n\n"; \ |
Arthur Heymans | 4988af8 | 2017-04-02 23:21:53 +0200 | [diff] [blame] | 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 |