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 |
| 19 | STRIP = strip |
| 20 | INSTALL = /usr/bin/install |
| 21 | PREFIX = /usr/local |
| 22 | #CFLAGS = -O2 -g -Wall -Werror |
| 23 | CFLAGS = -Os -Wall -Werror |
| 24 | OS_ARCH = $(shell uname) |
| 25 | ifeq ($(OS_ARCH), SunOS) |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 26 | LDFLAGS = -lpci |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 27 | else |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 28 | LDFLAGS = -lpci -lz -static |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 29 | STRIP_ARGS = -s |
| 30 | endif |
| 31 | |
| 32 | OBJS = k8resdump.o |
| 33 | |
| 34 | all: pciutils dep $(PROGRAM) |
| 35 | |
| 36 | $(PROGRAM): $(OBJS) |
| 37 | $(CC) -o $(PROGRAM) $(OBJS) $(LDFLAGS) |
| 38 | $(STRIP) $(STRIP_ARGS) $(PROGRAM) |
| 39 | |
| 40 | clean: |
| 41 | rm -f *.o *~ |
| 42 | |
| 43 | distclean: clean |
| 44 | rm -f $(PROGRAM) .dependencies |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 45 | |
Rudolf Marek | f32325e | 2007-10-30 01:12:20 +0000 | [diff] [blame] | 46 | dep: |
| 47 | @$(CC) -MM *.c > .dependencies |
| 48 | |
| 49 | pciutils: |
| 50 | @echo; echo -n "Checking for pciutils and zlib... " |
| 51 | @$(shell ( echo "#include <pci/pci.h>"; \ |
| 52 | echo "struct pci_access *pacc;"; \ |
| 53 | echo "int main(int argc, char **argv)"; \ |
| 54 | echo "{ pacc = pci_alloc(); return 0; }"; ) > .test.c ) |
| 55 | @$(CC) $(CFLAGS) .test.c -o .test $(LDFLAGS) &>/dev/null && \ |
| 56 | echo "found." || ( echo "not found."; echo; \ |
| 57 | echo "Please install pciutils-devel and zlib-devel."; \ |
| 58 | echo "See README for more information."; echo; \ |
| 59 | rm -f .test.c .test; exit 1) |
| 60 | @rm -f .test.c .test |
| 61 | |
| 62 | .PHONY: all clean distclean dep pciutils |
| 63 | |
| 64 | -include .dependencies |