sys/user: Python xseg bindings
[archipelago] / xseg / sys / user / Makefile
1 .PHONY: default all clean drivers
2
3 include $(XSEG_HOME)/base.mk
4
5 MAJOR=0
6 MINOR=0.1
7 AR=ar
8
9 DRIVERS=xseg_posix xseg_segdev
10 DRVDIR=$(BASE)/drivers/user
11 DRVOBJS=$(addsuffix .o, $(addprefix $(DRVDIR)/, $(DRIVERS)))
12 SHELL=/bin/bash
13
14 default: all
15
16 all: libxseg.a libxseg.so
17         make -C xq all
18         make -C python all
19
20 COMMA=,
21 _initialize.c: drivers
22         $(BASE)/tools/create_initializer $(DRIVERS) > _initialize.c
23
24 xseg.o: $(BASE)/xseg/xseg.c $(BASE)/xseg/xseg.h $(BASE)/xq/xq.h
25         $(CC) $(CFLAGS) $(INC) -c -o $@ $<
26
27 xseg.pic.o: $(BASE)/xseg/xseg.c $(BASE)/xseg/xseg.h _initialize.c
28         $(CC) $(CFLAGS) $(INC) -fPIC -c -o $@ $<
29
30 libxseg.so: libxseg.so.$(MAJOR)
31         ln -sf $< $@
32         cp -vaf $@ $(LIB)
33
34 libxseg.so.$(MAJOR): libxseg.so.$(MAJOR).$(MINOR)
35         ln -sf $< $@
36         cp -vaf $@ $(LIB)
37
38 drivers:
39         make -C $(DRVDIR) $(addsuffix .o, $(DRIVERS))
40
41 xq/xq.o:
42         make -C xq xq.o
43
44 xq/xq.pic.o:
45         make -C xq xq.pic.o
46
47 xseg_user.o: xseg_user.c
48         $(CC) $(CFLAGS) $(INC) -Wall -O2 -finline-functions -fPIC -c -o $@ $<
49
50 libxseg.map: $(BASE)/xq/xq_exports.h $(BASE)/xseg/xseg_exports.h
51         cat $(BASE)/xq/xq_exports.h $(BASE)/xseg/xseg_exports.h | ./make_symbol_map.sh > $@
52
53 libxseg.so.$(MAJOR).$(MINOR): xseg.pic.o xseg_user.o libxseg.map \
54                                  xq/xq.pic.o $(DRVOBJS)
55         $(CC) $(CFLAGS) -shared \
56                         -Wl,-soname=libxseg.so.$(MAJOR) \
57                         -o libxseg.so.$(MAJOR).$(MINOR) \
58                         xseg.pic.o xseg_user.o xq/xq.pic.o \
59                          _initialize.o $(DRVOBJS) \
60                         -Wl,--version-script=libxseg.map \
61                         -ldl -lrt
62         cp -vaf $@ $(LIB)
63
64 libxseg.a: xseg.o xq/xq.o drivers _initialize.o
65         $(AR) r libxseg.a xseg.o xq/xq.o _initialize.o $(DRVOBJS)
66         cp -vaf $@ $(LIB)
67
68 clean:
69         make -C xq clean
70         make -C python clean
71         rm -f _initialize.c _initialize.o
72         rm -f xseg.o xseg.pic.o xseg_user.o
73         rm -f libxseg.a libxseg.map
74         rm -f libxseg.so libxseg.so.$(MAJOR) libxseg.so.$(MAJOR).$(MINOR)