-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (37 loc) · 1.15 KB
/
Makefile
File metadata and controls
60 lines (37 loc) · 1.15 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Makefile for compiling the shell project in C
# C compiler to use
CC = gcc
# Source files
SRC = $(wildcard *.c)
# Object files
OBJ = $(SRC:.c=.o)
# Name of executable
NAME = hsh
# Remove program to use
# RM = rm -f
# Not allowed to set the RM variable
# Flags for C compiler
CFLAGS := -Wall -Werror -Wextra -pedantic -std=gnu89
# Flags to enable debugging
DBG_CFLAGS := -Wall -Werror -Wextra -pedantic -ggdb3 -std=gnu89
# Vim temporary files
VIM_TMP = $(wildcard *.swp)
# Emacs temporary files
EMACS_TMP = $(wildcard *~)
# Dependencies
DEPS := "$(wildcard shell.h)"
# Rules
ifneq ($(strip $(DEPS)), "") # ensure dependencies are present
all: $(SRC) # recompile only the updated source files
$(CC) $(CFLAGS) $? -o $(NAME)
.PHONY: clean fclean oclean re compiledbg
clean: # delete all emacs and vim temporary files along with the executable
$(RM) $(EMACS_TMP) $(VIM_TMP) $(NAME)
oclean: # delete all object files
$(RM) $(OBJ)
fclean: clean oclean # delete all emacs and vim temporary files, the executable \
and the object files
re: fclean all # force recompilation of all source files
compiledbg: $(SRC)
$(CC) $(DBG_CFLAGS) $? -o $(NAME)
endif