2 # Makefile for viatool utility
4 # Copyright (C) 2008 by coresystems GmbH
5 # written by Stefan Reinauer <stepan@coresystems.de>
6 # Copyright (C) 2013 Alexandru Gagniuc
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 INSTALL ?
= /usr
/bin
/install
28 CFLAGS ?
= -O2
-g
-Wall
-W
-I
$(shell pwd
)
36 OBJS
= $(sort ${SRCS
:.c
=.o
})
38 OS_ARCH
= $(shell uname
)
39 ifeq ($(OS_ARCH
), Darwin
)
40 LDFLAGS
+= -framework DirectHW
42 ifeq ($(OS_ARCH
), FreeBSD
)
43 CFLAGS
+= -I
/usr
/local
/include
44 LDFLAGS
+= -L
/usr
/local
/lib
48 all: pciutils dep
$(PROGRAM
)
51 $(CC
) $(CFLAGS
) -o
$(PROGRAM
) $(OBJS
) $(LDFLAGS
)
54 # Remove build results
55 rm -f
$(PROGRAM
) $(OBJS
)
56 # Remove backup files created by some editors
57 find .
/ |grep
*~ |xargs
rm -f
63 @
$(CC
) $(CFLAGS
) -MM
*.c
> .dependencies
66 /* Avoid a failing
test due to libpci header symbol shadowing breakage
*/
67 #define index shadow_workaround_index
69 struct pci_access
*pacc
;
70 int main
(int argc
, char
**argv
)
81 @printf
"\nChecking for pciutils and zlib... "
82 @echo
"$$LIBPCI_TEST" > .
test.c
83 @
$(CC
) $(CFLAGS
) .
test.c
-o .
test $(LDFLAGS
) >/dev
/null
2>&1 && \
84 printf
"found.\n" ||
( printf
"not found.\n\n"; \
85 printf
"Please install pciutils-devel and zlib-devel.\n"; \
86 printf
"See README for more information.\n\n"; \
87 rm -f .
test.c .
test; exit
1)
88 @
rm -rf .
test.c .
test .
test.dSYM
91 mkdir
-p
$(DESTDIR
)$(PREFIX
)/sbin
92 $(INSTALL
) $(PROGRAM
) $(DESTDIR
)$(PREFIX
)/sbin
93 mkdir
-p
$(DESTDIR
)$(PREFIX
)/share
/man
/man8
94 $(INSTALL
) $(PROGRAM
).8 $(DESTDIR
)$(PREFIX
)/share
/man
/man8
96 .PHONY
: all clean distclean dep pciutils
98 -include .dependencies