-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
141 lines (112 loc) · 3.56 KB
/
makefile
File metadata and controls
141 lines (112 loc) · 3.56 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
####EXT_PATHS####
DEF_MKFILES = ./make_config/*.mk
EXT_MKFILES =
####OUTPUT INFO####
PROJECT_NAME = varfuture
TARGET_AOUT = testProgram
TARGET_ALIB = libvarfuture.a
TARGET_SLIB = libvarfuture.so
####Source files####
SRC_DIR = ./src
TST_DIR = ./test
SRC_LIBPART =\
$(SRC_DIR)/void_future.c\
$(SRC_DIR)/primitives.c\
$(SRC_DIR)/varfuture_globals.c\
$(SRC_DIR)/varfuture_queue.c\
$(SRC_DIR)/engine_concurrent.c\
$(SRC_DIR)/engine_threadpool.c\
SRC_PROGRAM =\
$(TST_DIR)/main.c\
$(TST_DIR)/int_test.c\
$(TST_DIR)/int_test2.c\
$(TST_DIR)/double_test.c\
$(TST_DIR)/mini/minitest.c
#### default compilers ####
CC = gcc
AR = ar
####build options####
CFLAGS = -Wall -O2
DEFS =
CROSS_PREFIX =
####dependency options####
#ALIB_EXTERNAL := $(ALIB_EXTERNAL) libExternal.a
#SLIB_EXTERNAL := $(SLIB_EXTERNAL) -lexternal_lib
#SLIB_EXTPATH := $(SLIB_EXTPATH) -L /dirpath/contains/.so_file/
#HDRS_EXTPATH := $(HDRS_EXTPATH) -I /dirpath/contains/header_root/
ALIB_EXTERNAL =
SLIB_INTERNAL = -lpthread -lrt
SLIB_EXTERNAL =
SLIB_EXTPATH =
HDRS_EXTPATH =
#################
## PARAMETERS WRITTEN BELOW MUST "NOT" BE OVERWRITTEN !!
#################
####BUILDING OBJ(*.o) and DEP(*.depend) INFO####
#OBJ_DIR and DEP_DIR is the most important AUTO-GENERATED directory.
#DO NOT RE-WRITE THIS PARAMETER!!
OBJ_DIR = ./.obj
DEP_DIR = ./.dep
OBJ_LIBPART := $(SRC_LIBPART:%.c=$(OBJ_DIR)/%.o)
DEP_LIBPART := $(SRC_LIBPART:%.c=$(DEP_DIR)/%.depend)
DEP_PROGRAM := $(OBJ_PROGRAM:%.o=%.d)
OBJ_PROGRAM := $(SRC_PROGRAM:%.c=$(OBJ_DIR)/%.o)
DEP_PROGRAM := $(SRC_PROGRAM:%.c=$(DEP_DIR)/%.depend)
#### FIXED PATH INFO ####
INCDIR_MYSELF =./include/
INSTALL_DIR =./install/
####include .mk files as config####
include $(DEF_MKFILES) $(EXT_MKFILES)
####SETUP BUILD COMMANDS####
HDRS_EXTPATH := -I$(INCDIR_MYSELF) $(HDRS_EXTPATH)
CC := $(CROSS_PREFIX)$(CC) $(HDRS_EXTPATH) $(CFLAGS) $(DEFS)
AR := $(CROSS_PREFIX)$(AR)
LFLAGS = $(ALIB_EXTERNAL) $(SLIB_EXTPATH) $(SLIB_EXTERNAL) $(SLIB_INTERNAL)
OBJ = $(OBJ_LIBPART) $(OBJ_PROGRAM)
DEP = $(DEP_LIBPART) $(DEP_PROGRAM)
#ひとまずビルド。
all: $(TARGET_ALIB) $(TARGET_AOUT)
#ライブラリ用のビルドなので、target.aの生成を念頭に入れる。
$(TARGET_ALIB) : $(OBJ_LIBPART)
$(AR) rcs $(TARGET_ALIB) $(OBJ_LIBPART)
ifneq ($(strip $(TARGET_SLIB)),)
$(CC) -shared -o $(TARGET_SLIB) $(OBJ_LIBPART)
endif
install -C -D $(TARGET_ALIB) $(INSTALL_DIR)/lib/$(TARGET_ALIB)
cp $(INCDIR_MYSELF) $(INSTALL_DIR) -R -f
ifneq ($(strip $(TARGET_SLIB)),)
install -C -D $(TARGET_SLIB) $(INSTALL_DIR)/lib/$(TARGET_SLIB)
endif
#テスタービルド
ifneq ($(strip $(TARGET_AOUT)), )
$(TARGET_AOUT) :$(TARGET_ALIB) $(OBJ_PROGRAM)
$(CC) -o $(TARGET_AOUT) $(OBJ_PROGRAM) $(TARGET_ALIB) $(LFLAGS)
endif
#みんないなくなる。
clean:
rm -rf $(TARGET_ALIB) $(TARGET_AOUT) $(TARGET_SLIB) $(OBJ_DIR) $(DEP_DIR) $(INSTALL_DIR)/*
#インストール。外部で指定したインストール先があるなら、そこに突っ込む。
install: FORCE
ifneq ($(strip $(INSTALL_EXT)),)
cp $(INSTALL_DIR)/* $(INSTALL_EXT)/ -R -f
endif
#オブジェクトファイルを「所定の場所に」作成する
#ついでに依存関係のファイルを出す
$(OBJ_DIR)/%.o : %.c
mkdir -p $(dir $(DEP_DIR)/$(<:%.c=%.depend))
$(CC) -MM $< -MT $@ > $(DEP_DIR)/$(<:%.c=%.depend)
mkdir -p $(dir $@)
ifneq ($(strip $(TARGET_SLIB)),)
$(CC) -c $< -o $@ -fPIC
else
$(CC) -c $< -o $@
endif
#普通のビルド。
#.c.o:
#ifneq ($(strip $(TARGET_SLIB)),)
# $(CC) -c -MMD $< -fPIC
#else
# $(CC) -c -MMD $<
#endif
FORCE:
-include $(DEP)