-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (42 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
46
47
48
49
50
51
PARE = $(HOST_CFLAGS)
FILE_TYPE = c
CC = gcc
#CC = g++
#LINK_LIBS = -lstdc++
DIR_INC = -I./include
DIR_INC += -I./data
DIR_SRC = ./src
DIR_OBJ = ./obj
DIR_BIN = ./bin
DIR_LIB = ./lib
AR = ar
RANLIB = ranlib
TAR_GET = libfft.a
SRC = $(wildcard ${DIR_SRC}/*.$(FILE_TYPE))
#文件路径+***.o
OBJ = $(patsubst %.$(FILE_TYPE),${DIR_OBJ}/%.o,$(notdir ${SRC}))
TARGET = main
BIN_TARGET = ${DIR_BIN}/${TARGET}
LIB_TARGET = ${DIR_LIB}/${TAR_GET}
CFLAGS = -g -Wall ${DIR_INC}
LINK_PATH = -L./lib
LINK_PATH += -lm
LINK_FLAGS = $(LINK_PATH)
LINK_FLAGS += $(LINK_LIBS)
#生成可执行文件
ifneq ($(HOST_CFLAGS), TRUE)
${BIN_TARGET}:${OBJ}
$(CC) $(OBJ) -o $@ $(LINK_FLAGS)
else
#生成动态库
${LIB_TARGET}:${OBJ}
${AR} cru ${LIB_TARGET} $(OBJ)
${RANLIB} ${LIB_TARGET}
endif
${DIR_OBJ}/%.o:${DIR_SRC}/%.$(FILE_TYPE)
$(CC) $(CFLAGS) -c -fPIC $< -o $@
.PHONY:clean
clean:
rm ${DIR_OBJ}/*.o
rm ${DIR_BIN}/*
rm ${DIR_LIB}/*