-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (34 loc) · 957 Bytes
/
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
# Makefile adapted from TREE assignment, original written by Ryan Gambord.
CC = gcc
CFLAGS = -std=gnu99
SRCS = UTL_smallsh.c smallsh.c
OBJS = $(SRCS:.c=.o)
EXE = smallsh
DBDIR = debug
DBEXE = $(DBDIR)/$(EXE)
DBOBJS = $(addprefix $(DBDIR)/, $(OBJS))
DBCFLAGS = -g -O0 -DDEBUG
REDIR = build
REEXE = $(REDIR)/$(EXE)
REOBJS = $(addprefix $(REDIR)/, $(OBJS))
RECFLAGS = -O3 -Wall -Wextra -Wpedantic -Werror
.PHONY: all clean debug release prep
all: debug release smallsh
smallsh: $(REEXE)
@cp $< $@
debug: prep_debug $(DBEXE)
$(DBEXE): $(DBOBJS)
$(CC) $(CFLAGS) $(DBCFLAGS) -DTEST -o $@ $^
$(DBDIR)/%.o: %.c
$(CC) -c $(CFLAGS) $(DBCFLAGS) -o $@ $<
release: prep_release $(REEXE)
$(REEXE): $(REOBJS)
$(CC) $(CFLAGS) $(RECFLAGS) -o $@ $^
$(REDIR)/%.o: %.c
$(CC) -c $(CFLAGS) $(RECFLAGS) -o $@ $<
prep_debug:
@mkdir -p $(DBDIR)
prep_release:
@mkdir -p $(REDIR)
clean:
rm -rf smallsh junk junk2 $(DBDIR) $(REDIR)