2020-12-27 19:43:19 +00:00
|
|
|
|
2020-12-27 22:59:59 +00:00
|
|
|
CFLAGS += -std=gnu17 -Wall -fPIC #-fPIE
|
2020-12-27 19:43:19 +00:00
|
|
|
|
2020-12-27 22:59:59 +00:00
|
|
|
RANLIB ?= ranlib
|
|
|
|
|
|
|
|
LIBS += -ldl -lc -lm
|
|
|
|
LDFLAGS += -pie
|
2020-12-27 19:43:19 +00:00
|
|
|
#LDFLAGS += -Wl,-I,$(HOME)/src/glibc/glibc-build/elf/ld-linux-x86-64.so.2
|
|
|
|
|
2020-12-27 22:59:59 +00:00
|
|
|
default: release #debug
|
|
|
|
|
|
|
|
example: default example.elf
|
|
|
|
example-%: % example.elf
|
|
|
|
|
|
|
|
debug: CFLAGS += -g -Og -fsanitize=address
|
|
|
|
debug: LDFLAGS += -g -Og -fsanitize=address
|
|
|
|
debug: all
|
|
|
|
|
|
|
|
release: CFLAGS += -O2 -flto -ffat-lto-objects
|
|
|
|
release: LDFLAGS += -O2 -flto
|
|
|
|
release: all
|
|
|
|
|
|
|
|
all: libdynso.a libdynso.so
|
|
|
|
|
|
|
|
dynso.o: dynso.c
|
|
|
|
$(CC) -c -o "$@" $(CFLAGS) $^
|
|
|
|
|
|
|
|
libdynso.a: dynso.o
|
|
|
|
$(AR) rcvs $@ $^
|
|
|
|
# $(RANLIB) $@
|
|
|
|
|
|
|
|
libdynso.so: dynso.o
|
|
|
|
$(CC) -Wl,-soname=$@ -shared -o "$@" $^ $(CFLAGS)
|
|
|
|
|
|
|
|
example.elf: dynso.c example.c
|
|
|
|
$(CC) -o "$@" $^ $(CFLAGS) $(LDFLAGS) $(LIBS) -g -Og -fsanitize=address
|
2020-12-27 19:43:19 +00:00
|
|
|
|
|
|
|
clean:
|
2020-12-27 22:59:59 +00:00
|
|
|
$(RM) *.o *.so *.a example.elf
|
2020-12-27 19:43:19 +00:00
|
|
|
|
2020-12-27 22:59:59 +00:00
|
|
|
.PHONY: clean default debug release all example example-debug example-release
|
2020-12-27 19:43:19 +00:00
|
|
|
|