aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Makefile.dll-lib
blob: dee8e62c29fd6c2a63df995df2221998414c3894 (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
62
63
64
65
66
67
68
69
70
#
# This is a Makefile stub which handles the creation of Linux DLL-style shared
# libraries.
#
# In order to use this stub, the following makefile variables must be defined.
# 
# DLL_ADDRESS = 0x80000000
# DLL_JUMPSIZE = 0x1000
# DLL_GOTSIZE  = 0x1000
# DLL_VERSION = 1.0
# DLL_IMAGE = libce
# DLL_STUB = libcom_err
# DLL_MYDIR = et
# DLL_INSTALL_DIR = $(SHLIBDIR)
#

all:: image stubs

#
# This is a horrible hack to try to find libgcc.a  --- the DLL documentation
# states that you should just be able to do -lgcc, but modern gcc 
# installation packages don't install /usr/lib/libgcc.a --- as well they 
# shouldn't since libgcc.a can be gcc version dependent.  
# If this hack doesn't work, try replacing it with a hardcoded path to 
# libgcc.a, or -lgcc.  
#
#DLL_LIBGCC ="`$(CC) -v 2>&1 | head -1 | \
#		sed -e 's;[^/]*;;' -e 's/specs/libgcc.a/'`"
DLL_LIBGCC ="`$(CC) --print-libgcc-file-name`"

image:		$(DLL_IMAGE).so.$(DLL_VERSION)

stubs:		$(DLL_STUB).sa $(OBJS)

$(DLL_IMAGE).so.$(DLL_VERSION): $(OBJS)
	(cd jump; export JUMP_DIR=`pwd`; \
		$(DLL_BIN)/mkimage -l $(DLL_IMAGE) -v $(DLL_VERSION) \
		-a $(DLL_ADDRESS) -j $(DLL_JUMPSIZE) -g $(DLL_GOTSIZE) -- \
		$(OBJS) -lc $(DLL_LIBS) $(DLL_LIBGCC) -lc)
	mv jump/$(DLL_IMAGE).so.$(DLL_VERSION) .

$(DLL_STUB).sa:
	(cd jump; export JUMP_DIR=`pwd`; \
		$(DLL_BIN)/mkstubs -l $(DLL_IMAGE) -v $(DLL_VERSION) \
		-a $(DLL_ADDRESS) -j $(DLL_JUMPSIZE) -g $(DLL_GOTSIZE) \
		-- $(DLL_STUB))
	mv jump/$(DLL_STUB).sa .
	@$(RM) ../$@
	@$(LN) $(DLL_MYDIR)/$@ ../$@

install:: $(DLL_IMAGE).so.$(DLL_VERSION)
	$(INSTALLBIN) $(DLL_IMAGE).so.$(DLL_VERSION) \
		$(DLL_INSTALL_DIR)/$(DLL_IMAGE).so.$(DLL_VERSION)
	-ldconfig

install-libs:: $(DLL_STUB).sa
	$(INSTALLLIB) $(DLL_STUB).sa $(LIBDIR)/$(DLL_STUB).sa
	$(CHMOD) 644 $(LIBDIR)/$(DLL_STUB).sa
	$(RANLIB) $(LIBDIR)/$(DLL_STUB).sa
	$(CHMOD) $(LIBMODE) $(LIBDIR)/$(DLL_STUB).sa

install-tree:: $(DLL_IMAGE).so.$(DLL_VERSION)
	rm -f ../../shlibs/$(DLL_IMAGE).so.$(DLL_VERSION)
	cp $(DLL_IMAGE).so.$(DLL_VERSION) ../../shlibs
	strip ../../shlibs/$(DLL_IMAGE).so.$(DLL_VERSION)
	chmod 555 ../../shlibs/$(DLL_IMAGE).so.$(DLL_VERSION)

clean::
	(cd jump; $(RM) *~ *.o *.s jump.log size.nm)
	$(RM) ../$(DLL_STUB).sa $(DLL_STUB).sa $(DLL_IMAGE).so.$(DLL_VERSION)