-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
85 lines (63 loc) · 2.03 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
###################################################################
# About the library name and path
###################################################################
# library name, without extension
LIB_NAME ?= libsmartcard
# project root directory, relative to app dir
PROJ_FILES = ../../
# library name, with extension
LIB_FULL_NAME = $(LIB_NAME).a
# SDK helper Makefiles inclusion
-include $(PROJ_FILES)/m_config.mk
-include $(PROJ_FILES)/m_generic.mk
# use an app-specific build dir
APP_BUILD_DIR = $(BUILD_DIR)/libs/$(LIB_NAME)
###################################################################
# About the compilation flags
###################################################################
CFLAGS += $(LIBS_CFLAGS)
# WARNING: there is a circular dependency beteween
# libiso7816 & libsmartcard exported headers, making the inclusion
# of the local api dir needed
CFLAGS += -Iapi
CFLAGS += -MMD -MP
#############################################################
# About library sources
#############################################################
SRC_DIR = .
SRC = $(wildcard $(SRC_DIR)/*.c)
OBJ = $(patsubst %.c,$(APP_BUILD_DIR)/%.o,$(SRC))
DEP = $(OBJ:.o=.d)
OUT_DIRS = $(dir $(OBJ))
# file to (dist)clean
# objects and compilation related
TODEL_CLEAN += $(OBJ)
# targets
TODEL_DISTCLEAN += $(APP_BUILD_DIR)
##########################################################
# generic targets of all libraries makefiles
##########################################################
.PHONY: app doc
default: all
all: $(APP_BUILD_DIR) lib
doc:
$(Q)$(MAKE) BUILDDIR=../$(APP_BUILD_DIR)/doc -C doc html latexpdf
show:
@echo
@echo "\tAPP_BUILD_DIR\t=> " $(APP_BUILD_DIR)
@echo
@echo "C sources files:"
@echo "\tSRC_DIR\t\t=> " $(SRC_DIR)
@echo "\tSRC\t\t=> " $(SRC)
@echo "\tOBJ\t\t=> " $(OBJ)
@echo
lib: $(APP_BUILD_DIR)/$(LIB_FULL_NAME)
$(APP_BUILD_DIR)/%.o: %.c
$(call if_changed,cc_o_c)
# lib
$(APP_BUILD_DIR)/$(LIB_FULL_NAME): $(OBJ)
$(call if_changed,mklib)
$(call if_changed,ranlib)
$(APP_BUILD_DIR):
$(call cmd,mkdir)
-include $(DEP)