1 # SPDX-License-Identifier: GPL-2.0-or-later
5 top ?
= $(abspath ..
/..
)
8 INSTALL ?
= /usr
/bin
/env
install
10 CFLAGS ?
= -O2
-g
-Wall
-Wextra
-Wmissing-prototypes
13 CPPFLAGS
+= -I
$(top
)/util
/inteltool
14 CPPFLAGS
+= -I
$(top
)/src
/commonlib
/include -I
$(top
)/src
/commonlib
/bsd
/include
15 CPPFLAGS
+= -I
$(top
)/src
/arch
/x86
/include
18 OBJS
= inteltool.o pcr.o cpu.o gpio.o gpio_groups.o rootcmplx.o powermgt.o \
19 memory.o pcie.o amb.o ivy_memory.o spi.o gfx.o ahci.o lpc.o iobp.o
21 OS_ARCH
= $(shell uname
)
22 ifeq ($(OS_ARCH
), Darwin
)
23 LDFLAGS
+= -framework DirectHW
25 ifeq ($(OS_ARCH
), FreeBSD
)
26 CPPFLAGS
+= -I
/usr
/local
/include
27 LDFLAGS
+= -L
/usr
/local
/lib
30 ifeq ($(OS_ARCH
), NetBSD
)
31 CPPFLAGS
+= -I
/usr
/pkg
/include
32 LDFLAGS
+= -L
/usr
/pkg
/lib
-Wl
,-rpath-link
,/usr
/pkg
/lib
-lz
-lpciutils
-lpci
-l
$(shell uname
-p
)
35 all: pciutils dep
$(PROGRAM
)
38 $(CC
) $(CFLAGS
) $(CPPFLAGS
) -o
$(PROGRAM
) $(OBJS
) $(LDFLAGS
)
41 rm -f
$(PROGRAM
) *.o
*~ junit.xml .dependencies
47 @
$(CC
) $(CFLAGS
) $(CPPFLAGS
) -MM
*.c
> .dependencies
50 /* Avoid a failing
test due to libpci header symbol shadowing breakage
*/
51 #define index shadow_workaround_index
53 #include <pciutils/pci.h>
57 struct pci_access
*pacc
;
58 int main
(int argc
, char
**argv
)
69 @printf
"\nChecking for pciutils and zlib... "
70 @echo
"$$LIBPCI_TEST" > .
test.c
71 @
$(CC
) $(CFLAGS
) $(CPPFLAGS
) .
test.c
-o .
test $(LDFLAGS
) \
73 printf
"found.\n" ||
( printf
"not found.\n\n"; \
74 printf
"Please install pciutils-devel and zlib-devel.\n"; \
75 printf
"See README for more information.\n\n"; \
76 rm -f .
test.c .
test; exit
1)
77 @
rm -rf .
test.c .
test .
test.dSYM
80 $(INSTALL
) -d
$(DESTDIR
)$(PREFIX
)/sbin
81 $(INSTALL
) $(PROGRAM
) $(DESTDIR
)$(PREFIX
)/sbin
82 $(INSTALL
) -d
$(DESTDIR
)$(PREFIX
)/share
/man
/man8
83 $(INSTALL
) -p
-m644
$(PROGRAM
).8 $(DESTDIR
)$(PREFIX
)/share
/man
/man8
85 .PHONY
: all clean distclean dep pciutils
87 -include .dependencies