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 | # |
| 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 | |
| 22 | PROGRAM = inteltool |
| 23 | |
| 24 | CC = gcc |
| 25 | INSTALL = /usr/bin/install |
| 26 | PREFIX = /usr/local |
| 27 | CFLAGS = -O2 -g -Wall -W |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 28 | LDFLAGS = -lpci -lz |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 29 | |
Sven Schnelle | 4b7b320 | 2012-01-08 15:27:18 +0100 | [diff] [blame] | 30 | OBJS = inteltool.o cpu.o gpio.o rootcmplx.o powermgt.o memory.o pcie.o amb.o |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 31 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 32 | OS_ARCH = $(shell uname) |
| 33 | ifeq ($(OS_ARCH), Darwin) |
Stefan Reinauer | cff573d | 2011-03-18 22:08:39 +0000 | [diff] [blame] | 34 | LDFLAGS = -framework DirectHW -lpci -lz |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 35 | endif |
Idwer Vollering | 3f91d81 | 2010-10-24 13:50:13 +0000 | [diff] [blame] | 36 | ifeq ($(OS_ARCH), FreeBSD) |
| 37 | CFLAGS += -I/usr/local/include |
| 38 | LDFLAGS += -L/usr/local/lib |
| 39 | LIBS = -lz |
| 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: |
Stefan Reinauer | 8b83597 | 2008-06-22 17:15:03 +0000 | [diff] [blame] | 48 | rm -f $(PROGRAM) *.o *~ |
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 | |
| 56 | pciutils: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 57 | @printf "\nChecking for pciutils and zlib... " |
| 58 | @$(shell ( printf "#include <pci/pci.h>\n"; \ |
| 59 | printf "struct pci_access *pacc;\n"; \ |
| 60 | printf "int main(int argc, char **argv)\n"; \ |
| 61 | printf "{ pacc = pci_alloc(); return 0; }\n"; ) > .test.c ) |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 62 | @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) &>/dev/null && \ |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 63 | printf "found.\n" || ( printf "not found.\n\n"; \ |
| 64 | printf "Please install pciutils-devel and zlib-devel.\n"; \ |
| 65 | printf "See README for more information.\n\n"; \ |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 66 | rm -f .test.c .test; exit 1) |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 67 | @rm -rf .test.c .test .test.dSYM |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 68 | |
| 69 | install: $(PROGRAM) |
Stefan Reinauer | f7f2f25 | 2009-09-01 09:52:14 +0000 | [diff] [blame] | 70 | mkdir -p $(DESTDIR)$(PREFIX)/sbin |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 71 | $(INSTALL) $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin |
| 72 | mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8 |
| 73 | $(INSTALL) $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8 |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 74 | |
| 75 | .PHONY: all clean distclean dep pciutils |
| 76 | |
| 77 | -include .dependencies |
| 78 | |