aboutsummaryrefslogtreecommitdiff
path: root/build/cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-15 17:54:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-15 17:54:41 +0200
commitec41632b536fbab63ce732a2439b38ae1c32b095 (patch)
treeea35808e934761d74711a9d0c0cb4e9150c07985 /build/cxx
parentdc62e900fb739b41b0f5e5ea028dadb0b86e72a7 (diff)
Add support for building MinWG shared libraries with GCC
Diffstat (limited to 'build/cxx')
-rwxr-xr-xbuild/cxx/gnu/configure33
-rw-r--r--build/cxx/gnu/o-l.make22
2 files changed, 51 insertions, 4 deletions
diff --git a/build/cxx/gnu/configure b/build/cxx/gnu/configure
index bda4bdb..7e5820e 100755
--- a/build/cxx/gnu/configure
+++ b/build/cxx/gnu/configure
@@ -31,10 +31,30 @@ $echo
cxx_gnu=`read_path --command g++`
# Pass cxx_extra_options and cxx_ld_extra_options since those
-# can affect the search paths (e.g., -m32).
+# can affect the search paths (e.g., -m32) and target.
#
cxx_gnu_libraries=`$cxx_gnu $3 $4 -print-search-dirs | sed -e 's/libraries: =//p' -e d`
+cxx_gnu_target=`$cxx_gnu $3 $4 -dumpmachine`
+cxx_gnu_target=`$bld_root/system/config.sub "$cxx_gnu_target"`
+
+if [ $? != 0 ]; then
+ $echo "unable to canonicalize target system '$cxx_gnu_target'"
+ exit 1
+fi
+
+cxx_gnu_target_cpu=`echo $cxx_gnu_target | cut -f 1 -d -`
+cxx_gnu_target_mf=`echo $cxx_gnu_target | cut -f 2 -d -`
+cxx_gnu_target_kernel=`echo $cxx_gnu_target | cut -f 3 -d -`
+cxx_gnu_target_os=`echo $cxx_gnu_target | cut -f 4 -d -`
+
+if [ -z "$cxx_gnu_target_os" ]; then
+
+ # Old format: cpu-mf-os
+ #
+ cxx_gnu_target_os=$cxx_gnu_target_kernel
+ cxx_gnu_target_kernel=
+fi
optimization=
@@ -56,6 +76,11 @@ if [ "$2" == "y" ]; then
fi
-echo "cxx_gnu := $cxx_gnu" > $1
-echo "cxx_gnu_libraries := $cxx_gnu_libraries" >> $1
-echo "cxx_gnu_optimization_options := $optimization" >> $1
+echo "cxx_gnu := $cxx_gnu" > $1
+echo "cxx_gnu_libraries := $cxx_gnu_libraries" >> $1
+echo "cxx_gnu_optimization_options := $optimization" >> $1
+echo "cxx_gnu_target := $cxx_gnu_target" >> $1
+echo "cxx_gnu_target_cpu := $cxx_gnu_target_cpu" >> $1
+echo "cxx_gnu_target_mf := $cxx_gnu_target_mf" >> $1
+echo "cxx_gnu_target_kernel := $cxx_gnu_target_kernel" >> $1
+echo "cxx_gnu_target_os := $cxx_gnu_target_os" >> $1
diff --git a/build/cxx/gnu/o-l.make b/build/cxx/gnu/o-l.make
index 9a2e129..e27927c 100644
--- a/build/cxx/gnu/o-l.make
+++ b/build/cxx/gnu/o-l.make
@@ -42,10 +42,14 @@ $(out_base)/%.l.o.clean:
else
+mingw := $(if $(filter $(cxx_gnu_target_os),mingw32 mingw64),y,n)
+
$(out_base)/%.l: ld := $(cxx_gnu)
$(out_base)/%.l: ld_options := $(cxx_gnu_optimization_options) $(cxx_gnu_debugging_options)
+ifeq ($(mingw),n)
$(out_base)/%.l: c_pic_options := -fPIC
$(out_base)/%.l: cxx_pic_options := -fPIC
+endif
$(out_base)/%.l: comma_ := ,
$(out_base)/%.l: expand-l = $(if $(subst n,,$(cxx_rpath)),\
@@ -57,6 +61,9 @@ $(out_base)/%.l:
else
$(out_base)/%.l: | $$(dir $$@).
endif
+ifeq ($(mingw),n)
+# Standard version.
+#
$(call message,ld $@,$(ld) -shared \
$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) \
-o $(@D)/lib$(basename $(@F)).so -Wl$(comma_)-soname=lib$(basename $(@F)).so \
@@ -64,9 +71,24 @@ $(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_lib
$(call message,,echo "$(@D)/lib$(basename $(@F)).so" >$@)
$(call message,,echo "rpath:$(@D)" >>$@)
$(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.so %.l,$^))" | xargs -n 1 echo >>$@)
+else
+# MinGW version.
+#
+ $(call message,ld $@,$(ld) -shared \
+$(cxx_extra_options) $(ld_options) $(cxx_ld_extra_options) \
+-o $(@D)/$(basename $(@F)).dll -Wl$(comma_)--out-implib$(comma_)$(@D)/lib$(basename $(@F)).a \
+$(foreach f,$^,$(if $(patsubst %.l,,$f),$f,$(call expand-l,$f))) $(cxx_extra_libs))
+ $(call message,,echo "$(@D)/lib$(basename $(@F)).a" >$@)
+ $(call message,,echo "rpath:$(@D)" >>$@)
+ $(call message,,echo "$(patsubst %.l,`cat %.l`,$(filter %.a %.l,$^))" | xargs -n 1 echo >>$@)
+endif
$(out_base)/%.l.o.clean:
+ifeq ($(mingw),n)
$(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,lib%.so,$(@F)),$(basename $(basename $@)))
+else
+ $(call message,rm $$1,rm -f $$1 $(@D)/$(patsubst %.l.o.clean,%.dll,$(@F)) $(@D)/$(patsubst %.l.o.clean,lib%.a,$(@F)),$(basename $(basename $@)))
+endif
endif
endif