Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 1 | # intelmetool |
| 2 | |
| 3 | # Copyright (C) 2013-2015 Damien Zammit <damien@zamaudio.com> |
| 4 | |
| 5 | # This program is free software; you can redistribute it and/or |
| 6 | # modify it under the terms of the GNU General Public License as |
| 7 | # published by the Free Software Foundation; either version 2 of |
Damien Zammit | f0a9128 | 2019-02-23 12:38:15 +1100 | [diff] [blame] | 8 | # the License, or (at your option) any later version. |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 9 | |
| 10 | # This program is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | |
| 15 | PROGRAM = intelmetool |
| 16 | |
| 17 | CC ?= gcc |
Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 18 | INSTALL ?= /usr/bin/env install |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 19 | PREFIX ?= /usr/local |
Jacob Garber | 52f0e84 | 2019-07-19 12:27:27 -0600 | [diff] [blame] | 20 | CFLAGS ?= -O0 -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 21 | LDFLAGS += -lpci -lz |
| 22 | |
Philipp Deppenwiese | 73add17 | 2016-08-26 02:10:51 +0200 | [diff] [blame] | 23 | OBJS = intelmetool.o me.o me_status.o mmap.o rcba.o msr.o |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 24 | |
| 25 | OS_ARCH = $(shell uname) |
| 26 | ifeq ($(OS_ARCH), Darwin) |
| 27 | LDFLAGS += -framework DirectHW |
| 28 | endif |
| 29 | ifeq ($(OS_ARCH), FreeBSD) |
| 30 | CFLAGS += -I/usr/local/include |
| 31 | LDFLAGS += -L/usr/local/lib |
| 32 | LIBS = -lz |
| 33 | endif |
| 34 | ifeq ($(OS_ARCH), NetBSD) |
| 35 | CFLAGS += -I/usr/pkg/include |
| 36 | LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib -lz -lpciutils -lpci -l$(shell uname -p) |
| 37 | endif |
| 38 | |
| 39 | all: pciutils dep $(PROGRAM) |
| 40 | |
Matthias Gazzari | d88cd70 | 2018-05-21 20:54:41 +0200 | [diff] [blame] | 41 | oldarc: CFLAGS += -DOLDARC |
| 42 | oldarc: all |
| 43 | |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 44 | $(PROGRAM): $(OBJS) |
| 45 | $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS) |
| 46 | |
| 47 | clean: |
| 48 | rm -f $(PROGRAM) *.o *~ junit.xml |
| 49 | |
| 50 | distclean: clean |
| 51 | rm -f .dependencies |
| 52 | |
| 53 | dep: |
| 54 | @$(CC) $(CFLAGS) -MM *.c > .dependencies |
| 55 | |
| 56 | define LIBPCI_TEST |
| 57 | /* Avoid a failing test due to libpci header symbol shadowing breakage */ |
| 58 | #define index shadow_workaround_index |
| 59 | #ifdef __NetBSD__ |
| 60 | #include <pciutils/pci.h> |
| 61 | #else |
| 62 | #include <pci/pci.h> |
| 63 | #endif |
| 64 | struct pci_access *pacc; |
| 65 | int main(int argc, char **argv) |
| 66 | { |
| 67 | (void) argc; |
| 68 | (void) argv; |
| 69 | pacc = pci_alloc(); |
| 70 | return 0; |
| 71 | } |
| 72 | endef |
| 73 | export LIBPCI_TEST |
| 74 | |
| 75 | pciutils: |
Vincent Legoll | 0d2ff13 | 2017-05-07 17:51:25 +0200 | [diff] [blame] | 76 | @printf "\nChecking for development libraries: pci and zlib... " |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 77 | @echo "$$LIBPCI_TEST" > .test.c |
| 78 | @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) >/dev/null 2>&1 && \ |
| 79 | printf "found.\n" || ( printf "not found.\n\n"; \ |
Vincent Legoll | 0d2ff13 | 2017-05-07 17:51:25 +0200 | [diff] [blame] | 80 | printf "For RPM based distributions like Fedora, please install pciutils-devel and zlib-devel.\n"; \ |
| 81 | printf "For DEB based distributions, please install libpci-dev and zlib1g-dev.\n"; \ |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 82 | rm -f .test.c .test; exit 1) |
| 83 | @rm -rf .test.c .test .test.dSYM |
| 84 | |
| 85 | install: $(PROGRAM) |
| 86 | mkdir -p $(DESTDIR)$(PREFIX)/sbin |
| 87 | $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin |
| 88 | |
Matthias Gazzari | d88cd70 | 2018-05-21 20:54:41 +0200 | [diff] [blame] | 89 | .PHONY: all clean distclean dep pciutils oldarc |
Philipp Deppenwiese | d8fe443 | 2016-03-18 00:52:54 +0100 | [diff] [blame] | 90 | |
| 91 | -include .dependencies |