Patrick Georgi | 593124d | 2020-05-10 19:44:08 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0-or-later |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 2 | |
| 3 | PROGRAM = inteltool |
| 4 | |
Nico Huber | af83db2 | 2017-04-05 17:30:20 +0200 | [diff] [blame] | 5 | top ?= $(abspath ../..) |
| 6 | |
Paul Menzel | 9ebd8ea | 2013-03-31 22:15:43 +0200 | [diff] [blame] | 7 | CC ?= gcc |
Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 8 | INSTALL ?= /usr/bin/env install |
Paul Menzel | 9ebd8ea | 2013-03-31 22:15:43 +0200 | [diff] [blame] | 9 | PREFIX ?= /usr/local |
Jacob Garber | 52f0e84 | 2019-07-19 12:27:27 -0600 | [diff] [blame] | 10 | CFLAGS ?= -O2 -g -Wall -Wextra -Wmissing-prototypes |
Paul Menzel | 9ebd8ea | 2013-03-31 22:15:43 +0200 | [diff] [blame] | 11 | LDFLAGS += -lpci -lz |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 12 | |
Michael Niewöhner | cc85ce0 | 2020-03-21 23:31:31 +0100 | [diff] [blame] | 13 | CPPFLAGS += -I$(top)/util/inteltool |
Julius Werner | 98eeb96 | 2019-12-11 15:47:42 -0800 | [diff] [blame] | 14 | CPPFLAGS += -I$(top)/src/commonlib/include -I$(top)/src/commonlib/bsd/include |
Michael Niewöhner | a808d63 | 2020-03-13 23:25:28 +0100 | [diff] [blame] | 15 | CPPFLAGS += -I$(top)/src/arch/x86/include |
Julius Werner | 98eeb96 | 2019-12-11 15:47:42 -0800 | [diff] [blame] | 16 | |
Nico Huber | cce508f | 2017-06-13 12:51:54 +0200 | [diff] [blame] | 17 | |
Nico Huber | 1898023 | 2017-04-07 12:26:07 +0200 | [diff] [blame] | 18 | OBJS = inteltool.o pcr.o cpu.o gpio.o gpio_groups.o rootcmplx.o powermgt.o \ |
Michael Niewöhner | 9952e72 | 2020-03-13 22:22:26 +0100 | [diff] [blame] | 19 | memory.o pcie.o amb.o ivy_memory.o spi.o gfx.o ahci.o lpc.o |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 20 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 21 | OS_ARCH = $(shell uname) |
| 22 | ifeq ($(OS_ARCH), Darwin) |
Paul Menzel | 9ebd8ea | 2013-03-31 22:15:43 +0200 | [diff] [blame] | 23 | LDFLAGS += -framework DirectHW |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 24 | endif |
Idwer Vollering | 3f91d81 | 2010-10-24 13:50:13 +0000 | [diff] [blame] | 25 | ifeq ($(OS_ARCH), FreeBSD) |
Nico Huber | cce508f | 2017-06-13 12:51:54 +0200 | [diff] [blame] | 26 | CPPFLAGS += -I/usr/local/include |
Idwer Vollering | 3f91d81 | 2010-10-24 13:50:13 +0000 | [diff] [blame] | 27 | LDFLAGS += -L/usr/local/lib |
| 28 | LIBS = -lz |
| 29 | endif |
Andrey Korolyov | 046d217 | 2016-01-05 19:59:06 +0300 | [diff] [blame] | 30 | ifeq ($(OS_ARCH), NetBSD) |
Nico Huber | cce508f | 2017-06-13 12:51:54 +0200 | [diff] [blame] | 31 | CPPFLAGS += -I/usr/pkg/include |
Andrey Korolyov | 046d217 | 2016-01-05 19:59:06 +0300 | [diff] [blame] | 32 | LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib -lz -lpciutils -lpci -l$(shell uname -p) |
| 33 | endif |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 34 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 35 | all: pciutils dep $(PROGRAM) |
| 36 | |
| 37 | $(PROGRAM): $(OBJS) |
Nico Huber | cce508f | 2017-06-13 12:51:54 +0200 | [diff] [blame] | 38 | $(CC) $(CFLAGS) $(CPPFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS) |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 39 | |
| 40 | clean: |
Nico Huber | cde2bdf | 2017-06-13 12:54:28 +0200 | [diff] [blame] | 41 | rm -f $(PROGRAM) *.o *~ junit.xml .dependencies |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 42 | |
| 43 | distclean: clean |
Stefan Reinauer | 8b83597 | 2008-06-22 17:15:03 +0000 | [diff] [blame] | 44 | rm -f .dependencies |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 45 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 46 | dep: |
Nico Huber | cce508f | 2017-06-13 12:51:54 +0200 | [diff] [blame] | 47 | @$(CC) $(CFLAGS) $(CPPFLAGS) -MM *.c > .dependencies |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 48 | |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 49 | define LIBPCI_TEST |
| 50 | /* Avoid a failing test due to libpci header symbol shadowing breakage */ |
| 51 | #define index shadow_workaround_index |
Andrey Korolyov | 046d217 | 2016-01-05 19:59:06 +0300 | [diff] [blame] | 52 | #ifdef __NetBSD__ |
| 53 | #include <pciutils/pci.h> |
| 54 | #else |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 55 | #include <pci/pci.h> |
Andrey Korolyov | 046d217 | 2016-01-05 19:59:06 +0300 | [diff] [blame] | 56 | #endif |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 57 | struct pci_access *pacc; |
| 58 | int main(int argc, char **argv) |
| 59 | { |
| 60 | (void) argc; |
| 61 | (void) argv; |
| 62 | pacc = pci_alloc(); |
| 63 | return 0; |
| 64 | } |
| 65 | endef |
| 66 | export LIBPCI_TEST |
| 67 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 68 | pciutils: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 69 | @printf "\nChecking for pciutils and zlib... " |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 70 | @echo "$$LIBPCI_TEST" > .test.c |
Nico Huber | cce508f | 2017-06-13 12:51:54 +0200 | [diff] [blame] | 71 | @$(CC) $(CFLAGS) $(CPPFLAGS) .test.c -o .test $(LDFLAGS) \ |
| 72 | >/dev/null 2>&1 && \ |
| 73 | printf "found.\n" || ( printf "not found.\n\n"; \ |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 74 | printf "Please install pciutils-devel and zlib-devel.\n"; \ |
| 75 | printf "See README for more information.\n\n"; \ |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 76 | rm -f .test.c .test; exit 1) |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 77 | @rm -rf .test.c .test .test.dSYM |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 78 | |
| 79 | install: $(PROGRAM) |
Stefan Reinauer | f7f2f25 | 2009-09-01 09:52:14 +0000 | [diff] [blame] | 80 | mkdir -p $(DESTDIR)$(PREFIX)/sbin |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 81 | $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin |
| 82 | mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8 |
Lubomir Rintel | ba1f9aa | 2014-01-28 16:52:48 +0000 | [diff] [blame] | 83 | $(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8 |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 84 | |
| 85 | .PHONY: all clean distclean dep pciutils |
| 86 | |
| 87 | -include .dependencies |