-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
62 lines (46 loc) · 1.17 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
51
52
53
54
55
56
57
58
59
60
61
62
DESTDIR = /
PREFIX = /usr/local
SRC = .
DEST = ./build
IB = ib
CC = gcc
LD = gcc
STRIP = strip
CFLAGS = -Os -Wall
LDFLAGS = -flto
LIBS =
PROGRAM = ib
IB_HEADERS = $(wildcard $(SRC)/*.h.ib)
IB_CFILES = $(wildcard $(SRC)/*.c.ib)
HEADERS = $(patsubst $(SRC)/%.h.ib, $(DEST)/%.h, $(IB_HEADERS))
OBJS = $(patsubst $(SRC)/%.c.ib, $(DEST)/%.o, $(IB_CFILES))
CFILES = $(patsubst $(SRC)/%.c.ib, $(DEST)/%.c, $(IB_CFILES))
all: $(PROGRAM)
$(DEST)/%.h: $(SRC)/%.h.ib
@echo " IB $<"
@$(IB) $< -o $@
$(DEST)/%.c: $(SRC)/%.c.ib
@echo " IB $<"
@$(IB) $< -o $@
$(DEST)/%.o: $(DEST)/%.c
@echo " CC $<"
@$(CC) $< $(CFLAGS) -I build -c -o $@
$(PROGRAM): $(HEADERS) $(CFILES) $(OBJS)
@echo " LD $(PROGRAM)"
@$(LD) $(LDFLAGS) $(LIBS) $(OBJS) -o $(PROGRAM)
@echo " STRIP $(PROGRAM)"
#@$(STRIP) $(PROGRAM)
bootstrap:
@echo " CC $<"
@$(CC) $(DEST)/ib.c $(CFLAGS) $(LDFLAGS) -I build -o $(PROGRAM)
setup_test:
$(eval IB = ./ib)
test: setup_test clean $(PROGRAM)
make -C testing
clean:
@echo " CLEAN"
@rm -f $(DEST)/*.h $(DEST)/*.o $(DEST)/*.c
install:
@echo " INSTALL $(PROGRAM)"
@mkdir -p $(DESTDIR)/${PREFIX}/bin
@cp $(PROGRAM) $(DESTDIR)/$(PREFIX)/bin/