blob: 4461f8615b49c7bfc9152ddf2480616a6ecf1960 [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
8# the License, or any later version.
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
15PROGRAM = intelmetool
16
17CC ?= gcc
18INSTALL ?= /usr/bin/install
19PREFIX ?= /usr/local
20CFLAGS ?= -O0 -g -Wall -W -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-sign-compare -Wno-unused-function
21LDFLAGS += -lpci -lz
22
23OBJS = intelmetool.o me.o me_status.o mmap.o
24
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
41$(PROGRAM): $(OBJS)
42 $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
43
44clean:
45 rm -f $(PROGRAM) *.o *~ junit.xml
46
47distclean: clean
48 rm -f .dependencies
49
50dep:
51 @$(CC) $(CFLAGS) -MM *.c > .dependencies
52
53define LIBPCI_TEST
54/* Avoid a failing test due to libpci header symbol shadowing breakage */
55#define index shadow_workaround_index
56#ifdef __NetBSD__
57#include <pciutils/pci.h>
58#else
59#include <pci/pci.h>
60#endif
61struct pci_access *pacc;
62int main(int argc, char **argv)
63{
64 (void) argc;
65 (void) argv;
66 pacc = pci_alloc();
67 return 0;
68}
69endef
70export LIBPCI_TEST
71
72pciutils:
73 @printf "\nChecking for pciutils and zlib... "
74 @echo "$$LIBPCI_TEST" > .test.c
75 @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) >/dev/null 2>&1 && \
76 printf "found.\n" || ( printf "not found.\n\n"; \
77 printf "Please install pciutils-devel and zlib-devel.\n"; \
78 rm -f .test.c .test; exit 1)
79 @rm -rf .test.c .test .test.dSYM
80
81install: $(PROGRAM)
82 mkdir -p $(DESTDIR)$(PREFIX)/sbin
83 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
84
85.PHONY: all clean distclean dep pciutils
86
87-include .dependencies