Skip to content

Commit 935a1ed

Browse files
committed
Update Makefile
1 parent cc04788 commit 935a1ed

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

Makefile

+21-23
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
1-
#
21
# processWatchdog application makefile
32
# Copyright (c) 2023 Eray Ozturk <[email protected]>
4-
#
3+
4+
# Variables
55
CC := gcc
66
STRIP := strip
7-
87
TARGET_EXEC := processWatchdog
9-
108
SRC_DIRS := src
119
DEPLOY_DIR := .
12-
1310
SRCS := $(shell find $(SRC_DIRS) -not -name 'main.c' -name '*.c')
14-
1511
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
16-
1712
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
18-
13+
LIBS := -lpthread -lm
1914
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
2015
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
2116
PERFORMANCE_FLAGS := -fPIC -fPIE -ffast-math -fassociative-math -fno-signed-zeros -fno-trapping-math -fno-exceptions
2217

23-
#debug
24-
#CFLAGS := $(INC_FLAGS) -g3 -o0 -ggdb $(WARNING_FLAGS)
18+
# Flags
19+
# Debug
20+
# CFLAGS := $(INC_FLAGS) -g3 -O0 -ggdb $(WARNING_FLAGS)
2521

26-
#release
27-
CFLAGS := $(INC_FLAGS) -g0 -o2 $(WARNING_FLAGS) $(HARDENING_FLAGS) $(PERFORMANCE_FLAGS)
22+
# Release
23+
CFLAGS := $(INC_FLAGS) -g0 -O2 $(WARNING_FLAGS) $(HARDENING_FLAGS) $(PERFORMANCE_FLAGS)
2824

29-
LIBS := -lpthread -lm
25+
# Rules
26+
all: $(DEPLOY_DIR)/$(TARGET_EXEC)
3027

31-
all: $(TARGET_EXEC)
28+
$(DEPLOY_DIR)/$(TARGET_EXEC): $(SRCS) $(SRC_DIRS)/main.c | $(DEPLOY_DIR)
29+
$(CC) $(SRCS) $(SRC_DIRS)/main.c $(CFLAGS) $(LIBS) -o $@
30+
$(STRIP) -R .comment -R *.note* -s -x -X -v $@
3231

33-
$(TARGET_EXEC):
34-
$(CC) $(SRCS) $(CFLAGS) $(EXTRA) -o $(DEPLOY_DIR)/$(TARGET_EXEC) $(SRC_DIRS)/main.c $(LIBS)
35-
$(STRIP) -R .comment -R *.note* -s -x -X -v $(DEPLOY_DIR)/$(TARGET_EXEC)
32+
$(DEPLOY_DIR):
33+
mkdir -p $(DEPLOY_DIR)
3634

37-
.PHONY: clean
3835
clean:
39-
rm $(TARGET_EXEC)
36+
rm -f $(DEPLOY_DIR)/$(TARGET_EXEC)
4037

41-
.PHONY: install
42-
install:
43-
cp $(TARGET_EXEC) ~/
38+
install: $(DEPLOY_DIR)/$(TARGET_EXEC)
39+
cp $(DEPLOY_DIR)/$(TARGET_EXEC) ~/
4440
cp run.sh ~/
45-
chmod +x $(TARGET_EXEC) run.sh
41+
chmod +x ~$(TARGET_EXEC) run.sh
42+
43+
.PHONY: all clean install

0 commit comments

Comments
 (0)