-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
45 lines (34 loc) · 766 Bytes
/
Copy pathMakefile
File metadata and controls
45 lines (34 loc) · 766 Bytes
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
CC = gcc
CFLAGS = -Wall -g
LEX = flex
YACC = bison
# Target executable
TARGET = minishell
# Source files
LEX_SRC = shell.l
YACC_SRC = shell.y
# Generated files
LEX_OUT = lex.yy.c
YACC_OUT = y.tab.c
YACC_HEADER = y.tab.h
# Object files
OBJS = $(YACC_OUT:.c=.o) $(LEX_OUT:.c=.o)
# Default target
all: $(TARGET)
# Build the executable
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS)
# Generate parser from Yacc
$(YACC_OUT) $(YACC_HEADER): $(YACC_SRC)
$(YACC) -d $(YACC_SRC)
# Generate scanner from Lex
$(LEX_OUT): $(LEX_SRC) $(YACC_HEADER)
$(LEX) $(LEX_SRC)
# Compile object files
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Clean generated files
clean:
rm -f $(TARGET) $(OBJS) $(LEX_OUT) $(YACC_OUT) $(YACC_HEADER)
# Phony targets
.PHONY: all clean