1include ../Makefile.common 2 3prefix ?= /usr 4includedir ?= $(prefix)/include 5libdir ?= $(prefix)/lib 6libdevdir ?= $(prefix)/lib 7 8CPPFLAGS ?= 9override CPPFLAGS += -D_GNU_SOURCE \ 10 -Iinclude/ -include ../config-host.h 11CFLAGS ?= -g -O2 -Wall -Wextra -fno-stack-protector 12override CFLAGS += -Wno-unused-parameter -Wno-sign-compare -DLIBURING_INTERNAL 13SO_CFLAGS=-fPIC $(CFLAGS) 14L_CFLAGS=$(CFLAGS) 15LINK_FLAGS= 16LINK_FLAGS+=$(LDFLAGS) 17ENABLE_SHARED ?= 1 18 19soname=liburing.so.$(VERSION_MAJOR) 20libname=liburing.so.$(VERSION) 21all_targets += liburing.a 22 23ifeq ($(ENABLE_SHARED),1) 24all_targets += $(libname) 25endif 26 27include ../Makefile.quiet 28 29ifneq ($(MAKECMDGOALS),clean) 30include ../config-host.mak 31endif 32 33all: $(all_targets) 34 35liburing_srcs := setup.c queue.c register.c 36 37ifeq ($(CONFIG_NOLIBC),y) 38 liburing_srcs += nolibc.c 39 override CFLAGS += -nostdlib -nodefaultlibs -ffreestanding 40 override CPPFLAGS += -nostdlib -nodefaultlibs -ffreestanding 41 override LINK_FLAGS += -nostdlib -nodefaultlibs 42else 43 liburing_srcs += syscall.c 44endif 45 46override CPPFLAGS += -MT "$@" -MMD -MP -MF "[email protected]" 47liburing_objs := $(patsubst %.c,%.ol,$(liburing_srcs)) 48liburing_sobjs := $(patsubst %.c,%.os,$(liburing_srcs)) 49 50%.os: %.c 51 $(QUIET_CC)$(CC) $(CPPFLAGS) $(SO_CFLAGS) -c -o $@ $< 52 53%.ol: %.c 54 $(QUIET_CC)$(CC) $(CPPFLAGS) $(L_CFLAGS) -c -o $@ $< 55 56# Include compiler generated dependency files. 57-include $(liburing_objs:%=%.d) 58-include $(liburing_sobjs:%=%.d) 59 60AR ?= ar 61RANLIB ?= ranlib 62liburing.a: $(liburing_objs) 63 @rm -f liburing.a 64 $(QUIET_AR)$(AR) r liburing.a $^ 65 $(QUIET_RANLIB)$(RANLIB) liburing.a 66 67$(libname): $(liburing_sobjs) liburing.map 68 $(QUIET_CC)$(CC) $(SO_CFLAGS) -shared -Wl,--version-script=liburing.map -Wl,-soname=$(soname) -o $@ $(liburing_sobjs) $(LINK_FLAGS) 69 70install: $(all_targets) 71 install -D -m 644 include/liburing/io_uring.h $(includedir)/liburing/io_uring.h 72 install -D -m 644 include/liburing.h $(includedir)/liburing.h 73 install -D -m 644 include/liburing/compat.h $(includedir)/liburing/compat.h 74 install -D -m 644 include/liburing/barrier.h $(includedir)/liburing/barrier.h 75 install -D -m 644 liburing.a $(libdevdir)/liburing.a 76ifeq ($(ENABLE_SHARED),1) 77 install -D -m 755 $(libname) $(libdir)/$(libname) 78 ln -sf $(libname) $(libdir)/$(soname) 79 ln -sf $(relativelibdir)$(libname) $(libdevdir)/liburing.so 80endif 81 82clean: 83 @rm -f $(all_targets) $(liburing_objs) $(liburing_sobjs) $(soname).new 84 @rm -f *.so* *.a *.o *.d 85 @rm -f include/liburing/compat.h 86 87 @# When cleaning, we don't include ../config-host.mak, 88 @# so the nolibc objects are always skipped, clean them up! 89 @rm -f nolibc.ol nolibc.os 90