-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
56 lines (44 loc) · 1.41 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
# Makefile for upc2
DESTDIR ?= $(shell pwd)
BINDIR := $(DESTDIR)/bin
OBJDIR := $(DESTDIR)/obj
CFLAGS := -Iinclude -Wall -Werror -g
LDFLAGS :=
LIBS :=
COMMON_SRCS := grouch.c xmodem.c up.c utils.c up_lineend.c srec.c \
kinetis-bin.c kinetis-srec.c
#COMMON_INCLUDES := up_bio.h up_bio_serial.h up.h
ifeq ($(KBUS_DEBUG),)
COMMON_SRCS += up_bio_serial.c
else
COMMON_SRCS += up_bio_kbus.c
CFLAGS += -DKBUS_DEBUG
LIBS += -lkbus
endif
LOCATED_OBJS := $(COMMON_SRCS:%.c=$(OBJDIR)/src/%.o)
LOCATED_DEPS := $(LOCATED_OBJS:%.o=%.d)
#LOCATED_INCLUDES := $(COMMON_INCLUDES:%.h=include/%.h)
.PHONY: all
all: $(BINDIR)/upc2
# Pull in dependencies for existing object files
-include $(LOCATED_DEPS)
$(BINDIR)/upc2: $(OBJDIR)/progs/upc2.o $(LOCATED_OBJS)
-mkdir -p $(BINDIR)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)
# Compile and generate dependency info
# See http://scottmcpeak.com/autodepend/autodepend.html for how
# and why this works. Essentially we post-process GCC's output to
# create proper Makefile entries for all the dependent include files.
$(OBJDIR)/%.o: %.c
-mkdir -p $(dir $@)
$(CC) -o $@ $(CFLAGS) -c $<
$(CC) -MM $(CFLAGS) $< > ${@:%.o=%.d.tmp}
@sed -e 's|.*:|$@:|' < ${@:%.o=%.d.tmp} > ${@:%.o=%.d}
@sed -e 's/.*://' -e 's/\\$$//' < ${@:%.o=%.d.tmp} | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> ${@:%.o=%.d}
@rm -f ${@:%.o=%.d.tmp}
clean:
-rm -rf $(BINDIR) $(OBJDIR)
tidy:
-rm -rf src/*~ progs/*~
# End file.