-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (36 loc) · 956 Bytes
/
Copy pathMakefile
File metadata and controls
48 lines (36 loc) · 956 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
46
47
48
CC = gcc
CFLAGS = -Wall -Wextra -g -ggdb3
LDFLAGS =
OBJDIR = obj
# Allow overriding password from command line
ifdef ADMIN_PWD
CFLAGS += -DDEFAULT_ADMIN_PASSWORD=\"$(ADMIN_PWD)\"
endif
# Source files
SRCS = main.c tinysh.c tiny_port.c tinysh_test.c tinysh_menu.c tinysh_menuconf.c tinysh_menu_test.c
OBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(SRCS))
# Target executable
TARGET = tinysh_shell
# Make sure the obj directory exists
$(shell mkdir -p $(OBJDIR))
# Default target
all: $(TARGET)
# Link object files to create executable
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^
# Compile source files into object files
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# Clean up build artifacts
clean:
rm -f $(TARGET) $(OBJS)
rm -rf $(OBJDIR)
# Run the shell for testing
run: $(TARGET)
./$(TARGET)
# Shorthand to run the automated tests
test: $(TARGET)
./$(TARGET) -test
# Rebuild everything
rebuild: clean all
.PHONY: all clean run test rebuild