-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile.generic
117 lines (100 loc) · 4.88 KB
/
Makefile.generic
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
COMPILER = cc
AR = gcc-ar
LDLIBS = -lpthread -lm -lnuma
CFLAGS =
ARGS =
D_ARGS =
INSTALL_INFO = .install_info
INSTALL_SUFFIX = Synch
UNINSTALL_DIR = $(shell cat $(INSTALL_INFO))
# define any directories containing header files other than /usr/include
INCLUDES = -Ilibconcurrent/includes -Ilibconcurrent
# define the output directory
BINDIR = build/bin
LIBDIR = build/lib
DOCSDIR = build/docs
OBJDIR = build/objects
LIBNAME = libconcurrent.a
LIBNAMESO = libconcurrent.so
BUILD_LOG=./build.log
# define the C source files
PRIMITIVES = $(wildcard libconcurrent/primitives/*.c)
CONCURRENT = $(wildcard libconcurrent/concurrent/*.c)
BENCHMARKS = $(wildcard benchmarks/*bench.c)
SRCS = $(PRIMITIVES) $(CONCURRENT)
# define the C object files
OBJECTS = $(SRCS:.c=.o)
# define the .run executable files
EXECS = $(BENCHMARKS:.c=.run)
COLOR_CC = [ \e[32mCC\e[39m ]
COLOR_CP = [ \e[32mCP\e[39m ]
COLOR_AR = [ \e[36mAR\e[39m ]
COLOR_RM = [ \e[31mRM\e[39m ]
COLOR_ERR = [ \e[31mERROR\e[39m ]
.PHONY: all clean
all: $(EXECS)
$(EXECS): %.run : %.c libbuild
@printf '$(COLOR_CC)\t$<\n'
@$(COMPILER) $(CFLAGS) $(ARGS) $(INCLUDES) $(D_ARGS) $< -o $(BINDIR)/$(notdir $@) $(LIBDIR)/$(LIBNAME) $(LDLIBS)
.c.o:
@printf '$(COLOR_CC)\t$<\n'
@$(COMPILER) $(CFLAGS) $(ARGS) $(INCLUDES) $(D_ARGS) -c $< -o $(OBJDIR)/$(notdir $@)
libbuild: $(OBJECTS)
@printf '$(COLOR_CC)\t$(LIBDIR)/$(LIBNAMESO)\n'
@$(COMPILER) -shared -o $(LIBDIR)/$(LIBNAMESO) $(addprefix $(OBJDIR)/,$(notdir $(OBJECTS)))
@printf '$(COLOR_AR)\t$(LIBDIR)/$(LIBNAME)\n'
@$(AR) rcs $(LIBDIR)/$(LIBNAME) $(addprefix $(OBJDIR)/,$(notdir $(OBJECTS)))
clean: $(SRCS)
@printf '$(COLOR_RM)\t$(LIBDIR)/*.a\n'
@rm -rf $(LIBDIR)/*.a
@printf '$(COLOR_RM)\t$(LIBDIR)/*.so\n'
@rm -rf $(LIBDIR)/*.so
@printf '$(COLOR_RM)\tObject files\n'
@rm -f $(addprefix $(OBJDIR)/,$(notdir $(OBJECTS)))
@printf '$(COLOR_RM)\tExecutable files\n'
@rm -rf $(BINDIR)/*.run
@printf '$(COLOR_RM)\tLog and result files\n'
@rm -rf res.txt results.txt *.log
@printf '$(COLOR_RM)\tOld documentation files\n'
@rm -rf $(DOCSDIR)/*
@printf '$(COLOR_RM)\tInstallation configuration\n'
@rm -rf $(INSTALL_INFO)
docs:
@printf '$(COLOR_RM)\tOld documentation files\n'
@rm -rf $(DOCSDIR)
@printf '$(COLOR_CC)\tGenerating documentation\n'
@doxygen resources/Doxyfile >> $(BUILD_LOG)
@printf 'Documentation build log is placed in $(BUILD_LOG)\n'
install:
@if [ -d ${INSTALL_DIR} ]; then \
if [ -w ${INSTALL_DIR} ]; then \
mkdir -p ${INSTALL_DIR}; \
mkdir -p ${INSTALL_DIR}/$(INSTALL_SUFFIX)/; \
mkdir -p ${INSTALL_DIR}/$(INSTALL_SUFFIX)/build; \
printf '$(COLOR_CP)\tInstalling the Synch framework\n'; \
cp -r ./build/* $(INSTALL_DIR)/$(INSTALL_SUFFIX)/; \
cp -r ./libconcurrent/includes/ $(INSTALL_DIR)/$(INSTALL_SUFFIX)/; \
cp bench.sh run_all.sh $(INSTALL_DIR)/$(INSTALL_SUFFIX)/; \
ln -s ${INSTALL_DIR}/$(INSTALL_SUFFIX)/bin ${INSTALL_DIR}/$(INSTALL_SUFFIX)/build/bin; \
ln -s ${INSTALL_DIR}/$(INSTALL_SUFFIX)/lib ${INSTALL_DIR}/$(INSTALL_SUFFIX)/build/lib; \
echo $(INSTALL_DIR) > $(INSTALL_INFO); \
else \
printf '$(COLOR_ERR)\tNo write access at %s \n' ${INSTALL_DIR}; \
printf '$(COLOR_ERR)\tYou may need root access\n'; \
fi \
else \
printf '$(COLOR_ERR)\tThere is no directory: %s\n' ${INSTALL_DIR}; \
fi
uninstall:
@if [ -d ${UNINSTALL_DIR} ]; then \
if [ -w ${UNINSTALL_DIR} ]; then \
printf '$(COLOR_RM)\tRemoving installation files\n'; \
rm -rf $(UNINSTALL_DIR)/$(INSTALL_SUFFIX)/; \
else \
echo "Unable to remove " $(UNINSTALL_DIR); \
echo "You may need root access"; \
fi \
else \
printf '$(COLOR_ERR)\tThere is no directory: %s\n' ${UNINSTALL_DIR}; \
printf '$(COLOR_ERR)\tFramework may already uninstalled\n'; \
fi