-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (36 loc) · 1.8 KB
/
Makefile
File metadata and controls
46 lines (36 loc) · 1.8 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
# processWatchdog application makefile
# Copyright (c) 2023 Eray Ozturk <erayozturk1@gmail.com>
# Variables
CC := gcc
STRIP := strip
TARGET_EXEC := processWatchdog
SRC_DIRS := src
DEPLOY_DIR := .
SRCS := $(shell find $(SRC_DIRS) -not -name 'main.c' -name '*.c')
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
LIBS := -lpthread -lm
WARNING_FLAGS := -pedantic -Wall -Wextra -Wno-missing-declarations -Wstrict-prototypes -Wpointer-arith -Wwrite-strings -Wbad-function-cast -Wformat-security -Wno-discarded-qualifiers -Wno-implicit-fallthrough -Wformat-nonliteral -Wmissing-format-attribute -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -Wno-ignored-qualifiers -Wno-strict-prototypes -Wno-bad-function-cast -Wno-pointer-sign
HARDENING_FLAGS := -fno-builtin -fvisibility=hidden -fstack-protector -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-common -ffunction-sections -fdata-sections
PERFORMANCE_FLAGS := -fPIC -fPIE -ffast-math -fassociative-math -fno-signed-zeros -fno-trapping-math -fno-exceptions
# Build type (debug or release)
BUILD_TYPE ?= release
ifeq ($(BUILD_TYPE),debug)
CFLAGS := $(INC_FLAGS) -g3 -O0 -ggdb $(WARNING_FLAGS)
else
CFLAGS := $(INC_FLAGS) -g0 -O2 $(WARNING_FLAGS) $(HARDENING_FLAGS) $(PERFORMANCE_FLAGS)
endif
# Rules
all: $(DEPLOY_DIR)/$(TARGET_EXEC)
$(DEPLOY_DIR)/$(TARGET_EXEC): $(SRCS) $(SRC_DIRS)/main.c | $(DEPLOY_DIR)
$(CC) $(SRCS) $(SRC_DIRS)/main.c $(CFLAGS) $(LIBS) -o $@
$(STRIP) --strip-all -v $@
$(DEPLOY_DIR):
mkdir -p $(DEPLOY_DIR)
clean:
$(RM) -f $(DEPLOY_DIR)/$(TARGET_EXEC) $(DEPLOY_DIR)/stats_*.log $(DEPLOY_DIR)/stats_*.raw wdt.log
install: $(DEPLOY_DIR)/$(TARGET_EXEC)
$(CP) $(DEPLOY_DIR)/$(TARGET_EXEC) ~/
$(CP) run.sh ~/
chmod +x ~/$(TARGET_EXEC) ~/run.sh
.PHONY: all clean install