makefile没有正确导入PATH

时间:2017-04-04 18:26:22

标签: linux makefile build ubuntu-14.04

我有一个简单的Makefile。出于某种原因,我没有正确导入PATH

这是我在终端

中运行echo $PATH时得到的结果

/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/common/petalinux/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/linux-i386/petalinux/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/common/petalinux/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/linux-i386/microblaze-xilinx-elf/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/linux-i386/microblazeel-xilinx-linux-gnu/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/linux-i386/gcc-arm-none-eabi/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/linux-i386/gcc-arm-linux-gnueabi/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/linux-i386/aarch64-none-elf/bin:/home/someuser/myfs/opt/pkg/petalinux-v2016.2-final/tools/linux-i386/aarch64-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

以下是我运行PATH

时获得make的内容

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

有人知道发生了什么吗?

Makefile在下面,这是我的系统描述

uname -a
4.4.0-72-generic #93~14.04.1-Ubuntu SMP Fri Mar 31 15:05:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:    14.04
Codename:   trusty

Makefile

.PHONY: linux bootimage fsbl dts build-dts

all: linux bootimage

dts: build-dts package bootimage

rootfs: build-rootfs package bootimage

fsbl:
    petalinux-build -c bootloader

clean:
    echo $(PATH)
    petalinux-build -x distclean

linux:
    petalinux-build

build-dts:
    petalinux-build -c device-tree

build-rootfs:
    petalinux-build -c rootfs

package:
    petalinux-build -x package

bootimage:
    petalinux-package --boot --force --fsbl ${BOOT_FSBL_IMAGE} --fpga ${BOOT_BIT_IMAGE} --u-boot=${BOOT_UBOOT_IMAGE} -o ${BOOT_IMAGE}

1 个答案:

答案 0 :(得分:0)

  

这是我在运行make

时获得的PATH      

的/ usr / local / sbin中:在/ usr / local / bin中:/ usr / sbin目录:在/ usr / bin中:/ sbin目录:/ bin中:/ SNAP / bin中

这里你的make文件没有程序运行所需的必要路径文件。

在makefile中,最简单的导出方式就是这样。

export PATH := bin:$(PATH)

也许,就像这样。

export PATH := $(shell pwd)/bin:$(PATH)

target:
    mkdir -p ./bin 
    export PATH
    echo $(PATH)

或另一种方法是将所有路径变量添加到你的〜/ .bashrc,它完成后,它显式设置。

您可以使用“:”添加更多路径,在〜/ .bashrc中添加此行

export PATH=$PATH:~/your/bin1:~/your/bin2

示例示例在env路径中追加更多路径:

export PATH=/opt/bin:/usr/local/bin:/usr/contrib/bin:/bin:/usr/bin:/usr/sbin:/usr/bin/X11

Information about export: