aboutsummaryrefslogtreecommitdiff
path: root/external/xscom-utils/Makefile
blob: 3fee2473115890f91f31636de775359224cf27cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
CC = $(CROSS_COMPILE)gcc

XSCOM_VERSION ?= $(shell ../../make_version.sh xscom-utils)
CFLAGS += -O2 -g -Wall -m64

prefix = /usr/local/
sbindir = $(prefix)/sbin
datadir = $(prefix)/share
mandir = $(datadir)/man

%.o: %.c
	$(Q_CC)$(COMPILE.c) $< -o $@

# Use make V=1 for a verbose build.
ifndef V
        Q_CC=	@echo '    CC ' $@;
        Q_LINK=	@echo '  LINK ' $@;
        Q_LN=   @echo '    LN ' $@;
        Q_MKDIR=@echo ' MKDIR ' $@;
endif

all: getscom putscom getsram

getscom: getscom.c xscom.o version.o
	$(Q_LINK)$(LINK.o) -o $@ $^

getsram: getsram.o xscom.o sram.o version.o
	$(Q_LINK)$(LINK.o) -o $@ $^

putscom: putscom.o xscom.o version.o
	$(Q_LINK)$(LINK.o) -o $@ $^

install: all
	install -D getscom $(DESTDIR)$(sbindir)/getscom
	install -D putscom $(DESTDIR)$(sbindir)/putscom
	install -D getsram $(DESTDIR)$(sbindir)/getsram

.PHONY: clean
clean:
	rm -rf *.[od] getscom putscom getsram

.PHONY: distclean
distclean: clean
	rm -rf *.c~ *.h~ *.i *.s Makefile~

version.c: ../../make_version.sh  .version
	@(if [ "a$(XSCOM_VERSION)" = "a" ]; then \
	echo "#error You need to set XSCOM_VERSION environment variable" > $@ ;\
	else \
	echo "const char version[] = \"$(XSCOM_VERSION)\";" ;\
	fi) > $@

.PHONY: VERSION-always
.version: VERSION-always
	@echo $(XSCOM_VERSION) > $@.tmp
	@cmp -s $@ $@.tmp || cp $@.tmp $@
	@rm -f $@.tmp