-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (32 loc) · 941 Bytes
/
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
TARGET = app
NON_MAIN_OBJECT_FILES = embeddedgmetric.o modp_numtoa.o
OBJECT_FILES = $(NON_MAIN_OBJECT_FILES) main.o
LIB_DIR = /usr/local/lib
CXXFLAGS = -Wall -c -g
LDFLAGS = -L$(LIB_DIR)
LDFLAGS += -Wl,-E
CC = g++
.PHONY: clean
all: $(TARGET)
$(TARGET): $(OBJECT_FILES)
$(CC) -o $(TARGET) $(OBJECT_FILES) $(LDFLAGS)
@echo "Build successfully!"
%.o : %.c
$(CC) $(CXXFLAGS) $*.c -o $*.o
$(CC) $(CXXFLAGS) -MM $*.c > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
%.o : %.cpp
$(CC) $(CXXFLAGS) $*.cpp -o $*.o
$(CC) $(CXXFLAGS) -MM $*.cpp > $*.d
@mv -f $*.d $*.d.tmp
@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@rm -f $*.d.tmp
-include $(OBJECT_FILES:.o=.d)
clean:
rm -rf $(TARGET) *.o *.d