-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·53 lines (40 loc) · 1.29 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
# author: runsisi@hust.edu.cn
# date: 2013/08/24
.PHONY : all clean
CC := /opt/zte/x86_64_gcc4.5.2_glibc2.13.0/bin/x86_64-pc-linux-gnu-gcc
AR := /opt/zte/x86_64_gcc4.5.2_glibc2.13.0/bin/x86_64-pc-linux-gnu-ar
CODE_DIR := $(CURDIR)/../../..
ROOT_DIR := $(CURDIR)
TARGET := $(ROOT_DIR)/libbsdtcp.a
INC_DIRS := $(ROOT_DIR)/include \
$(ROOT_DIR)/include/opt \
$(ROOT_DIR)/include/amd64 \
$(ROOT_DIR)/include/x86 \
$(ROOT_DIR)/include/contrib/altq \
$(CODE_DIR)/dps/pub/include \
SRC_DIRS := $(ROOT_DIR)/source/kern \
$(ROOT_DIR)/source/libkern \
$(ROOT_DIR)/source/net \
$(ROOT_DIR)/source/netinet \
$(ROOT_DIR)/source/netinet/cc \
$(ROOT_DIR)/source/vm
INCS := $(addprefix -I, $(INC_DIRS))
SRCS := $(foreach dir, $(SRC_DIRS), $(wildcard $(dir)/*.c))
OBJS := $(SRCS:.c=.o)
DEPS := $(OBJS:.o=.d)
MACROS := -D_KERNEL
CFLAGS := -MD -MP $(INCS) $(MACROS)
all : $(TARGET)
@printf "\r\x1b[KCompilation done!\nBrought to u by runsisi@hust.edu.cn :)\n"
$(TARGET) : $(OBJS)
@$(AR) -crs $@ $^
# a little trick to use as a progress indicator, it is not a shell variable!!!
i := 0
%.o : %.c
$(eval i := $(shell expr $$(expr $(i) + 1) % 6))
@printf .
@$(CC) -c $(CFLAGS) -o $@ $<
@if [ $(i) -eq 0 ]; then printf "\r\x1b[K"; fi;
-include $(DEPS)
clean:
@rm -f $(OBJS) $(DEPS) $(TARGET)