aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Makefile.elf-lib
blob: 97d9a70e2e5e3ac244dcbc1be8b46e668604aaaa (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
71
72
73
74
#
# This is a Makefile stub which handles the creation of Linux ELF shared
# libraries.
#
# In order to use this stub, the following makefile variables must be defined.
# 
# ELF_VERSION = 1.0
# ELF_SO_VERSION = 1
# ELF_IMAGE = libce
# ELF_MYDIR = et
# ELF_INSTALL_DIR = $(SHLIBDIR)
# ELF_OTHER_LIBS = -lc

all:: elfshared image

subdirs:: elfshared

elfshared:
	@echo "	MKDIR elfshared"
	@mkdir elfshared

ELF_LIB = $(ELF_IMAGE).so.$(ELF_VERSION)
ELF_SONAME = $(ELF_IMAGE).so.$(ELF_SO_VERSION)

image:		$(ELF_LIB)

$(ELF_LIB): $(OBJS)
	@echo "	GEN_ELF_SOLIB $(ELF_LIB)"
	@(cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \
		-Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS))
	@$(MV) elfshared/$(ELF_LIB) .
	@$(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)
	@$(LN) $(ELF_LIB) ../$(ELF_LIB)
	@$(LN) ../$(ELF_LIB) ../$(ELF_IMAGE).so
	@$(LN) ../$(ELF_LIB) ../$(ELF_SONAME)

installdirs-elf-lib::
	@echo "	MKINSTALLDIRS $(ELF_INSTALL_DIR) $(libdir)"
	@$(MKINSTALLDIRS) $(DESTDIR)$(ELF_INSTALL_DIR) \
		$(DESTDIR)$(libdir)

installdirs:: installdirs-elf-lib

install-shlibs install:: $(ELF_LIB) installdirs-elf-lib
	@echo "	INSTALL-ELF-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
	@$(INSTALL_PROGRAM) $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)
	@echo "	SYMLINK $(ELF_INSTALL_DIR)/$(ELF_SONAME)"
	@$(LN_S) -f $(ELF_LIB) $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME)
	@echo "	SYMLINK $(libdir)/$(ELF_IMAGE).so"
	@$(LN_S) -f $(ELF_INSTALL_DIR)/$(ELF_SONAME) \
		$(DESTDIR)$(libdir)/$(ELF_IMAGE).so
	@echo "	LDCONFIG"
	@-$(LDCONFIG)

install-strip: install
	@echo "	STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
	@$(STRIP) --strip-unneeded --remove-section=.comment \
		--remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)

install-shlibs-strip: install-shlibs
	@echo "	STRIP-LIB $(ELF_INSTALL_DIR)/$(ELF_LIB)"
	@$(STRIP) --strip-unneeded --remove-section=.comment \
		--remove-section=.note $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB)

uninstall-shlibs uninstall::
	$(RM) -f $(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_LIB) \
		$(DESTDIR)$(ELF_INSTALL_DIR)/$(ELF_SONAME) \
		$(DESTDIR)$(libdir)/$(ELF_IMAGE).so
	-$(LDCONFIG)

clean::
	$(RM) -rf elfshared
	$(RM) -f $(ELF_LIB)
	$(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME)