blob: 55ba82a4242f13c37de4fb9000595a9049b07c04 [file] [log] [blame]
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +01001# 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 Zammitf0a91282019-02-23 12:38:15 +11008# the License, or (at your option) any later version.
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +01009
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
15PROGRAM = intelmetool
16
17CC ?= gcc
Yegor Timoshenkoc2e49412018-10-07 01:58:27 +000018INSTALL ?= /usr/bin/env install
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010019PREFIX ?= /usr/local
Jacob Garber52f0e842019-07-19 12:27:27 -060020CFLAGS ?= -O0 -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010021LDFLAGS += -lpci -lz
22
Philipp Deppenwiese73add172016-08-26 02:10:51 +020023OBJS = intelmetool.o me.o me_status.o mmap.o rcba.o msr.o
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010024
25OS_ARCH = $(shell uname)
26ifeq ($(OS_ARCH), Darwin)
27LDFLAGS += -framework DirectHW
28endif
29ifeq ($(OS_ARCH), FreeBSD)
30CFLAGS += -I/usr/local/include
31LDFLAGS += -L/usr/local/lib
32LIBS = -lz
33endif
34ifeq ($(OS_ARCH), NetBSD)
35CFLAGS += -I/usr/pkg/include
36LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib -lz -lpciutils -lpci -l$(shell uname -p)
37endif
38
39all: pciutils dep $(PROGRAM)
40
Matthias Gazzarid88cd702018-05-21 20:54:41 +020041oldarc: CFLAGS += -DOLDARC
42oldarc: all
43
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010044$(PROGRAM): $(OBJS)
45 $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
46
47clean:
48 rm -f $(PROGRAM) *.o *~ junit.xml
49
50distclean: clean
51 rm -f .dependencies
52
53dep:
54 @$(CC) $(CFLAGS) -MM *.c > .dependencies
55
56define 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
64struct pci_access *pacc;
65int main(int argc, char **argv)
66{
67 (void) argc;
68 (void) argv;
69 pacc = pci_alloc();
70 return 0;
71}
72endef
73export LIBPCI_TEST
74
75pciutils:
Vincent Legoll0d2ff132017-05-07 17:51:25 +020076 @printf "\nChecking for development libraries: pci and zlib... "
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010077 @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 Legoll0d2ff132017-05-07 17:51:25 +020080 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 Deppenwiesed8fe4432016-03-18 00:52:54 +010082 rm -f .test.c .test; exit 1)
83 @rm -rf .test.c .test .test.dSYM
84
85install: $(PROGRAM)
86 mkdir -p $(DESTDIR)$(PREFIX)/sbin
87 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
88
Matthias Gazzarid88cd702018-05-21 20:54:41 +020089.PHONY: all clean distclean dep pciutils oldarc
Philipp Deppenwiesed8fe4432016-03-18 00:52:54 +010090
91-include .dependencies