-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (32 loc) · 1.05 KB
/
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
BUILDDIR = ./bin/
SOURCEDIR = ./src/
DEFINES =
PREFIX = /usr/local
INSTDIR = $(PREFIX)
INSTBIN = $(INSTDIR)/bin
SDIRS = $(wildcard $(SOURCEDIR)*/)
VPATH = $(SOURCEDIR):$(SDIRS):$(foreach dir, $(SDIRS), $(wildcard $(dir)*/))
IFILES = $(shell find $(SOURCEDIR) -name '*.c')
OFILES = $(subst $(SOURCEDIR), $(BUILDDIR), $(addsuffix .o, $(notdir $(shell find $(SOURCEDIR) -name '*.c'))))
CC = gcc
LINKER = $(CC)
ARCH = 64
CCFLAGS = -c -g -w -O3 -m$(ARCH) -std=c99
LINKFLAGS = -m$(ARCH)
TARGET = open8080
.PHONY: all install remove clean
all: $(BUILDDIR) $(TARGET)
$(BUILDDIR):
test -d $@ || mkdir -p $@
$(TARGET): $(foreach file, $(OFILES), $(BUILDDIR)$(file))
$(LINKER) $^ $(LINKFLAGS) -o $(BUILDDIR)$@
$(BUILDDIR)%.c.o: %.c
$(CC) $(foreach def, $(DEFINES), -D $(def)) $(CCFLAGS) $< -o $@
install:
test -d $(INSTDIR) || mkdir -p $(INSTDIR)
test -d $(INSTBIN) || mkdir -p $(INSTBIN)
install -m 0755 $(BUILDDIR)$(TARGET) $(INSTBIN)
remove:
rm $(INSTBIN)/$(TARGET)
clean:
rm $(BUILDDIR)*