summaryrefslogtreecommitdiff
path: root/src/Makefile
blob: 3d3e6cd3e06f43480be68d7a7a8e86c00b7da903 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
prefix=/usr
includedir=$(prefix)/include
libdir=$(prefix)/lib

ARCH := $(shell uname -m | sed -e s/i.86/i386/)
CFLAGS := -nostdlib -nostartfiles -Wall -I. -g -fomit-frame-pointer -O2
CFLAGS += $(shell if [ "$(ARCH)" != "i386" ] ; then echo -fPIC ; fi)
SO_CFLAGS=-shared $(CFLAGS)
L_CFLAGS=$(CFLAGS)
LINK_FLAGS=

soname=libaio.so.1
all_targets += libaio.a $(soname)

all: $(all_targets)

# libaio provided functions
libaio_srcs := io_queue_init.c io_queue_release.c
libaio_srcs += io_queue_wait.c io_queue_run.c

# real syscalls
libaio_srcs += io_getevents.c io_submit.c io_cancel.c
libaio_srcs += io_setup.c io_destroy.c

# internal functions
libaio_srcs += raw_syscall.c

# old symbols
libaio_srcs += compat-0_1.c

libaio_objs := $(patsubst %.c,%.ol,$(libaio_srcs))
libaio_sobjs := $(patsubst %.c,%.os,$(libaio_srcs))

$(libaio_objs) $(libaio_sobjs): libaio.h vsys_def.h

%.os: %.c
	$(CC) $(SO_CFLAGS) -c -o $@ $<

%.ol: %.c
	$(CC) $(L_CFLAGS) -c -o $@ $<


libaio.a: $(libaio_objs)
	rm -f libaio.a
	ar r libaio.a $^
	ranlib libaio.a

$(soname): $(libaio_sobjs) libaio.map
	$(CC) $(SO_CFLAGS) -Wl,--version-script=libaio.map -Wl,-soname=$(soname) -o $@ $(libaio_sobjs) $(LINK_FLAGS)

install: $(all_targets)
	install -D -m 644 libaio.h $(includedir)/libaio.h
	install -D -m 644 libaio.a $(libdir)/libaio.a
	install -D -m 755 $(soname) $(libdir)/$(soname)
	ln -sf $(soname) $(libdir)/libaio.so

$(libaio_objs): libaio.h

clean:
	rm -f $(all_targets) $(libaio_objs) $(libaio_sobjs) $(soname).new
	rm -f *.so* *.a *.o