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 | |
Paul Menzel | be2c634 | 2013-03-28 11:44:19 +0100 | [diff] [blame] | 5 | CC ?= gcc |
Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 6 | INSTALL ?= /usr/bin/env install |
Paul Menzel | be2c634 | 2013-03-28 11:44:19 +0100 | [diff] [blame] | 7 | PREFIX ?= /usr/local |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 8 | |
Guenter Roeck | 3397cef | 2012-06-29 12:25:46 -0700 | [diff] [blame] | 9 | # Set the superiotool version string to the output of 'git describe'. |
| 10 | |
| 11 | VERSION := -D'SUPERIOTOOL_VERSION="$(shell git describe 2>/dev/null)"' |
Ulf Jordan | 39a5bf7 | 2007-10-13 18:06:12 +0000 | [diff] [blame] | 12 | |
Mathias Krause | 14b67f7 | 2011-03-09 11:37:16 +0100 | [diff] [blame] | 13 | CFLAGS += -O2 -Wall -Wstrict-prototypes -Wundef -Wstrict-aliasing \ |
Guenter Roeck | 3397cef | 2012-06-29 12:25:46 -0700 | [diff] [blame] | 14 | -Werror-implicit-function-declaration -ansi -pedantic $(VERSION) |
Anders Juel Jensen | 280275d | 2010-08-22 19:39:04 +0000 | [diff] [blame] | 15 | LDFLAGS += -lz |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 16 | |
Derek Waldner | 3b42119 | 2016-04-14 12:13:48 -0500 | [diff] [blame] | 17 | 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] | 18 | nuvoton.o smsc.o winbond.o infineon.o aspeed.o |
Uwe Hermann | 0120e1a | 2007-09-16 18:11:03 +0000 | [diff] [blame] | 19 | |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 20 | OS_ARCH = $(shell uname) |
| 21 | ifeq ($(OS_ARCH), Darwin) |
Stefan Reinauer | cff573d | 2011-03-18 22:08:39 +0000 | [diff] [blame] | 22 | LIBS = -framework IOKit -framework DirectHW -lpci -lz |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 23 | endif |
Idwer Vollering | a4d77dc | 2010-10-24 13:42:32 +0000 | [diff] [blame] | 24 | ifeq ($(OS_ARCH), FreeBSD) |
| 25 | CFLAGS = -O2 -Wall -Werror -Wstrict-prototypes -Wundef -Wstrict-aliasing \ |
Andriy Gapon | 89397fc | 2012-10-03 08:19:34 +0200 | [diff] [blame] | 26 | -Werror-implicit-function-declaration -ansi $(VERSION) \ |
Idwer Vollering | a4d77dc | 2010-10-24 13:42:32 +0000 | [diff] [blame] | 27 | -I/usr/local/include |
| 28 | LDFLAGS += -L/usr/local/lib |
| 29 | LIBS = -lz |
| 30 | endif |
Jonathan Kollasch | 51ac838 | 2010-10-24 14:10:35 +0000 | [diff] [blame] | 31 | ifeq ($(OS_ARCH), NetBSD) |
Andrey Korolyov | decefea | 2016-01-04 02:20:04 +0300 | [diff] [blame] | 32 | CFLAGS += -I/usr/pkg/include |
| 33 | LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib |
| 34 | LIBS = -lz -l$(shell uname -p) |
Jonathan Kollasch | 51ac838 | 2010-10-24 14:10:35 +0000 | [diff] [blame] | 35 | endif |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 36 | |
Carl-Daniel Hailfinger | bb38f32 | 2010-01-24 01:40:46 +0000 | [diff] [blame] | 37 | # Support for PCI-attached "Super I/Os" (e.g. in VIA VT82686A/B). |
| 38 | CONFIG_PCI = yes |
| 39 | |
| 40 | ifeq ($(CONFIG_PCI), yes) |
| 41 | CFLAGS += -DPCI_SUPPORT |
Rudolf Marek | 113c349 | 2011-10-27 20:42:11 +0200 | [diff] [blame] | 42 | OBJS += pci.o via.o amd.o |
Andrey Korolyov | decefea | 2016-01-04 02:20:04 +0300 | [diff] [blame] | 43 | LIBS += -lpci |
| 44 | ifeq ($(OS_ARCH),NetBSD) |
| 45 | LIBS += -lpciutils |
| 46 | endif |
Carl-Daniel Hailfinger | bb38f32 | 2010-01-24 01:40:46 +0000 | [diff] [blame] | 47 | endif |
| 48 | |
Arthur Heymans | 4988af8 | 2017-04-02 23:21:53 +0200 | [diff] [blame] | 49 | all: pciutils $(PROGRAM) |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 50 | |
Ulf Jordan | 39a5bf7 | 2007-10-13 18:06:12 +0000 | [diff] [blame] | 51 | superiotool.o: *.c superiotool.h |
| 52 | |
Uwe Hermann | d754d2c | 2007-09-18 23:30:24 +0000 | [diff] [blame] | 53 | $(PROGRAM): $(OBJS) superiotool.h |
Christian Ruppert | 121f0b8 | 2010-03-21 21:22:51 +0000 | [diff] [blame] | 54 | $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 55 | |
| 56 | install: $(PROGRAM) |
Stefan Reinauer | e95eb61 | 2009-09-01 09:57:55 +0000 | [diff] [blame] | 57 | mkdir -p $(DESTDIR)$(PREFIX)/sbin |
| 58 | $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin |
| 59 | mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8 |
Lubomir Rintel | ba1f9aa | 2014-01-28 16:52:48 +0000 | [diff] [blame] | 60 | $(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8 |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 61 | |
Stefan Reinauer | 6a5bc46 | 2007-01-17 10:57:42 +0000 | [diff] [blame] | 62 | clean: |
Martin Roth | 0be83c0 | 2015-10-21 14:50:00 -0600 | [diff] [blame] | 63 | rm -f $(PROGRAM) *.o junit.xml |
Uwe Hermann | 1ae8e83 | 2007-09-01 20:20:41 +0000 | [diff] [blame] | 64 | |
Martin Roth | 0be83c0 | 2015-10-21 14:50:00 -0600 | [diff] [blame] | 65 | distclean: clean |
| 66 | |
| 67 | .PHONY: all install clean distclean |
Arthur Heymans | 4988af8 | 2017-04-02 23:21:53 +0200 | [diff] [blame] | 68 | |
| 69 | ifeq ($(CONFIG_PCI), yes) |
| 70 | define LIBPCI_TEST |
| 71 | /* Avoid a failing test due to libpci header symbol shadowing breakage */ |
| 72 | #define index shadow_workaround_index |
| 73 | #ifdef __NetBSD__ |
| 74 | #include <pciutils/pci.h> |
| 75 | #else |
| 76 | #include <pci/pci.h> |
| 77 | #endif |
| 78 | struct pci_access *pacc; |
| 79 | int main(int argc, char **argv) |
| 80 | { |
| 81 | (void) argc; |
| 82 | (void) argv; |
| 83 | pacc = pci_alloc(); |
| 84 | return 0; |
| 85 | } |
| 86 | endef |
| 87 | export LIBPCI_TEST |
| 88 | |
| 89 | pciutils: |
| 90 | @printf "\nChecking for pciutils and zlib... " |
| 91 | @echo "$$LIBPCI_TEST" > .test.c |
Idwer Vollering | 7abc037 | 2019-12-16 15:39:00 +0100 | [diff] [blame] | 92 | @$(CC) $(CFLAGS) .test.c -o .test $(LIBS) $(LDFLAGS) >/dev/null 2>&1 && \ |
Elyes HAOUAS | b9585c5 | 2018-05-29 22:23:48 +0200 | [diff] [blame] | 93 | printf "found.\n" || ( printf "not found.\n\n"; \ |
Arthur Heymans | 4988af8 | 2017-04-02 23:21:53 +0200 | [diff] [blame] | 94 | printf "Please install pciutils-devel and zlib-devel.\n"; \ |
| 95 | printf "See README for more information.\n\n"; \ |
| 96 | rm -f .test.c .test; exit 1) |
| 97 | @rm -rf .test.c .test .test.dSYM |
| 98 | endif |