1 # Copyright 2012 GRNET S.A. All rights reserved.
3 # Redistribution and use in source and binary forms, with or
4 # without modification, are permitted provided that the following
7 # 1. Redistributions of source code must retain the above
8 # copyright notice, this list of conditions and the following
11 # 2. Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following
13 # disclaimer in the documentation and/or other materials
14 # provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
29 # The views and conclusions contained in the software and
30 # documentation are those of the authors and should not be
31 # interpreted as representing official policies, either expressed
32 # or implied, of GRNET S.A.
35 .PHONY: default all clean drivers install install-src
37 include $(XSEG_HOME)/base.mk
40 FILES+=$(shell ls *.h)
41 FILES+=$(shell ls *.c)
43 EFILES+="make_symbol_map.sh"
45 SUBDIR:=$(subst $(XSEG_HOME),,$(CURDIR))
51 DRIVERS=xseg_posix xseg_segdev xseg_pthread xseg_posixfd
52 DRVDIR=$(BASE)/drivers/user
53 DRVOBJS=$(addsuffix .o, $(addprefix $(DRVDIR)/, $(DRIVERS)))
56 XTYPE_OBJS = $(addsuffix .o, $(XTYPES))
57 XTYPES_PICS = $(addsuffix .pic.o, $(XTYPES))
58 XTYPES_EXPORTS = $(addsuffix _exports.h, $(XTYPES))
60 EXPORT_DEPENDENCIES = $(addprefix $(BASE)/xtypes/, $(XTYPES_EXPORTS))
61 EXPORT_DEPENDENCIES += $(BASE)/xseg/xseg_exports.h
63 PIC_DEPENDENCIES = $(foreach xt, $(XTYPES), $(xt)/$(xt).pic.o)
64 PIC_DEPENDENCIES += xseg.pic.o
66 OBJ_DEPENDENCIES = $(foreach xt, $(XTYPES), $(xt)/$(xt).o)
67 OBJ_DEPENDENCIES += xseg.o _initialize.o
71 all: libxseg.a libxseg.so
72 make -C python all MAJOR=$(MAJOR) MINOR=$(MINOR)
73 @for xt in $(XTYPES) ; do \
78 _initialize.c: drivers
79 $(BASE)/tools/create_initializer $(DRIVERS) > _initialize.c
81 xseg.o: $(BASE)/xseg/xseg.c $(BASE)/xseg/xseg.h $(BASE)/xtypes/xq.h
82 $(CC) $(CFLAGS) $(INC) -c -o $@ $<
84 xseg.pic.o: $(BASE)/xseg/xseg.c $(BASE)/xseg/xseg.h _initialize.c
85 $(CC) $(CFLAGS) $(INC) -fPIC -c -o $@ $<
87 libxseg.so: libxseg.so.$(MAJOR)
91 libxseg.so.$(MAJOR): libxseg.so.$(MAJOR).$(MINOR)
96 make -C $(DRVDIR) $(addsuffix .o, $(DRIVERS))
105 make -C xpool xpool.o
108 make -C xpool xpool.pic.o
111 make -C xhash xhash.o
114 make -C xhash xhash.pic.o
117 make -C xheap xheap.o
120 make -C xheap xheap.pic.o
126 make -C xobj xobj.pic.o
129 make -C xworkq xworkq.o
132 make -C xworkq xworkq.pic.o
135 make -C xwaitq xwaitq.o
138 make -C xwaitq xwaitq.pic.o
141 make -C xbinheap xbinheap.o
143 xbinheap/xbinheap.pic.o:
144 make -C xbinheap xbinheap.pic.o
147 make -C xcache xcache.o
150 make -C xcache xcache.pic.o
152 xseg_user.o: xseg_user.c
153 $(CC) $(CFLAGS) $(INC) -Wall -O2 -finline-functions -fPIC -c -o $@ $<
155 libxseg.map: $(EXPORT_DEPENDENCIES)
156 cat $(EXPORT_DEPENDENCIES) | ./make_symbol_map.sh > $@
158 libxseg.so.$(MAJOR).$(MINOR): xseg_user.o libxseg.map \
159 $(PIC_DEPENDENCIES) $(DRVOBJS)
160 $(CC) $(CFLAGS) -shared \
161 -Wl,-soname=libxseg.so.$(MAJOR) \
162 -o libxseg.so.$(MAJOR).$(MINOR) \
164 $(PIC_DEPENDENCIES) $(DRVOBJS) \
166 -Wl,--version-script=libxseg.map \
170 libxseg.a: $(OBJ_DEPENDENCIES) drivers
171 $(AR) r libxseg.a $(OBJ_DEPENDENCIES) $(DRVOBJS)
175 make -C python install
176 install -d $(DESTDIR)$(libdir)
177 install -o 0 -g 0 -m 644 -t $(DESTDIR)$(libdir) libxseg.so.$(MAJOR).$(MINOR)
178 cp -vaf libxseg.so.$(MAJOR) $(DESTDIR)$(libdir)
179 cp -vaf libxseg.so $(DESTDIR)$(libdir)
182 @for xt in $(XTYPES) ; do \
183 make -C $$xt install-src ; \
185 make -C python install-src
186 install -d $(DESTDIR)$(srcdir)$(SUBDIR) ;
187 @for f in $(FILES) ; do \
188 install -o 0 -g 0 -m 644 -t $(DESTDIR)$(srcdir)$(SUBDIR) $$f ; \
190 @for f in $(EFILES) ; do \
191 install -o 0 -g 0 -m 755 -t $(DESTDIR)$(srcdir)$(SUBDIR) $$f ; \
196 @for xt in $(XTYPES) ; do \
197 make -C $$xt clean ; \
200 rm -f _initialize.c _initialize.o
201 rm -f xseg.o xseg.pic.o xseg_user.o
202 rm -f libxseg.a libxseg.map
203 rm -f libxseg.so libxseg.so.$(MAJOR) libxseg.so.$(MAJOR).$(MINOR)