-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
150 lines (116 loc) · 4.71 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
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
142
143
144
145
146
147
148
149
150
#! This is the root-level Makefile, which includes all the others
# NOTE: the two following variables are to stay at the very top of this Makefile and never move
#! The complete absolute path of the root-level makefile
MKFILE_PATH := "$(abspath $(lastword $(MAKEFILE_LIST)))"
#! The directory of the root-level makefile
CURRENT_DIR := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
#! The sub-directory in which makefile scripts are stored
MKFILES_DIR := ./mkfile/
# Custom variable to detect when Makefile is called through `emmake make`
ifdef EMSCRIPTEN
__EMSCRIPTEN__ = 1
$(info 'EMSCRIPTEN' is defined, building for emscripten platform...)
else ifeq ($(OSMODE),emscripten)
$(error You need to call 'emmake make' instead of simply 'make' if you want to build with emscripten. \
see https://emscripten.org/docs/compiling/Building-Projects.html#integrating-with-a-build-system)
endif
#######################################
# Project variables #
#######################################
#! Output filename for the library
NAME = libccc
#! Output filename for the test suite program
NAME_TEST = libccc-test
ifdef __EMSCRIPTEN__
NAME_TEST := $(NAME_TEST).js
endif
#######################################
# Project folder structure #
#######################################
# repository folders
#! The directory for header code files (stores `.h` files)
HDRDIR = ./hdr/
#! The directory for source code files (stores `.c` files)
SRCDIR = ./src/
#! The directory for dependency library files (stores libs - static:`.a` or dynamic:`.dll`/`.dylib`/`.so`)
LIBDIR = ./lib/
#! The directory for documentation (stores config and scripts to generate doc)
DOCDIR = ./doc/
#! The directory for testing programs (stores source/header code for the various testing programs)
TESTDIR = ./test/
#! The directory for git hooks scripts
GITHOOKSDIR = ./.githooks/
#! The directory for important list files (source files, packages)
LISTSDIR = $(MKFILES_DIR)lists/
# generated folders
#! The name of the subfolder for the current compilation target
TARGETDIR = $(BUILDMODE)_$(OSMODE)_$(CPUMODE)
#! The directory for compiled object files (stores `.o` and `.d` files)
OBJDIR = ./obj/
OBJPATH = $(OBJDIR)$(TARGETDIR)/
#! The directory for built binary files (stores programs/libraries built by this project)
BINDIR = ./bin/
BINPATH = $(BINDIR)$(TARGETDIR)/
#! The directory for output logs (stores `.txt` outputs of the test suite program)
LOGDIR = ./log/
LOGPATH = $(LOGDIR)$(TARGETDIR)/
#! The directory for test-suite code-coverage output reports
COVDIR = $(LOGDIR)coverage/
COVPATH = $(COVDIR)$(TARGETDIR)/
#! The directory for distribution archives (stores `.zip` distributable builds)
DISTDIR = ./dist/
#! The directory for temporary (can be used for several things - should always be deleted after use)
TEMPDIR = ./temp/
#! The directory for linter/static analyzer output logs (stores warnings logs)
LINTDIR = $(LOGDIR)lint/
#######################################
# Included Makefile Variables #
#######################################
# general variables
include $(MKFILES_DIR)utils/make.mk
include $(MKFILES_DIR)utils/shell.mk
include $(MKFILES_DIR)utils/prereq.mk
include $(MKFILES_DIR)utils/print.mk
include $(MKFILES_DIR)utils/ansi.mk
include $(MKFILES_DIR)utils/ext.mk
# project-specific variables
include $(MKFILES_DIR)config/modes.mk
include $(MKFILES_DIR)config/build.mk
include $(MKFILES_DIR)config/build-tests.mk
include $(MKFILES_DIR)config/install.mk
# parse any .env files, to override variables
ifneq ($(wildcard .env),)
$(shell $(call print_message,"Sourcing local '.env' file..."))
$(shell sh ./.env)
endif
#######################################
# Included Makefile Rules #
#######################################
# project-specific rules
include $(MKFILES_DIR)rules/all.mk
include $(MKFILES_DIR)rules/init.mk
include $(MKFILES_DIR)rules/prereq.mk
include $(MKFILES_DIR)rules/version.mk
include $(MKFILES_DIR)rules/packages.mk
include $(MKFILES_DIR)rules/lists.mk
include $(MKFILES_DIR)rules/build.mk
include $(MKFILES_DIR)rules/install.mk
include $(MKFILES_DIR)rules/dist.mk
include $(MKFILES_DIR)rules/clean.mk
include $(MKFILES_DIR)rules/lists-tests.mk
include $(MKFILES_DIR)rules/build-tests.mk
include $(MKFILES_DIR)rules/test.mk
include $(MKFILES_DIR)rules/coverage.mk
include $(MKFILES_DIR)rules/debugging.mk
include $(MKFILES_DIR)rules/format.mk
include $(MKFILES_DIR)rules/lint.mk
include $(MKFILES_DIR)rules/doc.mk
include $(MKFILES_DIR)rules/doc-help.mk
# libccc-specific rules
include $(MKFILES_DIR)rules/generic.mk
include $(MKFILES_DIR)rules/test-env.mk
include $(MKFILES_DIR)rules/test-standalone.mk
include $(MKFILES_DIR)rules/emscripten.mk
# general rules
include $(MKFILES_DIR)utils/refactor.mk
include $(MKFILES_DIR)utils/help.mk