-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
63 lines (47 loc) · 1.47 KB
/
Makefile
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
58
59
60
61
62
CC=clang
CFLAGS=-Wall -std=c99 -pedantic -Wextra -Weverything -Wno-padded -Os #-emit-llvm
LDFLAGS=-Os
AR=ar
ARFLAGS=rcs
OBJS = kk_ihex_write.o kk_ihex_read.o bin2ihex.o ihex2bin.o
BINPATH = ./
LIBPATH = ./
BINS = $(BINPATH)bin2ihex $(BINPATH)ihex2bin $(BINPATH)split16bit $(BINPATH)merge16bit
BINS += $(BINPATH)split32bit $(BINPATH)merge32bit
LIB = $(LIBPATH)libkk_ihex.a
TESTFILE = $(LIB)
TESTER =
#TESTER = valgrind
all: $(BINS) $(LIB)
$(OBJS): kk_ihex.h
$(BINS): | $(BINPATH)
$(LIB): | $(LIBPATH)
bin2ihex.o kk_ihex_write.o: kk_ihex_write.h
ihex2bin.o kk_ihex_read.o: kk_ihex_read.h
$(LIB): kk_ihex_write.o kk_ihex_read.o
$(AR) $(ARFLAGS) $@ $+
$(BINPATH)bin2ihex: bin2ihex.o $(LIB)
$(CC) $(LDFLAGS) -o $@ $+
$(BINPATH)ihex2bin: ihex2bin.o $(LIB)
$(CC) $(LDFLAGS) -o $@ $+
$(BINPATH)split16bit: split16bit.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
$(BINPATH)merge16bit: merge16bit.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
$(BINPATH)split32bit: split32bit.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
$(BINPATH)merge32bit: merge32bit.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
$(sort $(BINPATH) $(LIBPATH)):
@mkdir -p $@
.PHONY: all clean distclean test
test: $(BINPATH)bin2ihex $(BINPATH)ihex2bin $(TESTFILE)
@$(TESTER) $(BINPATH)bin2ihex -v -a 0x80 -i '$(TESTFILE)' | \
$(TESTER) $(BINPATH)ihex2bin -A -v | \
diff '$(TESTFILE)' -
@echo Loopback test success!
clean:
rm -f $(OBJS)
distclean: | clean
rm -f $(BINS) $(LIB)
@rmdir $(BINPATH) $(LIBPATH) >/dev/null 2>/dev/null || true