-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (37 loc) · 916 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
# -----------------------------------------
# A wrapper for llvm ia32 instruction decoding
# Author: Ian Goforth
#
# A 3-second Makefile
# -----------------------------------------
TARGET = decoder
CC = gcc
AR = ar rcs
SRCDIR = src
LIBDIR = lib
OBJDIR = obj
BINDIR = bin
SRCS := $(wildcard $(SRCDIR)/*.c)
LIBS := $(wildcard $(LIBDIR)/$(LIBRARY)/*.c)
SOBJS := $(SRCS:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
LOBJS := $(LIBS:$(LIBDIR)/%.c=$(OBJDIR)/%.o)
rm = rm -rf
all: $(BINDIR)/$(LIBRARY) $(BINDIR)/$(TARGET)
$(BINDIR)/$(LIBRARY): $(LOBJS)
@mkdir -p $(@D)
@$(AR) [email protected] $<
$(LOBJS): $(OBJDIR)/%.o: $(LIBDIR)/%.c
@mkdir -p $(@D)
@$(CC) -c $< -o $@
$(BINDIR)/$(TARGET): $(SOBJS)
@mkdir -p $(@D)
@$(CC) -o $@ $(SOBJS)
$(SOBJS): $(OBJDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(@D)
@$(CC) -l$(LIBRARY) -L$(LIBDIR)/$(LIBRARY) -c $< -o $@
.PHONY: clean
clean:
@$(rm) $(OBJDIR)
.PHONY: remove
remove: clean
@$(rm) $(BINDIR)