Makefile 2.33 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 10
CC      ?= gcc
STRIP   = strip
11 12 13 14
INSTALL = install
PREFIX  ?= /usr/local
CFLAGS  ?= -Os -Wall -Werror

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

28
LIBS += -lpci -lz
Peter Stuge's avatar
Peter Stuge committed
29

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

38
all: pciutils dep $(PROGRAM)
39

40 41 42 43
# 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/")"'
44

45
$(PROGRAM): $(OBJS)
46
	$(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
47

48 49 50
flashrom.o: flashrom.c
	$(CC) -c $(CFLAGS) $(SVNDEF) $(CPPFLAGS) $< -o $@

51
clean:
52
	rm -f $(PROGRAM) *.o
53 54

distclean: clean
Peter Stuge's avatar
Peter Stuge committed
55 56
	rm -f .dependencies

57
dep:
58 59 60 61
	@$(CC) $(CPPFLAGS) $(SVNDEF) -MM *.c > .dependencies

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

63
pciutils:
64
	@echo; printf "Checking for pciutils and zlib... "
65 66 67 68
	@$(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 )
69
	@$(CC) $(CFLAGS) $(LDFLAGS) .test.c -o .test $(LIBS) >/dev/null 2>&1 &&	\
70
		echo "found." || ( echo "not found."; echo;		\
71
		echo "Please install pciutils-devel and zlib-devel.";	\
72 73 74 75
		echo "See README for more information."; echo;		\
		rm -f .test.c .test; exit 1)
	@rm -f .test.c .test

76
install: $(PROGRAM)
77 78 79 80
	mkdir -p $(DESTDIR)$(PREFIX)/sbin
	mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
	$(INSTALL) -m 0755 $(PROGRAM) $(DESTDIR)$(PREFIX)/sbin
	$(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(PREFIX)/share/man/man8
81

82
.PHONY: all clean distclean dep pciutils
83 84

-include .dependencies