当前位置:  开发笔记 > 编程语言 > 正文

从Unix迁移到Linux时,Makefile包含指令

如何解决《从Unix迁移到Linux时,Makefile包含指令》经验,为你挑选了0个好方法。

我的任务是迁移一个古老的基于C++的代码,从Unix环境到Linux.该项目由多个Makefile组成,用于库的不同"模块".我已经解决了一些问题,但现在遇到了include指令的问题.

显然,Makefiles的构造方式是为不同的文件提供单独的 include指令,并且它在Unix服务器中工作了多年.

例如:

include ../../../../util/genmake.def

processControl.slOBJS = processControl.o
outputControlOBJS = outputControl.o
inputControlOBJS = inputControl.o
cleanList  = *.o *.C *.out processControl.sl outputControl inputControl

all: processControl.sl  outputControl inputControl

processControl.sl: $(processControl.slOBJS)
        include ../../../../util/genmake.slinc

outputControl: $(outputControlOBJS)
        include ../../../../util/genmake.exeinc

inputControl: $(inputControlOBJS)
        include ../../../../util/genmake.exeinc

include ../../../../util/genmake.inc

你可以在这里看到,tabbed包含,只能引用指定的目标!它们是该目标的配方的一部分.

但是,这个构造在Linux中不起作用,我收到此错误:

include ../../../../util/genmake.slinc
make: include: Command not found
make: *** [processControl.sl] Error 127

显然,我不能只删除标签,因为包含应仅适用于该目标...

所以,我试图用shell'source'命令替换它来源包含的文件,如:

        source ../../../../util/genmake.slinc

这显然不起作用,我也尝试将包含的代码直接引入include文件(注释掉include命令) - 这会处理与Makefile相关的错误,但这不是一个好的解决方案,因为它真的很难迁移和维护它,不得不将整个项目中的相同代码复制到所有模块中,然后当然每一个微小的变化都要反映在所有文件上.

任何Make专家可以就此问题提出建议吗?此外,一般来说,欢迎任何有关如何最好地处理此迁移任务的建议:)

谢谢!

编辑 - 额外信息:genmake.slinc的内容:


#######################################################################
## This include will inherit the target and dependent files in
## a make file that inlcudes it.
## The inclusion of this file should look like:
##
## {target}: {dependent file list}
## include genmake.slinc
##
#######################################################################
        @echo "----------------------------------------------------------------"
        @echo " (G) Creating shared library $@ from $($(MaKeObJs:x=$(@)OBJS))";
        @echo "----------------------------------------------------------------"
        @echo "$(CPP) -b -o $@ $($(MaKeObJs:x=$(@)OBJS))"
        @$(CPP) -b -o $@ $($(MaKeObJs:x=$(@)OBJS))
        @echo " Moving shared library to $(SHLIBINSTALL) as lib$(@)"
        @$(MV) $@ $(SHLIBINSTALL)/lib$(@)
        @echo "----------------------------------------------------------------"

那些是@之前的标签.

现在genmake.exeinc的内容:


#######################################################################
## This include will inherit the target and dependent files in
## a make file that inlcudes it.
## The inclusion of this file should look like:
##
## {target}: {dependent file list}
## include /opt/app/fba/util/genmake.exeinc
##
#######################################################################
        @cp $(SHLIBINSTALL)/* $(TEMP_SHLIB_DIR)/.
        @echo "----------------------------------------------------------------"
        @echo " (G) Linking $($(MaKeObJs:x=$(@)OBJS)) to make $@ "
        @echo "     LDOPTS set to: $(LDOPTS)"
#       @echo "  $(PURIFY) $(LD) "
        @echo "  SHLIB Temp Path: $(TEMP_SHLIB_DIR)
        @echo "     FBA libraries: $(FBALIB)"
        @echo "     Application libraries: $(APPLIBS)"
        $(PURIFY) $(LD) -o $@ $($(MaKeObJs:x=$(@)OBJS)) \
                $(CXXOPTS) \
                $(LDFLAGS) \
                $(FBALIB) \
                $(PROLDLIBS) \
                `cat /usr/local/opt/oracle/product/t1c3d771/lib/ldflags`  \
                `cat /usr/local/opt/oracle/product/t1c3d771/lib/sysliblist` \
                $(APPLIBS)
        @echo " Moving executable to $(EXEINSTALL) "
        @$(MV) $@ $(EXEINSTALL)
        @echo "----------------------------------------------------------------"

如果我转到Makefile,并删除包含的主要标签,我会收到此错误:../../../../ util/genmake.slinc:10:***命令在第一个目标之前开始.停止.

推荐阅读
个性2402852463
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有