2008-04-26 01:28:31 +00:00
|
|
|
#
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
|
|
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
# 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
# http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
# for the specific language governing rights and limitations under the
|
|
|
|
# License.
|
|
|
|
#
|
|
|
|
# The Original Code is Weave code.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# Mozilla Corporation
|
|
|
|
# Portions created by the Initial Developer are Copyright (C) 2008
|
|
|
|
# the Initial Developer. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s):
|
|
|
|
# Dan Mills <thunder@mozilla.com> (original author)
|
|
|
|
#
|
|
|
|
# Alternatively, the contents of this file may be used under the terms of
|
|
|
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
# of those above. If you wish to allow use of your version of this file only
|
|
|
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
# use your version of this file under the terms of the MPL, indicate your
|
|
|
|
# decision by deleting the provisions above and replace them with the notice
|
|
|
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
# the provisions above, a recipient may use your version of this file under
|
|
|
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
#
|
|
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
|
|
|
|
# Platform detection
|
|
|
|
|
|
|
|
sys := $(shell uname -s)
|
|
|
|
|
|
|
|
ifeq ($(sys), Linux)
|
|
|
|
os = Linux
|
|
|
|
compiler = gcc3
|
|
|
|
cxx = c++
|
|
|
|
so = so
|
|
|
|
cppflags += -shared
|
|
|
|
else
|
|
|
|
ifeq ($(sys), Darwin)
|
|
|
|
os = Darwin
|
|
|
|
compiler = gcc3
|
|
|
|
cxx = c++
|
|
|
|
so = dylib
|
|
|
|
cppflags += -dynamiclib
|
|
|
|
else
|
2008-05-14 01:37:07 +00:00
|
|
|
ifeq ($(sys), MINGW32_NT-6.0)
|
2008-04-26 01:28:31 +00:00
|
|
|
os = WINNT
|
|
|
|
compiler = msvc
|
2008-05-14 01:37:07 +00:00
|
|
|
cxx = cl
|
2008-04-26 01:28:31 +00:00
|
|
|
so = dll
|
|
|
|
else
|
2008-05-14 01:37:07 +00:00
|
|
|
$(error Sorry, your os is unknown/unsupported: $(sys))
|
2008-04-26 01:28:31 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
machine := $(shell uname -m)
|
|
|
|
|
|
|
|
ifeq ($(machine), i386)
|
|
|
|
arch = x86
|
|
|
|
else
|
|
|
|
ifeq ($(machine), i586)
|
|
|
|
arch = x86
|
|
|
|
else
|
|
|
|
ifeq ($(machine), i686)
|
|
|
|
arch = x86
|
|
|
|
else
|
|
|
|
ifeq ($(machine), ppc) # FIXME: verify
|
|
|
|
arch = ppc
|
|
|
|
else
|
2008-06-22 21:43:09 +00:00
|
|
|
ifeq ($(machine), arm)
|
|
|
|
arch = arm
|
|
|
|
else
|
|
|
|
# FIXME: x86_64, ia64, sparc, Alpha
|
|
|
|
$(error Sorry, your arch is unknown/unsupported: $(machine))
|
|
|
|
endif
|
2008-04-26 01:28:31 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
platform = $(os)_$(arch)-$(compiler)
|
|
|
|
|
2008-05-14 01:37:07 +00:00
|
|
|
######################################################################
|
|
|
|
|
|
|
|
idl = IWeaveCrypto.idl
|
|
|
|
cpp_sources = WeaveCrypto.cpp WeaveCryptoModule.cpp
|
2008-06-22 21:43:09 +00:00
|
|
|
# will have .so / .dylib / .dll appended
|
|
|
|
target = WeaveCrypto
|
2008-05-14 01:37:07 +00:00
|
|
|
|
|
|
|
sdkdir ?= ${MOZSDKDIR}
|
|
|
|
destdir = ..
|
|
|
|
platformdir = $(destdir)/platform/$(platform)
|
|
|
|
|
|
|
|
xpidl = $(sdkdir)/bin/xpidl
|
|
|
|
|
|
|
|
# FIXME: we don't actually require this for e.g. clean
|
|
|
|
ifeq ($(sdkdir),)
|
|
|
|
$(warning No 'sdkdir' variable given)
|
|
|
|
$(warning It should point to the location of the Gecko SDK)
|
|
|
|
$(warning For example: "make sdkdir=/foo/bar/baz")
|
|
|
|
$(warning Or set the MOZSDKDIR environment variable to point to it)
|
|
|
|
$(error )
|
|
|
|
endif
|
|
|
|
|
2008-04-26 01:28:31 +00:00
|
|
|
idl_headers = $(idl:.idl=.h)
|
|
|
|
idl_typelib = $(idl:.idl=.xpt)
|
|
|
|
cpp_objects = $(cpp_sources:.cpp=.o)
|
|
|
|
so_target = $(target:=.$(so))
|
|
|
|
|
2008-05-14 01:37:07 +00:00
|
|
|
headers = -I$(sdkdir)/include \
|
|
|
|
-I$(sdkdir)/include/system_wrappers \
|
|
|
|
-I$(sdkdir)/include/nss \
|
|
|
|
-I$(sdkdir)/include/xpcom \
|
|
|
|
-I$(sdkdir)/include/string \
|
|
|
|
-I$(sdkdir)/include/pipnss \
|
|
|
|
-I$(sdkdir)/include/nspr \
|
|
|
|
-I$(sdkdir)/sdk/include
|
|
|
|
|
|
|
|
libdirs := $(sdkdir)/lib $(sdkdir)/bin
|
2008-05-22 18:44:51 +00:00
|
|
|
libs := xpcomglue_s xpcom nspr4 \
|
2008-06-29 23:58:10 +00:00
|
|
|
crmf smime3 ssl3 nss3 nssutil3 \
|
2008-05-14 01:37:07 +00:00
|
|
|
plds4 plc4
|
|
|
|
|
2008-05-22 18:44:51 +00:00
|
|
|
ifeq ($(os), linux)
|
|
|
|
libs := xpcom_core $(libs)
|
|
|
|
endif
|
|
|
|
|
2008-05-14 01:37:07 +00:00
|
|
|
ifeq ($(compiler),msvc)
|
|
|
|
libdirs := $(patsubst %,-LIBPATH:%,$(libdirs))
|
|
|
|
libs := $(patsubst %,$(sdkdir)/lib/%.lib,$(libs))
|
2008-05-15 00:15:55 +00:00
|
|
|
cppflags += -c -nologo -O1 -GR- -TP -MT -Zc:wchar_t- -W3 -Gy $(headers) \
|
|
|
|
-DNDEBUG -DTRIMMED -D_CRT_SECURE_NO_DEPRECATE=1 \
|
|
|
|
-D_CRT_NONSTDC_NO_DEPRECATE=1 -DWINVER=0x500 -D_WIN32_WINNT=0x500 \
|
|
|
|
-D_WIN32_IE=0x0500 -DX_DISPLAY_MISSING=1 -DMOZILLA_VERSION=\"1.9pre\" \
|
|
|
|
-DMOZILLA_VERSION_U=1.9pre -DHAVE_SNPRINTF=1 -D_WINDOWS=1 -D_WIN32=1 \
|
|
|
|
-DWIN32=1 -DXP_WIN=1 -DXP_WIN32=1 -DHW_THREADS=1 -DSTDC_HEADERS=1 \
|
|
|
|
-DWIN32_LEAN_AND_MEAN=1 -DNO_X11=1 -DHAVE_MMINTRIN_H=1 \
|
|
|
|
-DHAVE_OLEACC_IDL=1 -DHAVE_ATLBASE_H=1 -DHAVE_WPCAPI_H=1 -D_X86_=1 \
|
|
|
|
-DD_INO=d_ino
|
|
|
|
ldflags += -DLL -NOLOGO -SUBSYSTEM:WINDOWS -NXCOMPAT -SAFESEH -IMPLIB:fake.lib \
|
|
|
|
$(libdirs) $(libs) \
|
|
|
|
kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib
|
2008-05-14 01:37:07 +00:00
|
|
|
rcflags := -r $(headers)
|
|
|
|
else
|
2008-05-20 23:53:14 +00:00
|
|
|
libdirs := $(patsubst %,-L%,$(libdirs))
|
|
|
|
libs := $(patsubst %,-l%,$(libs))
|
|
|
|
cppflags += -pipe -Os \
|
2008-05-14 01:37:07 +00:00
|
|
|
-fPIC -fno-rtti -fno-exceptions -fno-strict-aliasing \
|
2008-05-20 23:53:14 +00:00
|
|
|
-fno-common -fshort-wchar -pthread \
|
2008-05-14 01:37:07 +00:00
|
|
|
-Wall -Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth \
|
|
|
|
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align \
|
|
|
|
-Wno-long-long \
|
|
|
|
-include xpcom-config.h $(headers)
|
2008-05-20 23:53:14 +00:00
|
|
|
ifeq ($(os), Linux)
|
|
|
|
ldflags += -pthread -pipe -DMOZILLA_STRICT_API \
|
|
|
|
-Wl,-dead_strip \
|
|
|
|
-Wl,-exported_symbol \
|
2008-06-06 00:21:53 +00:00
|
|
|
-Wl,-z,defs -Wl,-h,WeaveCrypto.so \
|
|
|
|
-Wl,-rpath-link,$(sdkdir)/bin \
|
2008-05-20 23:53:14 +00:00
|
|
|
$(sdkdir)/lib/libxpcomglue_s.a \
|
|
|
|
$(libdirs) $(libs)
|
|
|
|
else
|
|
|
|
cppflags += -fpascal-strings -c
|
|
|
|
ldflags += -pthread -pipe -bundle \
|
|
|
|
-Wl,-executable_path,$(sdkdir)/bin \
|
|
|
|
-Wl,-dead_strip \
|
|
|
|
-Wl,-exported_symbol \
|
|
|
|
-Wl,_NSGetModule \
|
|
|
|
$(libdirs) $(libs)
|
|
|
|
endif
|
2008-05-14 01:37:07 +00:00
|
|
|
endif
|
|
|
|
|
2008-04-26 01:28:31 +00:00
|
|
|
######################################################################
|
|
|
|
|
2008-04-30 20:01:17 +00:00
|
|
|
.PHONY: all build install test-install clean
|
|
|
|
|
2008-04-26 01:28:31 +00:00
|
|
|
all: build # default target
|
|
|
|
|
|
|
|
build: $(so_target) $(idl_typelib)
|
|
|
|
|
|
|
|
install: build
|
|
|
|
mkdir -p $(destdir)/components
|
|
|
|
mkdir -p $(platformdir)/components
|
|
|
|
cp $(idl_typelib) $(destdir)/components
|
|
|
|
cp $(so_target) $(platformdir)/components
|
|
|
|
|
2008-04-30 20:01:17 +00:00
|
|
|
# gross hack to get around component registration for xpcshell tests
|
|
|
|
test-install: install
|
|
|
|
ln -sf `pwd`/$(destdir)/defaults/preferences/sync.js $(sdkdir)/bin/defaults/pref/sync.js # fixme!!
|
|
|
|
ln -sf `pwd`/$(destdir)/components/$(idl_typelib) $(sdkdir)/bin/components/$(idl_typelib)
|
|
|
|
ln -sf `pwd`/$(platformdir)/components/$(so_target) $(sdkdir)/bin/components/$(so_target)
|
|
|
|
rm -f $(sdkdir)/bin/components/compreg.dat
|
|
|
|
rm -f $(sdkdir)/bin/components/xpti.dat
|
|
|
|
|
2008-04-26 01:28:31 +00:00
|
|
|
clean:
|
2008-05-15 00:15:55 +00:00
|
|
|
rm -f $(so_target) $(cpp_objects) $(idl_typelib) $(idl_headers) $(target:=.res) fake.lib fake.exp
|
2008-04-26 01:28:31 +00:00
|
|
|
|
|
|
|
# rules to build the c headers and .xpt from idl
|
|
|
|
|
|
|
|
$(idl_headers): $(idl)
|
|
|
|
$(xpidl) -m header -I$(sdkdir)/idl $(@:.h=.idl)
|
|
|
|
|
|
|
|
$(idl_typelib): $(idl)
|
|
|
|
$(xpidl) -m typelib -I$(sdkdir)/idl $(@:.xpt=.idl)
|
|
|
|
|
|
|
|
# "main" (internal) rules, build sources and link the component
|
|
|
|
|
|
|
|
$(cpp_objects): $(cpp_sources)
|
2008-05-14 01:37:07 +00:00
|
|
|
ifeq ($(cxx),cl)
|
|
|
|
$(cxx) -Fo$@ -Fd$(@:.o=.pdb) $(cppflags) $(@:.o=.cpp)
|
2008-06-06 00:21:53 +00:00
|
|
|
endif
|
|
|
|
ifeq ($(os),Linux)
|
|
|
|
# don't need object files, but we need to satisfy make
|
|
|
|
touch $(cpp_objects)
|
2008-05-14 01:37:07 +00:00
|
|
|
else
|
2008-04-26 01:28:31 +00:00
|
|
|
$(cxx) -o $@ $(cppflags) $(@:.o=.cpp)
|
2008-05-14 01:37:07 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(compiler),msvc)
|
2008-05-31 01:53:07 +00:00
|
|
|
$(target:=.res): $(target:=.rc)
|
2008-05-14 01:37:07 +00:00
|
|
|
rc -Fo$@ $(rcflags) $(target:=.rc)
|
2008-04-26 01:28:31 +00:00
|
|
|
|
2008-05-14 01:37:07 +00:00
|
|
|
$(so_target): $(idl_headers) $(cpp_objects) $(target:=.res)
|
2008-05-15 00:15:55 +00:00
|
|
|
link -OUT:$@ -PDB:$(@:.dll=.pdb) $(cpp_objects) $(target:=.res) $(ldflags)
|
2008-05-23 01:52:52 +00:00
|
|
|
else
|
2008-05-20 23:53:14 +00:00
|
|
|
ifeq ($(os),Linux)
|
2008-05-31 01:53:07 +00:00
|
|
|
$(so_target): $(idl_headers) $(cpp_objects)
|
2008-06-06 00:21:53 +00:00
|
|
|
$(cxx) $(cppflags) -o $@ $(cpp_sources) $(ldflags)
|
2008-05-14 01:37:07 +00:00
|
|
|
else
|
2008-05-31 01:53:07 +00:00
|
|
|
$(so_target): $(idl_headers) $(cpp_objects)
|
2008-04-26 01:28:31 +00:00
|
|
|
$(cxx) -o $@ $(ldflags) $(cpp_objects)
|
2008-05-23 01:52:52 +00:00
|
|
|
endif
|
2008-05-14 01:37:07 +00:00
|
|
|
endif
|
2008-04-26 01:28:31 +00:00
|
|
|
chmod +x $@
|
|
|
|
# strip $@
|