Makefile 2.31 KB
Newer Older
1
#
Uwe Hermann's avatar
Uwe Hermann committed
2
# Makefile for flashrom utility
3 4 5
# 
# redone by Stefan Reinauer <stepan@openbios.org>
#
6

7
PROGRAM = flashrom
Ronald G. Minnich's avatar
Ronald G. Minnich committed
8

9
CC     ?= gcc
10
STRIP	= strip
11 12 13 14 15 16 17
INSTALL = install
PREFIX  ?= /usr/local
CFLAGS  ?= -Os -Wall -Werror

prefix = $(DESTDIR)$(PREFIX)
man8dir = $(prefix)/share/man/man8
sbindir = $(prefix)/sbin
Peter Stuge's avatar
Peter Stuge committed
18

19
OS_ARCH	= $(shell uname)
Peter Stuge's avatar
Peter Stuge committed
20
ifneq ($(OS_ARCH), SunOS)
21 22
STRIP_ARGS = -s
endif
Stefan Reinauer's avatar
Stefan Reinauer committed
23 24 25 26
ifeq ($(OS_ARCH), Darwin)
CFLAGS += -I/usr/local/include
LDFLAGS += -framework IOKit -framework DirectIO -L/usr/local/lib
endif
27 28 29 30
ifeq ($(OS_ARCH), FreeBSD)
CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib
endif
31

32
LIBS += -lpci -lz
Peter Stuge's avatar
Peter Stuge committed
33

34
OBJS = chipset_enable.o board_enable.o udelay.o jedec.o stm50flw0x0x.o \
35
	sst28sf040.o am29f040b.o mx29f002.o m29f400bt.o \
36
	w49f002u.o 82802ab.o pm49fl00x.o sst49lf040.o en29f002a.o \
37
	sst49lfxxxc.o sst_fwhub.o layout.o cbtable.o flashchips.o physmap.o \
38
	flashrom.o w39v080fa.o sharplhf00l04.o w29ee011.o spi.o it87spi.o \
39
	ichspi.o w39v040c.o sb600spi.o wbsio_spi.o m29f002.o internal.o \
40
	dummyflasher.o nic3com.o
41

42
all: pciutils dep $(PROGRAM)
43

44 45 46 47
# Set the flashrom version string from the highest revision number
# of the checked out flashrom files.
SVNDEF := -D'FLASHROM_VERSION="0.9.0-r$(shell svnversion -cn . \
          | sed -e "s/.*://" -e "s/\([0-9]*\).*/\1/")"'
48

49
$(PROGRAM): $(OBJS)
50
	$(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
51

52 53 54
flashrom.o: flashrom.c
	$(CC) -c $(CFLAGS) $(SVNDEF) $(CPPFLAGS) $< -o $@

55
clean:
56
	rm -f $(PROGRAM) *.o
57 58

distclean: clean
Peter Stuge's avatar
Peter Stuge committed
59 60
	rm -f .dependencies

61
dep:
62 63 64 65
	@$(CC) $(CPPFLAGS) $(SVNDEF) -MM *.c > .dependencies

strip: $(PROGRAM)
	$(STRIP) $(STRIP_ARGS) $(PROGRAM)
66

67
pciutils:
68
	@echo; printf "Checking for pciutils and zlib... "
69 70 71 72
	@$(shell ( echo "#include <pci/pci.h>";		   \
		   echo "struct pci_access *pacc;";	   \
		   echo "int main(int argc, char **argv)"; \
		   echo "{ pacc = pci_alloc(); return 0; }"; ) > .test.c )
73
	@$(CC) $(CFLAGS) $(LDFLAGS) .test.c -o .test $(LIBS) >/dev/null 2>&1 &&	\
74
		echo "found." || ( echo "not found."; echo;		\
75
		echo "Please install pciutils-devel and zlib-devel.";	\
76 77 78 79
		echo "See README for more information."; echo;		\
		rm -f .test.c .test; exit 1)
	@rm -f .test.c .test

80
install: $(PROGRAM)
81 82 83
	mkdir -p $(sbindir) $(man8dir)
	$(INSTALL) -m 0755 $(PROGRAM) $(sbindir)
	$(INSTALL) -m 0644 $(PROGRAM).8 $(man8dir)
84

85
.PHONY: all clean distclean dep pciutils
86 87

-include .dependencies