blob: cd02fa8abef0075fd1852b9d183964910397f594 [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
Nico Huberaf83db22017-04-05 17:30:20 +020020top ?= $(abspath ../..)
21
Paul Menzel9ebd8ea2013-03-31 22:15:43 +020022CC ?= gcc
Yegor Timoshenkoc2e49412018-10-07 01:58:27 +000023INSTALL ?= /usr/bin/env install
Paul Menzel9ebd8ea2013-03-31 22:15:43 +020024PREFIX ?= /usr/local
Jacob Garber52f0e842019-07-19 12:27:27 -060025CFLAGS ?= -O2 -g -Wall -Wextra -Wmissing-prototypes
Paul Menzel9ebd8ea2013-03-31 22:15:43 +020026LDFLAGS += -lpci -lz
Stefan Reinauer03646be2008-05-13 22:14:21 +000027
Nico Hubercce508f2017-06-13 12:51:54 +020028CPPFLAGS += -I$(top)/src/commonlib/include
29
Nico Huber18980232017-04-07 12:26:07 +020030OBJS = inteltool.o pcr.o cpu.o gpio.o gpio_groups.o rootcmplx.o powermgt.o \
Nico Huber99b02a12017-04-05 17:39:57 +020031 memory.o pcie.o amb.o ivy_memory.o spi.o gfx.o ahci.o \
Stefan Reinauer03646be2008-05-13 22:14:21 +000032
Stefan Reinauer1162f252008-12-04 15:18:20 +000033OS_ARCH = $(shell uname)
34ifeq ($(OS_ARCH), Darwin)
Paul Menzel9ebd8ea2013-03-31 22:15:43 +020035LDFLAGS += -framework DirectHW
Stefan Reinauer1162f252008-12-04 15:18:20 +000036endif
Idwer Vollering3f91d812010-10-24 13:50:13 +000037ifeq ($(OS_ARCH), FreeBSD)
Nico Hubercce508f2017-06-13 12:51:54 +020038CPPFLAGS += -I/usr/local/include
Idwer Vollering3f91d812010-10-24 13:50:13 +000039LDFLAGS += -L/usr/local/lib
40LIBS = -lz
41endif
Andrey Korolyov046d2172016-01-05 19:59:06 +030042ifeq ($(OS_ARCH), NetBSD)
Nico Hubercce508f2017-06-13 12:51:54 +020043CPPFLAGS += -I/usr/pkg/include
Andrey Korolyov046d2172016-01-05 19:59:06 +030044LDFLAGS += -L/usr/pkg/lib -Wl,-rpath-link,/usr/pkg/lib -lz -lpciutils -lpci -l$(shell uname -p)
45endif
Stefan Reinauer1162f252008-12-04 15:18:20 +000046
Stefan Reinauer03646be2008-05-13 22:14:21 +000047all: pciutils dep $(PROGRAM)
48
49$(PROGRAM): $(OBJS)
Nico Hubercce508f2017-06-13 12:51:54 +020050 $(CC) $(CFLAGS) $(CPPFLAGS) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
Stefan Reinauer03646be2008-05-13 22:14:21 +000051
52clean:
Nico Hubercde2bdf2017-06-13 12:54:28 +020053 rm -f $(PROGRAM) *.o *~ junit.xml .dependencies
Stefan Reinauer03646be2008-05-13 22:14:21 +000054
55distclean: clean
Stefan Reinauer8b835972008-06-22 17:15:03 +000056 rm -f .dependencies
Uwe Hermann9a6b6b52008-05-14 21:20:55 +000057
Stefan Reinauer03646be2008-05-13 22:14:21 +000058dep:
Nico Hubercce508f2017-06-13 12:51:54 +020059 @$(CC) $(CFLAGS) $(CPPFLAGS) -MM *.c > .dependencies
Stefan Reinauer03646be2008-05-13 22:14:21 +000060
Stefan Taunerfba86bf2012-10-12 10:36:49 +020061define LIBPCI_TEST
62/* Avoid a failing test due to libpci header symbol shadowing breakage */
63#define index shadow_workaround_index
Andrey Korolyov046d2172016-01-05 19:59:06 +030064#ifdef __NetBSD__
65#include <pciutils/pci.h>
66#else
Stefan Taunerfba86bf2012-10-12 10:36:49 +020067#include <pci/pci.h>
Andrey Korolyov046d2172016-01-05 19:59:06 +030068#endif
Stefan Taunerfba86bf2012-10-12 10:36:49 +020069struct pci_access *pacc;
70int main(int argc, char **argv)
71{
72 (void) argc;
73 (void) argv;
74 pacc = pci_alloc();
75 return 0;
76}
77endef
78export LIBPCI_TEST
79
Stefan Reinauer03646be2008-05-13 22:14:21 +000080pciutils:
Stefan Reinauer1162f252008-12-04 15:18:20 +000081 @printf "\nChecking for pciutils and zlib... "
Stefan Taunerfba86bf2012-10-12 10:36:49 +020082 @echo "$$LIBPCI_TEST" > .test.c
Nico Hubercce508f2017-06-13 12:51:54 +020083 @$(CC) $(CFLAGS) $(CPPFLAGS) .test.c -o .test $(LDFLAGS) \
84 >/dev/null 2>&1 && \
85 printf "found.\n" || ( printf "not found.\n\n"; \
Stefan Reinauer1162f252008-12-04 15:18:20 +000086 printf "Please install pciutils-devel and zlib-devel.\n"; \
87 printf "See README for more information.\n\n"; \
Stefan Reinauer03646be2008-05-13 22:14:21 +000088 rm -f .test.c .test; exit 1)
Stefan Reinauer1162f252008-12-04 15:18:20 +000089 @rm -rf .test.c .test .test.dSYM
Stefan Reinauer03646be2008-05-13 22:14:21 +000090
91install: $(PROGRAM)
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000092 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Stefan Reinauer1162f252008-12-04 15:18:20 +000093 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
94 mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
Lubomir Rintelba1f9aa2014-01-28 16:52:48 +000095 $(INSTALL) -p -m644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
Stefan Reinauer03646be2008-05-13 22:14:21 +000096
97.PHONY: all clean distclean dep pciutils
98
99-include .dependencies