Skip to content

Commit

Permalink
unified build scheme: add the tweaks to build on Cygwin & Mingw
Browse files Browse the repository at this point in the history
Cygwin and Mingw name their libraries a bit differently from the rest
of the POSIXly universe, we need to adapt to that.

In Makefile.tmpl, it means that some hunks will only be output
conditionally.

This also means that shared_extension for the Cygwin and Mingw
configurations in Configurations/10-main.conf are changing from .dll.a
to .dll.  Makefile.shared does a fine job without having them
specified, and it's much easier to work with tucking an extra .a at
the end of files in the installation recipes than any amount of name
rewrites, especially with the support of the SHARED_NAME in the top
build.info.

Reviewed-by: Rich Salz <[email protected]>
  • Loading branch information
levitte committed Feb 10, 2016
1 parent 567a9e6 commit fcf80c4
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Configurations/10-main.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@
shared_target => "cygwin-shared",
shared_cflag => "-D_WINDLL -DOPENSSL_USE_APPLINK",
shared_ldflag => "-mno-cygwin",
shared_extension => ".dll.a",
shared_extension => ".dll",
},
"mingw64" => {
# As for OPENSSL_USE_APPLINK. Applink makes it possible to use
Expand All @@ -1199,7 +1199,7 @@
shared_target => "cygwin-shared",
shared_cflag => "-D_WINDLL",
shared_ldflag => "-mno-cygwin",
shared_extension => ".dll.a",
shared_extension => ".dll",
},

#### UEFI
Expand Down Expand Up @@ -1232,7 +1232,7 @@
shared_target => "cygwin-shared",
shared_cflag => "-D_WINDLL",
shared_ldflag => "-shared",
shared_extension => ".dll.a",
shared_extension => ".dll",
},
"Cygwin-x86_64" => {
inherit_from => [ asm("x86_64_asm") ],
Expand All @@ -1247,7 +1247,7 @@
shared_target => "cygwin-shared",
shared_cflag => "-D_WINDLL",
shared_ldflag => "-shared",
shared_extension => ".dll.a",
shared_extension => ".dll",
},
# Backward compatibility for those using this target
"Cygwin" => {
Expand Down
34 changes: 34 additions & 0 deletions Configurations/unix-Makefile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ install_dev:
fn2=`basename $$fn $(SHLIB_EXT)`$(SHLIB_EXT_SIMPLE); \
ln -sf $$fn $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn2; \
fi; \
: {- output_off() unless windowsdll(); "" -}; \
echo "install $$s.a -> $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
cp $$s.a $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new; \
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a.new \
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
: {- output_on() -}; \
done
@ : {- output_on() -}
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
Expand Down Expand Up @@ -263,6 +270,10 @@ uninstall_dev:
fi; \
echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn"; \
$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn; \
: {- output_off() unless windowsdll(); "" -}; \
echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a"; \
$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$fn.a; \
: {- output_on() -}; \
done
@echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc"
@$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
Expand Down Expand Up @@ -297,6 +308,16 @@ install_runtime:
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin
@$(PERL) $(SRCDIR)/util/mkdir-p.pl $(INSTALL_PREFIX)$(OPENSSLDIR)/misc
@echo "*** Installing runtime files"
: {- output_off() unless windowsdll(); "" -};
@set -e; for s in $(SHLIBS); do \
fn=`basename $$i`; \
echo "install $$s -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
cp $$s $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new; \
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn.new \
$(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
done
: {- output_on() -};
@set -e; for x in $(PROGRAMS); do \
fn=`basename $$x`; \
echo "install $$x -> $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
Expand Down Expand Up @@ -346,6 +367,13 @@ uninstall_runtime:
echo "$(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn"; \
$(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/misc/$$fn; \
done
: {- output_off() unless windowsdll(); "" -};
@set -e; for s in $(SHLIBS); do \
fn=`basename $$i`; \
echo "$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn"; \
$(RM) $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$fn; \
done
: {- output_on() -};
$(RM) $(INSTALL_PREFIX)$(OPENSSLDIR)/openssl.cnf

# A method to extract all names from a .pod file
Expand Down Expand Up @@ -667,6 +695,12 @@ $targets : $lib\$(LIB_EXT) $deps $ordinalsfile
CC="\$(CC)" CFLAGS="\$(CFLAGS)" LDFLAGS="\$(LDFLAGS)" \\
SHARED_LDFLAGS="\$(SHARED_LDFLAGS)" SHLIB_EXT=\$(SHLIB_EXT) \\
link_a.$shlib_target
EOF
. (windowsdll() ? <<"EOF" : "");
rm -f apps/$shlib\$(SHLIB_EXT)
rm -f test/$shlib\$(SHLIB_EXT)
cp -p $shlib\$(SHLIB_EXT) apps/
cp -p $shlib\$(SHLIB_EXT) test/
EOF
}
sub obj2dynlib {
Expand Down
17 changes: 17 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,23 @@ do_$(SHLIB_TARGET):
LIBDEPS="$$libs $(EX_LIBS)" \
link_a.$(SHLIB_TARGET); \
libs="-l$$i $$libs"; \
case "$(PLATFORM)" in \
Cygwin*) \
rm -f apps/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
rm -f test/cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll; \
cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll apps/; \
cp cyg$$i-$(SHLIB_MAJOR).$(SHLIB_MINOR).dll test/; \
;; \
mingw*) \
case $$i in \
crypto) i=libeay32;; \
ssl) i=ssleay32;; \
esac; \
rm -f apps/$$i.dll; \
rm -f test/$$i.dll; \
cp $$i.dll apps/; \
cp $$i.dll test/; \
esac; \
done

libcrypto.pc: Makefile
Expand Down
6 changes: 1 addition & 5 deletions Makefile.shared
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,8 @@ link_a.cygwin:
ALLSYMSFLAGS='-Wl,--whole-archive'; \
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
[ -f apps/$$dll_name ] && rm apps/$$dll_name; \
[ -f test/$$dll_name ] && rm test/$$dll_name; \
$(LINK_SO_A) || exit 1; \
rm $$extras; \
cp -p $$dll_name apps/; \
cp -p $$dll_name test/
rm $$extras
link_app.cygwin:
@if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
LIBDEPS="$(SRCDIR)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
Expand Down
8 changes: 8 additions & 0 deletions build.info
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ ORDINALS[libssl]=ssl
INCLUDE[libcrypto]={- rel2abs(catdir($builddir,"include")) -} . crypto/include include
INCLUDE[libssl]={- rel2abs(catdir($builddir,"include")) -} . include
DEPEND[libssl]=libcrypto

IF[{- $config{target} =~ /^Cygwin/ -}]
SHARED_NAME[libcrypto]=cygcrypto-{- $config{shlib_major}.".".$config{shlib_minor} -}
SHARED_NAME[libssl]=cygssl-{- $config{shlib_major}.".".$config{shlib_minor} -}
ELSIF[{- $config{target} =~ /^mingw/ -}]
SHARED_NAME[libcrypto]=libeay32
SHARED_NAME[libssl]=ssleay32
ENDIF

0 comments on commit fcf80c4

Please sign in to comment.