make(windows)调用sub-nmake的意外行为

时间:2015-02-03 16:47:03

标签: makefile nmake multiple-makefiles

制作一个makefile来为windows构建openssl,并且遇到让我困惑的事情。我想通过一次调用构建它,为构建提供平台。有一个父makefile调用sub-make,根据平台设置了一些参数(linux,win32,win64,win64debug等)。

windows的子makefile部分如下所示:

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

顶部设置了许多变量,并且所有变量都可以正常工作。我在这里有两个问题:

  1. 在winbuild目标中,我收到有关未找到env的投诉,但是,除非我使用该env命令,否则nmake将无法运行。不可思议?

  2. 这是让我困惑的一个。 nmake行似乎在后台运行。我这样说是因为,我在输出中找到了copy命令,后面紧跟tar + gzip命令...而编译刚刚开始。在构建完成之前大约10分钟创建的结果tarball只包含安装文件夹的目录结构,以及引用的两个文件。

  3. 如何同步完成此过程,而无需单独构建和定位?

    编辑:更新了上面的示例makefile。

    致电:

    make -f openssl.mf win64
    

    其中openssl.mf包含:

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

    它继续在后台调用nmake,然后继续tar一个相当空的目录。根本不是我想要完成的事情。我希望make过程坐下来等待nmake返回......这可能吗?

    错误输出:

    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
    

    你可以看到,在winbuild完成之前,winPkg的tar命令已经发布到底部。

0 个答案:

没有答案