-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
47 lines (32 loc) · 851 Bytes
/
Makefile
File metadata and controls
47 lines (32 loc) · 851 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
SRCDIR := srcs
OBJDIR := objs
INCDIR := incs
OUTDIR := .
AS := nasm
INCFLAGS := $(addprefix -I, $(addsuffix /, $(INCDIR)))
ASFLAGS := -g -F dwarf -f elf64 $(INCFLAGS)
RM := @rm -v -f
LD := ld
LDLIBS := readline c
LDLIBS := $(addprefix -l, $(LDLIBS))
LDFLAGS := $(INCFLAGS) -e main -I/lib/ld-linux-x86-64.so.2
NAME := $(OUTDIR)/ash
SRCS := builtins.s main.s exec.s prompt.s
OBJS := $(addprefix $(OBJDIR)/, $(SRCS))
SRCS := $(addprefix $(SRCDIR)/, $(SRCS))
OBJS := $(patsubst %.s, %.o, $(OBJS))
all: $(NAME)
$(NAME): | $(OBJDIR) $(OBJS)
@$(LD) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS)
@echo "linked '$@'"
$(OBJDIR):
@mkdir objs
$(OBJDIR)/%.o:: $(SRCDIR)/%.s
@$(AS) $(ASFLAGS) $< -o $@
@echo "compiled '$@'"
clean:; $(RM) $(OBJS)
fclean: clean
$(RM) $(NAME)
re: fclean all
.PHONY: all clean fclean re
get-%:; $($*)