-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
44 lines (34 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
####################
# Build requirements
#
# - We specify as a minimum C99 for flexible array members.
# - Require compiler support for packed structures via __attribute__((packed))
#
CC := cc
OPT := ${OPT_FLAG}
FLAGS := -Wall -Wextra -Werror -Wpedantic -std=c99 -fPIC $(OPT)
SRC_ROOT := src
C_SRCS := $(shell find $(SRC_ROOT) -name '*.c')
BUILD_ROOT := build
C_DEPS := $(C_SRCS:$(SRC_ROOT)/%.c=$(BUILD_ROOT)/%.o)
HEADERS := $(shell find $(SRC_ROOT) -name '*.h')
dist/llvm-statepoint-tablegen.h: dist/llvm-statepoint-tablegen.a
cp $(SRC_ROOT)/include/api.h $@
dist/llvm-statepoint-tablegen.a: $(C_DEPS)
ar rvs $@ $^
# $< gives first prereq
$(BUILD_ROOT)/%.o: $(SRC_ROOT)/%.c $(HEADERS)
$(CC) $(FLAGS) -c $< -o $@
unified:
# roll together the headers. api.h needs to come first so we sort the headers.
cat $(sort $(HEADERS)) > $(BUILD_ROOT)/statepoint.h
# make the C file
echo "#include \"statepoint.h\"" > $(BUILD_ROOT)/statepoint.c
sed -E -e "s:[[:space:]]*#include[[:space:]]+\"include/.+\":// include auto-removed:g" $(C_SRCS) >> $(BUILD_ROOT)/statepoint.c
# ensure that it compiles
$(CC) $(FLAGS) -c $(BUILD_ROOT)/statepoint.c -o $(BUILD_ROOT)/statepoint.o
tar cvf unified-source.tar $(BUILD_ROOT)/statepoint.c $(BUILD_ROOT)/statepoint.h
clean:
rm -f build/*
rm -f dist/*
rm -f unified-source.tar