blob: 6e202cf81f87a31e856b78c8d4f5517123350368 [file] [log] [blame]
Stefan Reinauer03646be2008-05-13 22:14:21 +00001#
2# Makefile for inteltool utility
3#
Stefan Reinauer14e22772010-04-27 06:56:47 +00004# Copyright (C) 2008 by coresystems GmbH
5# written by Stefan Reinauer <stepan@coresystems.de>
6#
Stefan Reinauer03646be2008-05-13 22:14:21 +00007# 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 Reinauer03646be2008-05-13 22:14:21 +000017
18PROGRAM = inteltool
19
Paul Menzel9ebd8ea2013-03-31 22:15:43 +020020CC ?= gcc
21INSTALL ?= /usr/bin/install
22PREFIX ?= /usr/local
23CFLAGS ?= -O2 -g -Wall -W
24LDFLAGS += -lpci -lz
Stefan Reinauer03646be2008-05-13 22:14:21 +000025
Vladimir Serbinenko188aec02015-05-20 14:04:41 +020026OBJS = inteltool.o cpu.o gpio.o rootcmplx.o powermgt.o memory.o pcie.o amb.o ivy_memory.o spi.o gfx.o
Stefan Reinauer03646be2008-05-13 22:14:21 +000027
Stefan Reinauer1162f252008-12-04 15:18:20 +000028OS_ARCH = $(shell uname)
29ifeq ($(OS_ARCH), Darwin)
Paul Menzel9ebd8ea2013-03-31 22:15:43 +020030LDFLAGS += -framework DirectHW
Stefan Reinauer1162f252008-12-04 15:18:20 +000031endif
Idwer Vollering3f91d812010-10-24 13:50:13 +000032ifeq ($(OS_ARCH), FreeBSD)
33CFLAGS += -I/usr/local/include
34LDFLAGS += -L/usr/local/lib
35LIBS = -lz
36endif
Stefan Reinauer1162f252008-12-04 15:18:20 +000037
Stefan Reinauer03646be2008-05-13 22:14:21 +000038all: pciutils dep $(PROGRAM)
39
40$(PROGRAM): $(OBJS)
Stefan Reinauera7b296d2011-11-14 12:40:34 -080041 $(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
Stefan Reinauer03646be2008-05-13 22:14:21 +000042
43clean:
Martin Roth0be83c02015-10-21 14:50:00 -060044 rm -f $(PROGRAM) *.o *~ junit.xml
Stefan Reinauer03646be2008-05-13 22:14:21 +000045
46distclean: clean
Stefan Reinauer8b835972008-06-22 17:15:03 +000047 rm -f .dependencies
Uwe Hermann9a6b6b52008-05-14 21:20:55 +000048
Stefan Reinauer03646be2008-05-13 22:14:21 +000049dep:
Stefan Reinauer1162f252008-12-04 15:18:20 +000050 @$(CC) $(CFLAGS) -MM *.c > .dependencies
Stefan Reinauer03646be2008-05-13 22:14:21 +000051
Stefan Taunerfba86bf2012-10-12 10:36:49 +020052define LIBPCI_TEST
53/* Avoid a failing test due to libpci header symbol shadowing breakage */
54#define index shadow_workaround_index
55#include <pci/pci.h>
56struct pci_access *pacc;
57int main(int argc, char **argv)
58{
59 (void) argc;
60 (void) argv;
61 pacc = pci_alloc();
62 return 0;
63}
64endef
65export LIBPCI_TEST
66
Stefan Reinauer03646be2008-05-13 22:14:21 +000067pciutils:
Stefan Reinauer1162f252008-12-04 15:18:20 +000068 @printf "\nChecking for pciutils and zlib... "
Stefan Taunerfba86bf2012-10-12 10:36:49 +020069 @echo "$$LIBPCI_TEST" > .test.c
Stefan Taunerf450b862012-10-13 02:33:35 +020070 @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) >/dev/null 2>&1 && \
Stefan Reinauer1162f252008-12-04 15:18:20 +000071 printf "found.\n" || ( printf "not found.\n\n"; \
72 printf "Please install pciutils-devel and zlib-devel.\n"; \
73 printf "See README for more information.\n\n"; \
Stefan Reinauer03646be2008-05-13 22:14:21 +000074 rm -f .test.c .test; exit 1)
Stefan Reinauer1162f252008-12-04 15:18:20 +000075 @rm -rf .test.c .test .test.dSYM
Stefan Reinauer03646be2008-05-13 22:14:21 +000076
77install: $(PROGRAM)
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000078 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Stefan Reinauer1162f252008-12-04 15:18:20 +000079 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
80 mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
Lubomir Rintelba1f9aa2014-01-28 16:52:48 +000081 $(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
Stefan Reinauer03646be2008-05-13 22:14:21 +000082
83.PHONY: all clean distclean dep pciutils
84
85-include .dependencies