blob: 248e51f726804d5267275b8a8f641d4499633aa8 [file] [log] [blame]
Stefan Reinauer03646be2008-05-13 22:14:21 +00001#
2# Makefile for inteltool utility
3#
4# Copyright (C) 2008 by coresystems GmbH
5# written by Stefan Reinauer <stepan@coresystems.de>
6#
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#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20#
21
22PROGRAM = inteltool
23
24CC = gcc
25INSTALL = /usr/bin/install
26PREFIX = /usr/local
27CFLAGS = -O2 -g -Wall -W
28LDFLAGS = -lpci -lz
29
Stefan Reinauer23190272008-08-20 13:41:24 +000030OBJS = inteltool.o cpu.o gpio.o rootcmplx.o powermgt.o memory.o pcie.o
Stefan Reinauer03646be2008-05-13 22:14:21 +000031
Stefan Reinauer1162f252008-12-04 15:18:20 +000032OS_ARCH = $(shell uname)
33ifeq ($(OS_ARCH), Darwin)
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000034LDFLAGS = -framework DirectIO -lpci -lz
Stefan Reinauer1162f252008-12-04 15:18:20 +000035endif
36
Stefan Reinauer03646be2008-05-13 22:14:21 +000037all: pciutils dep $(PROGRAM)
38
39$(PROGRAM): $(OBJS)
40 $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS)
41
42clean:
Stefan Reinauer8b835972008-06-22 17:15:03 +000043 rm -f $(PROGRAM) *.o *~
Stefan Reinauer03646be2008-05-13 22:14:21 +000044
45distclean: clean
Stefan Reinauer8b835972008-06-22 17:15:03 +000046 rm -f .dependencies
Uwe Hermann9a6b6b52008-05-14 21:20:55 +000047
Stefan Reinauer03646be2008-05-13 22:14:21 +000048dep:
Stefan Reinauer1162f252008-12-04 15:18:20 +000049 @$(CC) $(CFLAGS) -MM *.c > .dependencies
Stefan Reinauer03646be2008-05-13 22:14:21 +000050
51pciutils:
Stefan Reinauer1162f252008-12-04 15:18:20 +000052 @printf "\nChecking for pciutils and zlib... "
53 @$(shell ( printf "#include <pci/pci.h>\n"; \
54 printf "struct pci_access *pacc;\n"; \
55 printf "int main(int argc, char **argv)\n"; \
56 printf "{ pacc = pci_alloc(); return 0; }\n"; ) > .test.c )
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000057 @$(CC) $(CFLAGS) $(LDFLAGS) .test.c -o .test &>/dev/null && \
Stefan Reinauer1162f252008-12-04 15:18:20 +000058 printf "found.\n" || ( printf "not found.\n\n"; \
59 printf "Please install pciutils-devel and zlib-devel.\n"; \
60 printf "See README for more information.\n\n"; \
Stefan Reinauer03646be2008-05-13 22:14:21 +000061 rm -f .test.c .test; exit 1)
Stefan Reinauer1162f252008-12-04 15:18:20 +000062 @rm -rf .test.c .test .test.dSYM
Stefan Reinauer03646be2008-05-13 22:14:21 +000063
64install: $(PROGRAM)
Stefan Reinauerf7f2f252009-09-01 09:52:14 +000065 mkdir -p $(DESTDIR)$(PREFIX)/sbin
Stefan Reinauer1162f252008-12-04 15:18:20 +000066 $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
67 mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
68 $(INSTALL) $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
Stefan Reinauer03646be2008-05-13 22:14:21 +000069
70.PHONY: all clean distclean dep pciutils
71
72-include .dependencies
73