diff -r adb27ed2f421 crypto/Makefile --- a/crypto/Makefile Fri Aug 21 17:32:41 2009 -0700 +++ b/crypto/Makefile Mon Aug 24 00:09:43 2009 +0200 @@ -39,12 +39,23 @@ stage_dir=../dist/stage sdkdir ?= ${MOZSDKDIR} + +# If blank, try to use pkg-config +# To add a path to pkg-config search path, use PKG_CONFIG_PATH +# (see man pkg-config) +ifeq ($(sdkdir),) + sdkdir = $(shell pkg-config --variable sdkdir libxul) +endif + 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) + $(warning Or fix your xulrunner pkg-config files) $(error) +else + $(info Using Mozilla SDKDIR as: ${sdkdir}) endif all: build diff -r adb27ed2f421 crypto/src/Makefile --- a/crypto/src/Makefile Fri Aug 21 17:32:41 2009 -0700 +++ b/crypto/src/Makefile Mon Aug 24 00:09:43 2009 +0200 @@ -37,9 +37,17 @@ # # ***** END LICENSE BLOCK ***** +# Define some custom pkg-config functions +pkg-config-var = $(shell pkg-config --variable $(1) $(2)) +pkg-config-I = $(shell pkg-config --cflags-only-I $(1) $(2)) +pkg-config-l = $(patsubst -l%,%,$(shell pkg-config --libs-only-l $(1))) +pkg-config-L = $(patsubst -L%,%,$(shell pkg-config --libs-only-L $(1))) + +# Actually use pkg-config? +pkgconfig = "no" + # OS detection -xpidl = $(sdkdir)/bin/xpidl link = link sys := $(shell uname -s) @@ -48,7 +56,6 @@ ifeq ($(wince), 1) os = WINNT cxx = $(sdkdir)/sdk/bin/arm-wince-gcc - xpidl = $(sdkdir)/host/bin/host_xpidl link = $(sdkdir)/sdk/bin/arm-wince-link so = dll else @@ -165,13 +172,24 @@ destdir = .. platformdir = $(destdir)/platform/$(platform) +# If blank, try to use pkg-config +# To add a path to pkg-config search path, use PKG_CONFIG_PATH +# (see man pkg-config) +ifeq ($(sdkdir),) + pkgconfig="yes" + sdkdir = $(call pkg-config-var,sdkdir,libxul) +endif + # 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) + $(warning Or fix your xulrunner pkg-config files) $(error ) +else + $(info Using Mozilla SDKDIR as: ${sdkdir}) endif idl_headers = $(idl:.idl=.h) @@ -179,30 +197,75 @@ cpp_objects = $(cpp_sources:.cpp=.o) so_target = $(target:=.$(so)) -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 +xpidl = $(sdkdir)/bin/xpidl +ifeq ($(wince), 1) + xpidl = $(sdkdir)/host/bin/host_xpidl +endif + +ifeq ($(pkgconfig),"yes") + # Include dirs + nss_includes = $(call pkg-config-I,nss) + nspr_includes = $(call pkg-config-I,nspr) + libxul_includes = $(call pkg-config-I,libxul) + + # Library dirs + nss_libdirs = $(call pkg-config-L,nss) + nspr_libdirs = $(call pkg-config-L,nspr) + libxul_libdirs = $(call pkg-config-L,libxul) + + # Libs + nss_libs = $(call pkg-config-l,nss) + nspr_libs = $(call pkg-config-l,nspr) + libxul_libs = $(call pkg-config-l,libxul) + + idl_dir = $(call pkg-config-var,idldir,libxul) + +# Fallback to Hard-coded +else + # Include dirs + nss_includes = -I$(sdkdir)/include/nss + nspr_includes = -I$(sdkdir)/include/nspr + libxul_includes = -I$(sdkdir)/include \ + -I$(sdkdir)/include/system_wrappers \ + -I$(sdkdir)/include/xpcom \ + -I$(sdkdir)/include/string \ + -I$(sdkdir)/include/pipnss \ + -I$(sdkdir)/sdk/include + + # Library dirs + libxul_libdirs = $(sdkdir)/lib $(sdkdir)/bin + nss_libdirs = $(libxul_libdirs) + nspr_libdirs = $(libxul_libdirs) + + # Libs + nss_libs = ssl3 smime3 nss3 nssutil3 + nspr_libs = nspr4 plds4 plc4 + libxul_libs = xpcomglue_s + ifeq ($(wince),1) + libxul_libs = $(libxul_libs) xpcom + else + libxul_libs = $(libxul_libs) xpcomglue + endif + + ifeq ($(os), linux) + libxul_libs = $(libxul_libs) xpcom_core + endif + + idl_dir = $(sdkdir)/idl +endif + +headers = $(nss_includes) \ + $(nspr_includes) \ + $(libxul_includes) # libraries -libdirs := $(sdkdir)/lib $(sdkdir)/bin -ifeq ($(wince),1) -libs := xpcomglue_s xpcom nspr4 \ - crmf smime3 ssl3 nss3 nssutil3 \ - plds4 plc4 -else -libs := xpcomglue xpcomglue_s nspr4 \ - crmf smime3 ssl3 nss3 nssutil3 \ - plds4 plc4 -endif +libdirs = $(nss_libdirs) \ + $(nspr_libdirs) \ + $(libxul_libdirs) -ifeq ($(os), Linux) - libs := xpcom_core $(libs) -endif +libs = $(nss_libs) \ + $(nspr_libs) \ + $(libxul_libs) # compiler and Linker Flags @@ -328,10 +391,10 @@ # rules to build the c headers and .xpt from idl $(idl_headers): $(idl) - $(xpidl) -m header -I$(sdkdir)/idl $(@:.h=.idl) + $(xpidl) -m header -I$(idl_dir) $(@:.h=.idl) $(idl_typelib): $(idl) - $(xpidl) -m typelib -I$(sdkdir)/idl $(@:.xpt=.idl) + $(xpidl) -m typelib -I$(idl_dir) $(@:.xpt=.idl) # build and link rules ifeq ($(os), Darwin)