0

Fashioning a makefile to build openssl for windows and am running into something that has me puzzled. I want to just have it built with one call to make, supplying the platform to build. There is a parent makefile which calls a sub-make having set a few parameters based on the platform (linux, win32, win64, win64debug, etc).

The sub-makefile section for windows reads as follows:

winConfig: patch.tmp
    cd $(BUILD_HOME)/openssl-$(VERSION) ; \
    $(CHMOD) -R 777 * ; \
    perl Configure $(PERL_CFG_TARGET) $(CFG_BASEOPTS) ; \
    [ $(CFG_BITS) = 32 ] && ms/do_ms.bat ; \
    [ $(CFG_BITS) = 64 ] && ms/do_win64a.bat
    $(TOUCH) cfg-win$(CFG_BITS)$(CFG_DEBUG).tmp cfg.tmp
    $(TOUCH) winConfig

winBuild: winConfig remakeDirs
    cd $(BUILD_HOME)/openssl-$(VERSION) ; \
    env -u MAKE -u MAKEFLAGS nmake -f ms/nt.mak install ; \
    $(CP) crypto/ec/ec_lcl.h crypto/ecdsa/ecs_locl.h $(OPENSSL_INSTALL_DIR)/include/openssl/
    $(TOUCH) winBuild

winPkg: winConfig winBuild
    $(RM) $(TARGET_HOME)/$(OPENSSL_TARBALL)
    $(TAR) -C $(OPENSSL_INSTALL_BASE) -cf $(TARGET_HOME)/$(OPENSSL_TARBALL) $(OPENSSL_INSTALL_TARGET)
    $(GZIP) -f $(TARGET_HOME)/$(OPENSSL_TARBALL)
    $(RM) $(OPENSSL_INSTALL_DIR)
    $(TOUCH) winPkg

## build and install for Windows:
all-win: winPkg

A number of variables are set up top and that all appears to work fine. There are two issues I have here:

  1. In the winbuild target, I get complaints about env not being found, however, nmake will not run unless I preceed it with that env command. Weird?

  2. This is the one that really has me puzzled. The nmake lines appear to be run in the background. I say that because, I find in the output, the copy command, quickly followed by the tar + gzip commands... while the compile has just gotten underway. The resulting tarball, created approx 10min before the build completes, has only the directory structure of the install folder, plus the two files referenced.

How can I have this process completed synchronously without having to resort to building and tarring separately?

EDIT: Updated sample makefile above.

Calling via:

make -f openssl.mf win64

where openssl.mf contains:

win64:
    make -j 1 -f openssl-sub.mf all-win CC=cl  CXX=cl  OUTPATH=out64  CFG_TARGET=VC-WIN64A 

It continues to call the nmake in the background, then proceed to tar up a fairly empty directory. Not at all what I want to accomplish. I would like the make process sit and wait until nmake returns... is that possible?

Errored output:

cd L:/dev/openssl/openssl-build/openssl-1.0.1l ; \
        env -u MAKE -u MAKEFLAGS nmake -f ms/nt.mak install ; \
        L:/wintools/cygwin/cp -f crypto/ec/ec_lcl.h crypto/ecdsa/ecs_locl.h L:/dev/openssl/openssl-install/win64-x86/include/openssl/

Microsoft (R) Program Maintenance Utility Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

Building OpenSSL
        perl util/mkdir-p.pl "tmp32"
created directory `tmp32'
        perl util/mkdir-p.pl "out32"
created directory `out32'
        perl util/mkdir-p.pl "inc32"
created directory `inc32'
        perl util/mkdir-p.pl "inc32\openssl"
L:/wintools/cygwin/touch winBuild
created directory `inc32/openssl'
        perl util/copy.pl ".\.\e_os.h" "tmp32\e_os.h"
Copying: ././e_os.h to tmp32/e_os.h
        perl util/copy.pl ".\crypto\cryptlib.h" "tmp32\cryptlib.h"
