forked from wendlers/libemb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon_lib.mk
88 lines (67 loc) · 1.6 KB
/
common_lib.mk
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
##
# Common settings for Makefiles
#
# Stefan Wendler, sw@kaltpost.de
##
# compiler prefix
ifeq ($(TARCH),MSP430)
PREFIX ?= msp430-
else
PREFIX ?= arm-none-eabi-
endif
CC = $(PREFIX)gcc
AR = $(PREFIX)ar
ifeq ($(TARCH),MSP430)
INCDIR += -I./include
CFLAGS += -Os -g -mmcu=msp430g2553 -Wall -Wextra $(INCDIR)
else
INCDIR += -I./include -I$(HOME)/sat/arm-none-eabi/include
CFLAGS += -Os -g -Wall -Wextra -fno-common -mcpu=cortex-m3 -mthumb -msoft-float -MD $(INCDIR) -DSTM32F1
endif
ARFLAGS = rcs
# where to put generated libraries to
LIBDIR ?= ../lib
# doxygen executable
DOXYGEN = doxygen
# doxygen flags
DOXYGENFLAGS = ../doxygen.conf
# styler to use
STYLER = astyle
# which c-style to use
# - see man astyle
STYLERFLAGS = --style=stroustrup
# cpp checker
CHECKER = cppcheck
# flags for checker
# CHECKERFLAGS = --error-exitcode=1 --enable=all
CHECKERFLAGS = --enable=all --error-exitcode=1
.SUFFIXES: .elf .bin .hex .srec .list .images
.SECONDEXPANSION:
.SECONDARY:
all: $(LIBNAME).a
$(LIBNAME).a: $(OBJS)
@#printf " AR $(subst $(shell pwd)/,,$(@))\n"
$(AR) $(ARFLAGS) $@ $^ && cp $(LIBNAME).a $(LIBDIR)/.
%.o: %.c Makefile
@#printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(CC) $(CFLAGS) -o $@ -c $<
%.o: %.cpp Makefile
@#printf " CC $(subst $(shell pwd)/,,$(@))\n"
$(CC) $(CFLAGS) -o $@ -c $<
SRC = $(wildcard *.c)
HDR = $(wildcard include/*.h)
style:
$(STYLER) $(STYLERFLAGS) $(SRC)
$(STYLER) $(STYLERFLAGS) $(HDR)
clean:
rm -f *.o
rm -f *.a
rm -f *.d
rm -f *.elf
rm -f *.bin
rm -f *.hex
rm -f *.srec
rm -f *.list
rm -f *.orig
rm -f include/*.orig
.PHONY: images clean