Line 0
Link Here
|
|
|
1 |
# |
2 |
# lib.mak |
3 |
# |
4 |
# Make rules for building libraries rather than applications. |
5 |
# |
6 |
# Portable Windows Library |
7 |
# |
8 |
# Copyright (c) 1993-1998 Equivalence Pty. Ltd. |
9 |
# |
10 |
# The contents of this file are subject to the Mozilla Public License |
11 |
# Version 1.0 (the "License"); you may not use this file except in |
12 |
# compliance with the License. You may obtain a copy of the License at |
13 |
# http://www.mozilla.org/MPL/ |
14 |
# |
15 |
# Software distributed under the License is distributed on an "AS IS" |
16 |
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
17 |
# the License for the specific language governing rights and limitations |
18 |
# under the License. |
19 |
# |
20 |
# The Original Code is Portable Windows Library. |
21 |
# |
22 |
# The Initial Developer of the Original Code is Equivalence Pty. Ltd. |
23 |
# |
24 |
# Contributor(s): ______________________________________. |
25 |
# |
26 |
# $Revision: 23463 $ |
27 |
# $Author: csoutheren $ |
28 |
# $Date: 2009-09-15 21:57:13 -0500 (Tue, 15 Sep 2009) $ |
29 |
# |
30 |
|
31 |
ifeq (,$(findstring $(OSTYPE),Darwin cygwin mingw)) |
32 |
ifeq ($(BUILD_TYPE),.) |
33 |
LIBNAME_PAT = $(LIB_FILENAME).$(MAJOR_VERSION).$(MINOR_VERSION).$(BUILD_NUMBER) |
34 |
else |
35 |
LIBNAME_PAT = $(LIB_FILENAME).$(MAJOR_VERSION).$(MINOR_VERSION)-$(BUILD_TYPE)$(BUILD_NUMBER) |
36 |
endif |
37 |
else |
38 |
ifeq ($(BUILD_TYPE),.) |
39 |
LIBNAME_PAT = $(subst .$(LIB_SUFFIX),.$(MAJOR_VERSION).$(MINOR_VERSION).$(BUILD_NUMBER).$(LIB_SUFFIX),$(LIB_FILENAME)) |
40 |
else |
41 |
LIBNAME_PAT = $(subst .$(LIB_SUFFIX),.$(MAJOR_VERSION).$(MINOR_VERSION)-$(BUILD_TYPE)$(BUILD_NUMBER).$(LIB_SUFFIX),$(LIB_FILENAME)) |
42 |
endif |
43 |
endif |
44 |
|
45 |
LIB_SONAME = $(LIBNAME_PAT) |
46 |
|
47 |
ifneq ($(P_SHAREDLIB),1) |
48 |
STATIC_LIB_FILE = $(LIBDIR)/$(LIB_FILENAME) |
49 |
else |
50 |
STATIC_LIB_FILE = $(LIBDIR)/$(subst .$(LIB_SUFFIX),_s.$(STATICLIBEXT),$(LIB_FILENAME)) |
51 |
endif |
52 |
|
53 |
CLEAN_FILES += $(LIBDIR)/$(LIBNAME_PAT) $(LIBDIR)/$(LIB_FILENAME) $(STATIC_LIB_FILE) |
54 |
|
55 |
$(LIBDIR)/$(LIB_FILENAME) : $(TARGETLIB) |
56 |
|
57 |
ifeq ($(P_SHAREDLIB),1) |
58 |
|
59 |
ENDLDLIBS := $(SYSLIBS) $(ENDLDLIBS) |
60 |
ifeq ($(OSTYPE),beos) |
61 |
# BeOS requires different options when building shared libraries |
62 |
# Also, when building a shared library x that references symbols in libraries y, |
63 |
# the y libraries need to be added to the linker command |
64 |
LDSOOPTS = -nostdlib -nostart |
65 |
EXTLIBS = -lstdc++.r4 |
66 |
else |
67 |
ifeq ($(OSTYPE),Darwin) |
68 |
LDSOOPTS = -dynamiclib |
69 |
else |
70 |
LDSOOPTS = -shared |
71 |
endif |
72 |
endif |
73 |
|
74 |
ifeq ($(OSTYPE),rtems) |
75 |
EXTLIBS = -lstdc++ |
76 |
endif |
77 |
|
78 |
ifneq ($(OSTYPE), QNX) |
79 |
ifneq (,$(findstring $(OSTYPE),FreeBSD OpenBSDs)) |
80 |
ifdef P_PTHREADS |
81 |
EXTLIBS += -pthread |
82 |
endif |
83 |
else |
84 |
ifdef P_PTHREADS |
85 |
EXTLIBS += -lpthread |
86 |
endif |
87 |
endif |
88 |
endif |
89 |
|
90 |
# Solaris loader doesn't grok -soname (sees it as -s -oname) |
91 |
# We could use -Wl,-h,$(LIB_BASENAME).1 but then we find that the arglist |
92 |
# to gcc is 2900+ bytes long and it will barf. I fix this by invoking ld |
93 |
# directly and passing it the equivalent arguments...jpd@louisiana.edu |
94 |
ifeq ($(OSTYPE),solaris) |
95 |
LDSOOPTS = -Bdynamic -G -h $(LIB_SONAME) |
96 |
else |
97 |
ifeq ($(OSTYPE),mingw) |
98 |
LDSOOPTS += -Wl,--kill-at |
99 |
else |
100 |
ifneq ($(OSTYPE),Darwin) |
101 |
LDSOOPTS += -Wl,-soname,$(LIB_SONAME) |
102 |
endif |
103 |
endif |
104 |
endif |
105 |
|
106 |
$(LIBDIR)/$(LIB_FILENAME): $(LIBDIR)/$(LIBNAME_PAT) |
107 |
@cd $(LIBDIR) ; rm -f $(LIB_FILENAME) ; ln -sf $(LIBNAME_PAT) $(LIB_FILENAME) |
108 |
|
109 |
$(LIBDIR)/$(LIBNAME_PAT): $(STATIC_LIB_FILE) |
110 |
@if [ ! -d $(LIBDIR) ] ; then mkdir $(LIBDIR) ; fi |
111 |
$(Q_LD)$(LD) $(LDSOOPTS) -o $(LIBDIR)/$(LIBNAME_PAT) $(LDFLAGS) $(EXTLIBS) $(OBJS) $(ENDLDLIBS) |
112 |
|
113 |
endif # P_SHAREDLIB |
114 |
|
115 |
$(STATIC_LIB_FILE): $(OBJS) |
116 |
@if [ ! -d $(LIBDIR) ] ; then mkdir $(LIBDIR) ; fi |
117 |
$(Q_AR)$(ARCHIVE) $(STATIC_LIB_FILE) $(OBJS) |
118 |
ifeq ($(P_USE_RANLIB),1) |
119 |
$(RANLIB) $(STATIC_LIB_FILE) |
120 |
endif |
121 |
|
122 |
|
123 |
|
124 |
# End of file ################################################################ |
125 |
|