-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (35 loc) · 1.23 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
PLUGIN := cprintf
PLUGIN_SO := $(addsuffix .so,$(PLUGIN))
OBJS := cprintf log printfun gcc_hell
PLUGIN_INCLUDE := $(shell gcc -print-file-name=plugin)
ifeq ($(PLUGIN_INCLUDE),plugin)
$(error Error: GCC API for plugins is not installed on your system)
endif
CXX := g++
CC := gcc
CXXFLAGS += -I $(PLUGIN_INCLUDE)/include
all: $(PLUGIN_SO)
$(PLUGIN_SO): $(addsuffix .o,$(OBJS))
$(CXX) $(LDFLAGS) -shared -fno-rtti -o $@ $^
%.o: %.cpp
$(CXX) $(CXXFLAGS) -fPIC -fno-rtti -c -o $@ $<
clean:
rm -f $(addsuffix .so,$(PLUGIN)) $(addsuffix .o,$(PLUGIN))
rm -f ./test/quicksort
rm -f ./test/crlog
check: $(PLUGIN_SO)
$(CXX) -fplugin=./$(PLUGIN_SO) -c -x c++ /dev/null -o /dev/null \
-fplugin-arg-cprintf-log_level=Err \
-fplugin-arg-cprintf-printf="printf(0): %c putchar"
$(CC) -fplugin=./$(PLUGIN_SO) \
./test/quicksort.c -o ./test/quicksort \
-fplugin-arg-cprintf-printf="printf(0): %d putchar %s puts"
$(CC) ./test/crlog.c -o ./test/crlog
./test/crlog > /dev/null
$(CC) -fplugin=./$(PLUGIN_SO) \
./test/crlog.c -o ./test/crlog \
-fplugin-arg-cprintf-printf="printf(0): %s __puts \
%c putchar %li __putlong %d __putshort \
%lu __putulong %% __putwrite"
./test/crlog > /dev/null
.PHONY: all clean check