Copying: ./crypto/cryptlib.h to tmp32/cryptlib.h
        perl util/copy.pl ".\crypto\buildinf.h" "tmp32\buildinf.h"
Copying: ./crypto/buildinf.h to tmp32/buildinf.h
        perl util/copy.pl ".\crypto\md32_common.h" "tmp32\md32_common.h"
Copying: ./crypto/md32_common.h to tmp32/md32_common.h
        perl util/copy.pl ".\crypto\o_time.h" "tmp32\o_time.h"

Copying: ./crypto/o_time.h to tmp32/o_time.h
L:/wintools/rm -rf /dev/openssl/packages/win64-x86-openssl-1.0.1l.tar
        perl util/copy.pl ".\crypto\o_str.h" "tmp32\o_str.h"
L:/wintools/Gow/bin/tar.exe -C L:/dev/openssl/openssl-install -cf /dev/openssl/packages/win64-x86-openssl-1.0.1l.tar win64-x86
Copying: ./crypto/o_str.h to tmp32/o_str.h
        perl util/copy.pl ".\crypto\o_dir.h" "tmp32\o_dir.h"
Copying: ./crypto/o_dir.h to tmp32/o_dir.h
        perl util/copy.pl ".\crypto\constant_time_locl.h" "tmp32\constant_time_locl.h"
Copying: ./crypto/constant_time_locl.h to tmp32/constant_time_locl.h
        perl util/copy.pl ".\crypto\md4\md4_locl.h" "tmp32\md4_locl.h"
L:/wintools/cygwin/gzip -f /dev/openssl/packages/win64-x86-openssl-1.0.1l.tar
Copying: ./crypto/md4/md4_locl.h to tmp32/md4_locl.h
        perl util/copy.pl ".\crypto\md5\md5_locl.h" "tmp32\md5_locl.h"
Copying: ./crypto/md5/md5_locl.h to tmp32/md5_locl.h
        perl util/copy.pl ".\crypto\sha\sha_locl.h" "tmp32\sha_locl.h"
gzip: /dev/openssl/packages/win64-x86-openssl-1.0.1l.tar: No such file or directory
make[1]: *** [winPkg] Error 1
make[1]: Leaving directory `L:/dev/openssl'
make: *** [win64] Error 2

You can see, nr the bottom, where the tar command from winPkg has been issued prior to winbuild having completed.

Jon
  • 1,675
  • 26
  • 57
  • What errors are you getting about `env` exactly? What happens if you try to run `nmake` without using `env` there? – Etan Reisner Feb 03 '15 at 17:02
  • How are you running the toplevel `make` command? Are you using `-j` at all? Why do your targets not list each other as prerequisites if they depend on the others being finished first to operate correctly? – Etan Reisner Feb 03 '15 at 17:03
  • Hi Etan, I've edited the original question. Note that the error about 'env' not being found has gone away... I have no idea why. – Jon Feb 04 '15 at 20:07
  • I don't know that I would necessarily trust output ordering. Can you stick `echo "tar $(date)"` (etc. or similar) commands before tar and before nmake and see what they output? – Etan Reisner Feb 04 '15 at 21:54
  • But.... aren't the commands supposed to be executed in order, like a shell script, and one target complete before the other commences? – Jon Feb 05 '15 at 14:41
  • Yes. they should be. I'm saying I don't always trust output ordering to indicate process running order. There may be other things going on messing with output. That's what the date commands are to test. I'm actually more interested in why `gzip` even runs if `tar` is failing. That recipe should be bailing when tar fails. – Etan Reisner Feb 05 '15 at 15:00
  • Well, I just get "process_begin: CreateProcess(NULL, date, ...) failed." This might stem from the fact that a file included sets the shell to the cygwin bash.exe. I tried setting shell back to sh.exe, but, not only was I not able to locate an sh.exe, but it didn't work anyway. – Jon Feb 05 '15 at 15:22
  • You may not have a `date` binary. You might need to use something else there instead (though what I don't know offhand). – Etan Reisner Feb 05 '15 at 15:28

0 Answers0