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 |
| 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 | |
| 15 | PROGRAM = intelmetool |
| 16 | |
| 17 | CC ?= gcc |
| 18 | INSTALL ?= /usr/bin/install |
| 19 | PREFIX ?= /usr/local |
| 20 | CFLAGS ?= -O0 -g -Wall -W -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-sign-compare -Wno-unused-function |
| 21 | LDFLAGS += -lpci -lz |
| 22 | |
| 23 | OBJS = intelmetool.o me.o me_status.o mmap.o |
| 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 | |
| 41 | $(PROGRAM): $(OBJS) |
| 42 | $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS) |
| 43 | |
| 44 | clean: |
| 45 | rm -f $(PROGRAM) *.o *~ junit.xml |
| 46 | |
| 47 | distclean: clean |
| 48 | rm -f .dependencies |
| 49 | |
| 50 | dep: |
| 51 | @$(CC) $(CFLAGS) -MM *.c > .dependencies |
| 52 | |
| 53 | define 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 |
| 61 | struct pci_access *pacc; |
| 62 | int main(int argc, char **argv) |
| 63 | { |
| 64 | (void) argc; |
| 65 | (void) argv; |
| 66 | pacc = pci_alloc(); |
| 67 | return 0; |
| 68 | } |
| 69 | endef |
| 70 | export LIBPCI_TEST |
| 71 | |
| 72 | pciutils: |
| 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 | |
| 81 | install: $(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 |