53 lines
1.5 KiB
Makefile
53 lines
1.5 KiB
Makefile
|
|
CC=gcc
|
|
CFLAGS=-std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_POSIX_C_SOURCE=200809L -g
|
|
|
|
.PHONY: all clean
|
|
all: default
|
|
default: bin main intercept.so main_intercept #test_kernel.ko
|
|
|
|
bin:
|
|
mkdir -p bin/
|
|
|
|
bin/main.o: src/main.c
|
|
$(CC) -c -o $@ $^ $(CFLAGS)
|
|
|
|
bin/intercept_preload.o: src/intercept.c
|
|
$(CC) -fPIC -c -o $@ $^ $(CFLAGS) -DINTERCEPT_PRELOAD
|
|
|
|
intercept.so: bin/intercept_preload.o
|
|
$(CC) -shared -o $@ $^ $(CFLAGS) -lc -ldl
|
|
|
|
test_kernel.ko: src/test_kernel.c
|
|
$(CC) -D__KERNEL__ -DMODULE -I/usr/src/linux/include -o $@ $^
|
|
|
|
main: bin/main.o
|
|
$(CC) -o $@ $^ $(CFLAGS) -lc -lpthread
|
|
|
|
main_intercept: bin/main.o src/intercept.c
|
|
$(CC) -o $@ $^ $(CFLAGS) -lc -Wl,--wrap=malloc,--wrap=free,--wrap=calloc,--wrap=realloc,--wrap=reallocarray,--wrap=getopt,--wrap=exit,--wrap=close,--wrap=sigaction,\
|
|
--wrap=sem_init,--wrap=sem_open,--wrap=sem_post,--wrap=sem_wait,--wrap=sem_trywait,--wrap=sem_timedwait,--wrap=sem_getvalue,--wrap=sem_close,--wrap=sem_unlink,--wrap=sem_destroy
|
|
|
|
clean:
|
|
rm -rf main main_wrapped bin/* *.so *.ko *.o
|
|
|
|
|
|
#ifneq ($(KERNELRELEASE),)
|
|
# # call from kernel build system
|
|
# lifo-objs := main.o
|
|
# obj-m := lifo.o
|
|
#else
|
|
# KERNELDIR ?= /lib/modules/$(shell uname -r)/build
|
|
# PWD := $(shell pwd)
|
|
#modules:
|
|
# echo $(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)/../include modules
|
|
# $(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)/../include modules
|
|
#endif
|
|
#
|
|
#depend .depend dep:
|
|
# $(CC) $(CFLAGS) -M *.c > .depend
|
|
#
|
|
#ifeq (.depend,$(wildcard .depend))
|
|
# include .depend
|
|
#endif
|