Stefan Reinauer | 6559f43 | 2010-12-17 00:13:54 +0000 | [diff] [blame] | 1 | ## |
| 2 | ## Makefile for k8resdump utility |
| 3 | ## |
| 4 | ## (C) 2005 coresystems GmbH |
| 5 | ## |
| 6 | ## This program is free software; you can redistribute it and/or modify |
| 7 | ## it under the terms of the GNU General Public License as published by |
| 8 | ## the Free Software Foundation; version 2 of the License. |
| 9 | ## |
| 10 | ## This program is distributed in the hope that it will be useful, |
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ## GNU General Public License for more details. |
| 14 | ## |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 15 | |
| 16 | PROGRAM = k8resdump |
| 17 | |
| 18 | CC = gcc |
Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 19 | INSTALL = /usr/bin/env install |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 20 | PREFIX = /usr/local |
| 21 | #CFLAGS = -O2 -g -Wall -Werror |
| 22 | CFLAGS = -Os -Wall -Werror |
| 23 | OS_ARCH = $(shell uname) |
| 24 | ifeq ($(OS_ARCH), SunOS) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 25 | LDFLAGS = -lpci |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 26 | else |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 27 | LDFLAGS = -lpci -lz -static |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 28 | endif |
| 29 | |
| 30 | OBJS = k8resdump.o |
| 31 | |
| 32 | all: pciutils dep $(PROGRAM) |
| 33 | |
| 34 | $(PROGRAM): $(OBJS) |
| 35 | $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS) |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 36 | |
| 37 | clean: |
| 38 | rm -f *.o *~ |
| 39 | |
| 40 | distclean: clean |
| 41 | rm -f $(PROGRAM) .dependencies |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 42 | |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 43 | dep: |
| 44 | @$(CC) -MM *.c > .dependencies |
| 45 | |
| 46 | pciutils: |
| 47 | @echo; echo -n "Checking for pciutils and zlib... " |
| 48 | @$(shell ( echo "#include <pci/pci.h>"; \ |
| 49 | echo "struct pci_access *pacc;"; \ |
| 50 | echo "int main(int argc, char **argv)"; \ |
| 51 | echo "{ pacc = pci_alloc(); return 0; }"; ) > .test.c ) |
| 52 | @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) &>/dev/null && \ |
| 53 | echo "found." || ( echo "not found."; echo; \ |
| 54 | echo "Please install pciutils-devel and zlib-devel."; \ |
| 55 | echo "See README for more information."; echo; \ |
| 56 | rm -f .test.c .test; exit 1) |
| 57 | @rm -f .test.c .test |
| 58 | |
| 59 | .PHONY: all clean distclean dep pciutils |
| 60 | |
| 61 | -include .dependencies |