-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (43 loc) · 1.3 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
# Delete file and make directory commands
export REMOVE ?= rm -f
export MAKE_DIR ?= mkdir -p
# Compile command
export CC ?= cc
# Compiler warning flags
export WARNING_FLAGS ?= \
-Wall -Wextra -Wpedantic -Wfloat-equal -Wpointer-arith -Wshadow -Wstrict-prototypes \
-Wstrict-overflow=4 -Wwrite-strings -Waggregate-return -Wcast-qual -Wswitch-default \
-Wswitch-enum -Wconversion -Wunreachable-code -Wformat=2 -Winit-self -Wuninitialized \
-Wold-style-definition -Wmissing-prototypes
# Release and debug specific compiler flags
export RELEASE_FLAGS ?= -O2 -DNDEBUG -Werror
export DEBUG_FLAGS ?= -Og -g
# File extensions
export SOURCE_EXT ?= c
export HEADER_EXT ?= h
export OBJECT_EXT ?= o
# Directory names
export TARGET_DIR ?= bin
export BUILD_DIR ?= obj
export SOURCE_DIR ?= src
export INCLUDE_DIR ?= inc
# Project root directory
PROJECT_DIR ?= .
# Project names
COMMON ?= Common
SUB_PROJECT ?= Project
# Project directories
COMMON_DIR := $(PROJECT_DIR)/$(COMMON)
SUB_PROJECT_DIR := $(PROJECT_DIR)/$(SUB_PROJECT)
# Set phony targets
.PHONY: all release debug clean
# Make all
all: release
# Make release and debug
release debug:
$(MAKE) -C $(COMMON_DIR) $@
$(MAKE) -C $(SUB_PROJECT_DIR) $@ TARGET=$(SUB_PROJECT)
# Make clean
clean:
$(MAKE) -C $(COMMON_DIR) $@
$(MAKE) -C $(SUB_PROJECT_DIR) $@