1PROJECT=libboundscheck.so 2 3CC?=gcc 4 5OPTION = -fPIC 6OPTION += -fstack-protector-all 7OPTION += -D_FORTIFY_SOURCE=2 -O2 8OPTION += -Wformat=2 -Wfloat-equal -Wshadow 9OPTION += -Wconversion 10OPTION += -Wformat-security 11OPTION += -Wextra 12OPTION += --param ssp-buffer-size=4 13OPTION += -Warray-bounds 14OPTION += -Wpointer-arith 15OPTION += -Wcast-qual 16OPTION += -Wstrict-prototypes 17OPTION += -Wmissing-prototypes 18OPTION += -Wstrict-overflow=1 19OPTION += -Wstrict-aliasing=2 20OPTION += -Wswitch -Wswitch-default 21 22CFLAG = -Wall -DNDEBUG -O2 $(OPTION) 23 24SOURCES=$(wildcard src/*.c) 25 26OBJECTS=$(patsubst %.c,%.o,$(SOURCES)) 27 28.PHONY:clean 29 30CFLAG += -Iinclude 31LD_FLAG = -fPIC -s -Wl,-z,relro,-z,now,-z,noexecstack -fstack-protector-all 32 33$(PROJECT): $(OBJECTS) 34 mkdir -p lib 35 $(CC) -shared -o lib/$@ $(patsubst %.o,obj/%.o,$(notdir $(OBJECTS))) $(LD_FLAG) 36 @echo "finish $(PROJECT)" 37 38.c.o: 39 @mkdir -p obj 40 $(CC) -c $< $(CFLAG) -o obj/$(patsubst %.c,%.o,$(notdir $<)) 41 42clean: 43 -rm -rf obj lib 44 @echo "clean up" 45