-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (44 loc) · 1.33 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
#
# 'make' build executable file 'fed'
# 'make clean' removes all .o and executable files
#
# define the C compiler to use
CC = gcc
# For clean on different OS
ifeq ($(OS),Windows_NT)
#Windows
RM = del
else
#Linux
RM = rm
endif
# define any compile-time flags
CFLAGS = -Wall -g
# define the C source files
SRCS = fed.c utils.c commands/add.c commands/help.c\
commands/ls.c commands/clean.c commands/cd.c commands/open.c commands/rename.c
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
# Below we are replacing the suffix .c of all words in the macro SRCS
# with the .o suffix
#
OBJS = $(SRCS:.c=.o)
# define the executable file
MAIN = fed
.PHONY: clean
all: $(MAIN)
@echo Simple compiler named 'fed' has been compiled
$(MAIN): $(OBJS)
$(CC) $(CFLAGS) -o $(MAIN) $(OBJS)
# this is a suffix replacement rule for building .o's from .c's
# it uses automatic variables $<: the name of the prerequisite of
# the rule(a .c file) and $@: the name of the target of the rule (a .o file)
# (see the gnu make manual section about automatic variables)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
$(RM) *.o commands\*.o $(MAIN).exe $(MAIN)
# DO NOT DELETE THIS LINE -- make depend needs it