Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 1 | # |
| 2 | # Makefile for inteltool utility |
| 3 | # |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 4 | # Copyright (C) 2008 by coresystems GmbH |
| 5 | # written by Stefan Reinauer <stepan@coresystems.de> |
| 6 | # |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 17 | |
| 18 | PROGRAM = inteltool |
| 19 | |
Paul Menzel | 9ebd8ea | 2013-03-31 22:15:43 +0200 | [diff] [blame] | 20 | CC ?= gcc |
| 21 | INSTALL ?= /usr/bin/install |
| 22 | PREFIX ?= /usr/local |
| 23 | CFLAGS ?= -O2 -g -Wall -W |
| 24 | LDFLAGS += -lpci -lz |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 25 | |
Iru Cai | 904538b | 2016-06-08 22:39:22 +0800 | [diff] [blame] | 26 | OBJS = inteltool.o cpu.o gpio.o rootcmplx.o powermgt.o memory.o pcie.o amb.o ivy_memory.o spi.o gfx.o ahci.o |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 27 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 28 | OS_ARCH = $(shell uname) |
| 29 | ifeq ($(OS_ARCH), Darwin) |
Paul Menzel | 9ebd8ea | 2013-03-31 22:15:43 +0200 | [diff] [blame] | 30 | LDFLAGS += -framework DirectHW |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 31 | endif |
Idwer Vollering | 3f91d81 | 2010-10-24 13:50:13 +0000 | [diff] [blame] | 32 | ifeq ($(OS_ARCH), FreeBSD) |
| 33 | CFLAGS += -I/usr/local/include |
| 34 | LDFLAGS += -L/usr/local/lib |
| 35 | LIBS = -lz |
| 36 | endif |
Andrey Korolyov | 046d217 | 2016-01-05 19:59:06 +0300 | [diff] [blame] | 37 | ifeq ($(OS_ARCH), NetBSD) |
| 38 | CFLAGS += -I/usr/pkg/include |
| 39 | LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib -lz -lpciutils -lpci -l$(shell uname -p) |
| 40 | endif |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 41 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 42 | all: pciutils dep $(PROGRAM) |
| 43 | |
| 44 | $(PROGRAM): $(OBJS) |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 45 | $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS) |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 46 | |
| 47 | clean: |
Martin Roth | 0be83c0 | 2015-10-21 14:50:00 -0600 | [diff] [blame] | 48 | rm -f $(PROGRAM) *.o *~ junit.xml |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 49 | |
| 50 | distclean: clean |
Stefan Reinauer | 8b83597 | 2008-06-22 17:15:03 +0000 | [diff] [blame] | 51 | rm -f .dependencies |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 52 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 53 | dep: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 54 | @$(CC) $(CFLAGS) -MM *.c > .dependencies |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 55 | |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 56 | define LIBPCI_TEST |
| 57 | /* Avoid a failing test due to libpci header symbol shadowing breakage */ |
| 58 | #define index shadow_workaround_index |
Andrey Korolyov | 046d217 | 2016-01-05 19:59:06 +0300 | [diff] [blame] | 59 | #ifdef __NetBSD__ |
| 60 | #include <pciutils/pci.h> |
| 61 | #else |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 62 | #include <pci/pci.h> |
Andrey Korolyov | 046d217 | 2016-01-05 19:59:06 +0300 | [diff] [blame] | 63 | #endif |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 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 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 75 | pciutils: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 76 | @printf "\nChecking for pciutils and zlib... " |
Stefan Tauner | fba86bf | 2012-10-12 10:36:49 +0200 | [diff] [blame] | 77 | @echo "$$LIBPCI_TEST" > .test.c |
Stefan Tauner | f450b86 | 2012-10-13 02:33:35 +0200 | [diff] [blame] | 78 | @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) >/dev/null 2>&1 && \ |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 79 | printf "found.\n" || ( printf "not found.\n\n"; \ |
| 80 | printf "Please install pciutils-devel and zlib-devel.\n"; \ |
| 81 | printf "See README for more information.\n\n"; \ |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 82 | rm -f .test.c .test; exit 1) |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 83 | @rm -rf .test.c .test .test.dSYM |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 84 | |
| 85 | install: $(PROGRAM) |
Stefan Reinauer | f7f2f25 | 2009-09-01 09:52:14 +0000 | [diff] [blame] | 86 | mkdir -p $(DESTDIR)$(PREFIX)/sbin |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 87 | $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin |
| 88 | mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8 |
Lubomir Rintel | ba1f9aa | 2014-01-28 16:52:48 +0000 | [diff] [blame] | 89 | $(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8 |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 90 | |
| 91 | .PHONY: all clean distclean dep pciutils |
| 92 | |
| 93 | -include .dependencies |