-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (66 loc) · 1.32 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
63
64
65
66
67
68
69
70
#
# Generic compiles-it-all Makefile
# Loni Nix <[email protected]>
# Last modified **********
#
# adhere to a higher standard
CSTDCFLAGS=-std=gnu99
CXXSTDCFLAGS=-std=gnu++11
#
# save any options preset on cmd line
EXTFLAGS:=$(CFLAGS) $(CXXFLAGS)
CFLAGS=
#
# lots of debugging stuff included
CFLAGS+=-ggdb3
#
# but no optimization by default
#CFLAGS+=-O0
CFLAGS+=-O2
#
# warn about lots of things
CFLAGS+=-Wall -Wextra -Wunused
#
# but only include libs as needed
CFLAGS+=-Wl,--as-needed
#
# sometimes we want to see it all
#CFLAGS+=-save-temps -fverbose-asm
#
# and in glorious color!
CFLAGS+=-fdiagnostics-color=always
#
# don't really use LDFLAGS much
#LDFLAGS+=
#
# but need to list libraries needed
#LIBS+=-lm
#LIBS+=-lgd
LIBS+=-lmodbus
#
ASFLAGS=-ggdb3
#
AS=gas
CC:=gcc
CXX:=g++
#
.SUFFIXES:
.SUFFIXES: .c .cpp .s .o
#
.phony: all clean
#
SRC=$(wildcard *.c) $(wildcard *.cpp) $(wildcard *.s)
EXECS=$(basename $(SRC))
#
all: $(EXECS)
%: %.c
$(CC) $(CSTDCFLAGS) $(CFLAGS) $(EXTFLAGS) $(LDFLAGS) -c $< -o [email protected] $(LIBS)
$(CC) $(CSTDCFLAGS) $(CFLAGS) $(EXTFLAGS) $(LDFLAGS) [email protected] -o $@ $(LIBS)
%: %.cpp
$(CXX) $(CXXSTDCFLAGS) $(CFLAGS) $(EXTFLAGS) $(LDFLAGS) -c $< -o [email protected] $(LIBS)
$(CXX) $(CXXSTDCFLAGS) $(CFLAGS) $(EXTFLAGS) $(LDFLAGS) [email protected] -o $@ $(LIBS)
% :%.s
$(AS) $(ASFLAGS) $< -o [email protected]
$(LD) [email protected] -o $@
clean:
rm -f *.o $(EXECS)