linux - C++ 生成文件安装 : start program at boot and reboot

标签 linux makefile startup

我无法理解 C++ 联编文件。 makefile 使程序能够在重新启动时启动。我想要的是它在启动和重新启动时启用程序启动。我还想添加主机名(因为这是程序需要的参数)。

我尝试了什么:

  • 将 $(shell 主机名) 添加到 PROGN
  • 将 $(shell hostname) 添加到行:cp/etc/... in @test -s reboot

但是因为我无法理解这些行,所以它只是猜测..

安装部分makefile:

PROGN=myProgram

setup:
@install -m 755 -d \
    $(DESTDIR)/usr/bin \
    $(DESTDIR)/etc/$(PROGN)/samples \
    $(DESTDIR)/etc/udev/rules.d
@cp bin/$(PROGN) $(DESTDIR)/usr/bin
@cp sample_profiles/* $(DESTDIR)/etc/$(PROGN)/samples
@cp udev/$(PROGN).rules $(DESTDIR)/etc/udev/rules.d
@test -s /usr/bin/systemd-run && \
    install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system && \
    cp systemd/$(PROGN)-reboot.service $(DESTDIR)$(SYSTEMDDIR)/system

install: setup
@test -s /etc/$(PROGN)/profile || \
    cp /etc/$(PROGN)/samples/group_keys /etc/$(PROGN)/profile
@test -s /etc/$(PROGN)/reboot || \
    cp /etc/$(PROGN)/samples/all_off /etc/$(PROGN)/reboot
@udevadm control --reload-rules
@test -s /usr/bin/systemd-run && \
    systemctl daemon-reload && \
    systemctl enable $(PROGN)-reboot

最佳答案

我通过删除最后的@test 部分并调用 rc.local 文件 (raspbian jessie lite) 中的脚本,“解决”了启动自动引导的问题。我删除 makefile 的最后一部分的原因是因为当我进行安装时,它会启动程序以设置默认设置,但我在代码中删除了该部分并且安装卡住。

关于linux - C++ 生成文件安装 : start program at boot and reboot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43779212/

相关文章:

docker - 使用 Google Cloud Build,我如何运行 Makefile 来执行 docker 和 kubectl 命令?

angularjs - 加载 Angular 模块时如何异步加载数据?

Cortex m3第一条指令执行

java - 每个 Spring Web 应用程序仅加载一次图像

linux - 如何同时接受 TCP 连接 <ip :port> in many threads?

MySQL数据库-备份数据库时出错

c - 带有 c 型类型转换的 GCC 警告

找不到 linux/modversions.h

linux - 当我使用特殊字符时,为什么 tr 给我双字符?

c - 简单的 Makefile : undefined reference to symbol 'cos@@GLIBC_2.2.5' 问题