2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is mozilla.org code.
17 # The Initial Developer of the Original Code is
19 # Portions created by the Initial Developer are Copyright (C) 2008
20 # the Initial Developer. All Rights Reserved.
23 # Ted Mielczarek <ted.mielczarek@gmail.com>
25 # Alternatively, the contents of this file may be used under the terms of
26 # either of the GNU General Public License Version 2 or later (the "GPL"),
27 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
40 topsrcdir
= @top_srcdir@
44 include $(DEPTH
)/config
/autoconf.mk
48 # jemalloc.c properly uses 'static', so don't burden it with manually exposing
52 ifeq (WINNT
,$(OS_TARGET
))
53 # Building the CRT from source
54 CRT_OBJ_DIR
= $(CURDIR
)/crtsrc
55 MOZ_CRT_DLL_NAME
= mozcrt19
56 MOZ_CRTCPP_DLL_NAME
= mozcpp19
57 MOZ_CRT_STATIC_LIBS
= libcmt libcpmt
58 MOZ_CRT_DLL
= $(CRT_OBJ_DIR
)/build
/$(MOZ_CRT_CPU_ARCH
)/$(MOZ_CRT_DLL_NAME
).dll
59 MOZ_CRT_IMPORT_LIB
= $(CRT_OBJ_DIR
)/build
/$(MOZ_CRT_CPU_ARCH
)/$(MOZ_CRT_DLL_NAME
).lib
60 MOZ_CRTCPP_DLL
= $(CRT_OBJ_DIR
)/build
/$(MOZ_CRT_CPU_ARCH
)/$(MOZ_CRTCPP_DLL_NAME
).dll
61 MOZ_CRTCPP_IMPORT_LIB
= $(CRT_OBJ_DIR
)/build
/$(MOZ_CRT_CPU_ARCH
)/$(MOZ_CRTCPP_DLL_NAME
).lib
63 # copy the CRT DLLs to dist/bin,
64 # copy the import libs to dist/lib
65 libs
:: $(MOZ_CRT_DLL
) $(MOZ_CRT_IMPORT_LIB
)
66 $(INSTALL
) $(MOZ_CRT_DLL
) $(MOZ_CRTCPP_DLL
) $(FINAL_TARGET
)
67 $(INSTALL
) $(MOZ_CRT_IMPORT_LIB
) $(MOZ_CRTCPP_IMPORT_LIB
) $(DIST
)/lib
69 $(MOZ_CRT_IMPORT_LIB
): $(MOZ_CRT_DLL
)
72 cd
$(CRT_OBJ_DIR
)/$(MOZ_CRT_CPU_ARCH
)/$(i
)_lib
&& lib
"-extract:..\\build\\$(MOZ_CRT_CPU_ARCH)\\$(i)_obj\\unhandld.obj" eh.lib
74 endef # don't touch the blank line. actually, don't touch anything in this file.
77 ifeq ($(CC_VERSION
), 14.00.50727.762)
78 CRTDIFF
=crtvc8sp1-
$(MOZ_CRT_CPU_ARCH
).diff
80 CRTDIFF
=crtvc9sp1-
$(MOZ_CRT_CPU_ARCH
).diff
83 $(CRT_OBJ_DIR
)/jemalloc.c
: $(srcdir)/$(CRTDIFF
)
85 cp
-R
"$(WIN32_CRT_SRC_DIR)" $(CRT_OBJ_DIR
)
86 # per http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1189363&SiteID=1
87 $(foreach i
,dll mt xdll xmt
,$(EXTRACT_CMD
))
89 #XXX: get ed into mozillabuild, bug 415123
90 $(PERL
) $(srcdir)/apply-ed-patches.pl
$(srcdir)/$(CRTDIFF
) \
91 $(CRT_OBJ_DIR
) $(srcdir)/ed.exe
94 $(CRT_OBJ_DIR
)/jemalloc.c
$(srcdir)/jemalloc.c
$(srcdir)/jemalloc.h \
95 $(srcdir)/jemalloc_types.h
$(srcdir)/rb.h
96 cp
$(srcdir)/jemalloc.c
$(srcdir)/jemalloc.h
$(srcdir)/jemalloc_types.h
$(srcdir)/rb.h \
98 # this pretty much sucks, but nmake and make don't play well together
99 $(PYTHON
) $(srcdir)/build-crt.py
$(CRT_OBJ_DIR
)
100 # XXX: these don't link right for some reason; the problem is likely
101 # that not all the standard symbols are exported; looks like MSFT
102 # never updated the sample.def files; could probably fix if someone
103 # were ever bored enough. :-)
104 rm -f
$(addsuffix .lib
, $(addprefix $(CRT_OBJ_DIR
)/build
/$(MOZ_CRT_CPU_ARCH
)/, $(MOZ_CRT_STATIC_LIBS
)))
105 rm -f
$(addsuffix .pdb
, $(addprefix $(CRT_OBJ_DIR
)/build
/$(MOZ_CRT_CPU_ARCH
)/, $(MOZ_CRT_STATIC_LIBS
)))
107 # but still export jemalloc.h
108 EXPORTS
= jemalloc.h jemalloc_types.h
112 MODULE_OPTIMIZE_FLAGS
= -O2
113 ifeq ($(OS_ARCH
),SunOS
)
115 MODULE_OPTIMIZE_FLAGS
= -xO5
119 LIBRARY_NAME
= jemalloc
121 # Build jemalloc as a shared lib. This is mandatory for Darwin, since a library
122 # init function is used on that platform.
123 ifeq ($(OS_ARCH
),Darwin
)
130 EXPORTS
= jemalloc.h jemalloc_types.h
133 #XXX: PGO on Linux causes problems here
135 NO_PROFILE_GUIDED_OPTIMIZE
= 1
138 ifdef WRAP_MALLOC_CFLAGS
139 DEFINES
+= -DWRAP_MALLOC
142 include $(topsrcdir
)/config
/rules.mk
144 ifeq (Darwin
,$(OS_TARGET
))
145 LDFLAGS
+= -init _jemalloc_darwin_init