-
Notifications
You must be signed in to change notification settings - Fork 50
/
Makefile
59 lines (39 loc) · 1.4 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
.PHONY: all clean distclean
CC=gcc
FMT=clang-format
MKBOOTIMAGE_NAME:=mkbootimage
EXBOOTIMAGE_NAME:=exbootimage
VERSION_MAJOR:=2.3
VERSION_MINOR:=$(shell git rev-parse --short HEAD)
VERSION:=$(MKBOOTIMAGE_NAME) $(VERSION_MAJOR)-$(VERSION_MINOR)
COMMON_SRCS:=src/bif.c src/bootrom.c src/common.c \
$(wildcard src/arch/*.c) $(wildcard src/file/*.c)
COMMON_HDRS:=src/bif.h src/bootrom.h src/common.h \
$(wildcard src/arch/*.h) $(wildcard src/file/*.h)
MKBOOTIMAGE_SRCS:=$(COMMON_SRCS) src/mkbootimage.c
MKBOOTIMAGE_OBJS:=$(MKBOOTIMAGE_SRCS:.c=.o)
EXBOOTIMAGE_SRCS:=$(COMMON_SRCS) src/exbootimage.c
EXBOOTIMAGE_OBJS:=$(EXBOOTIMAGE_SRCS:.c=.o)
ALL_SRCS:=$(COMMON_SRCS) src/mkbootimage.c src/exbootimage.c
ALL_HDRS:=$(COMMON_HDRS)
INCLUDE_DIRS:=src
override CFLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir)) \
-DMKBOOTIMAGE_VER="\"$(VERSION)\"" \
-Wall -Wextra -Wpedantic \
--std=c11
LDLIBS = -lelf
all: $(MKBOOTIMAGE_NAME) $(EXBOOTIMAGE_NAME)
$(MKBOOTIMAGE_NAME): $(MKBOOTIMAGE_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(MKBOOTIMAGE_OBJS) -o $(MKBOOTIMAGE_NAME) $(LDLIBS)
$(EXBOOTIMAGE_NAME): $(EXBOOTIMAGE_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(EXBOOTIMAGE_OBJS) -o $(EXBOOTIMAGE_NAME) $(LDLIBS)
format:
$(FMT) -i $(ALL_SRCS) $(ALL_HDRS)
test:
./tests/tester.sh
clean:
@- $(RM) $(MKBOOTIMAGE_NAME)
@- $(RM) $(MKBOOTIMAGE_OBJS)
@- $(RM) $(EXBOOTIMAGE_NAME)
@- $(RM) $(EXBOOTIMAGE_OBJS)
distclean: clean