Unerwartete Wechselwirkung zwischen doppelten Regeln ("::`) und "Include" in MakefilesLinux

Linux verstehen
Anonymous
 Unerwartete Wechselwirkung zwischen doppelten Regeln ("::`) und "Include" in Makefiles

Post by Anonymous »

Untersuchung der Unterschiede zwischen Einzelkolonegeln (

Code: Select all

:
) und doppelkolonische Regeln (

Code: Select all

::
) [/b] In Makefiles habe ich einige verwirrende Verhaltensweisen beobachtet:

Erwartung : Die Include -Richtlinie sollte die Zieldatei erzwingen, die zu generieren ist (unabhängig von den Regeltypen). Fügen Sie ein, aber Einzelkolonegeln funktionierten wie erwartet. (Fehler)
Inhalt von Makefile :

Code: Select all

test0.txt::
touch test0.txt
test.txt::
touch test.txt
include test.txt
Ergebnis :

Code: Select all

xuanyi@Shwan:~/try/playground$ tree
.
└── Makefile

1 directory, 1 file
xuanyi@Shwan:~/try/playground$ head -n 20 Makefile
test0.txt ::
touch test0.txt

test.txt ::
touch test.txt

include test.txt
xuanyi@Shwan:~/try/playground$ make
touch test0.txt
xuanyi@Shwan:~/try/playground$ tree
.
├── Makefile
└── test0.txt

1 directory, 2 files
xuanyi@Shwan:~/try/playground$
Die Frage ist eingeschlossen. /> Inhalt von Makefile < /strong>: < /p>

Code: Select all

test0.txt::
touch test0.txt
test.txt:
touch test.txt
include test.txt
Ergebnis [/b]:

Code: Select all

xuanyi@Shwan:~/try/playground$ tree
.
└── Makefile

1 directory, 1 file
xuanyi@Shwan:~/try/playground$ head -n 20 Makefile
test0.txt ::
touch test0.txt

test.txt :
touch test.txt

include test.txt
xuanyi@Shwan:~/try/playground$ make
touch test.txt
touch test0.txt
xuanyi@Shwan:~/try/playground$ tree
.
├── Makefile
├── test.txt
└── test0.txt

1 directory, 3 files
xuanyi@Shwan:~/try/playground$
< /code>
[b] Schlüsselunterschied < /strong>: < /p>

 Einkolon-Regeln inklusive < /code>, während doppelkolonische Regeln mit leeren Voraussetzungen (Experiment 1) ausfallen. (Erfolg) [/b] 
[b] Inhalt von Makefile [/b]:
test0.txt::
touch test0.txt
test.txt:: invalid_file
touch test.txt
include test.txt
Ergebnis :

Code: Select all

xuanyi@Shwan:~/try/playground$ tree
.
└── Makefile

1 directory, 1 file
xuanyi@Shwan:~/try/playground$ head -n 20 Makefile
test0.txt ::
touch test0.txt

test.txt :: invalid_file
touch test.txt

include test.txt
xuanyi@Shwan:~/try/playground$ touch invalid_file
xuanyi@Shwan:~/try/playground$ tree
.
├── Makefile
└── invalid_file

1 directory, 2 files
xuanyi@Shwan:~/try/playground$ make
touch test.txt
touch test0.txt
xuanyi@Shwan:~/try/playground$ tree
.
├── Makefile
├── invalid_file
├── test.txt
└── test0.txt

1 directory, 4 files
xuanyi@Shwan:~/try/playground$
< /code>

Über meine Umgebung: < /p>
xuanyi@Shwan:~/try/playground$ make --version
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
xuanyi@Shwan:~/try/playground$ hostnamectl
Static hostname: Shwan
Icon name: computer-container
Chassis: container ☐
Machine ID: #####
Boot ID: #####
Virtualization: wsl
Operating System: Ubuntu 24.04.1 LTS
Kernel: Linux 5.15.167.4-microsoft-standard-WSL2
Architecture: x86-64
Ich bin verwirrt über das Ergebnis, dass doppelkolonische Regeln durch include nur dann ausgelöst werden, wenn Voraussetzungen vorhanden sind, aber mit leeren Voraussetzungen fehlschlagen (Experiment 1). Warum stehen doppelkolonische Regeln mit leeren Voraussetzungen in Konflikte in die Prioritätslogik von ? Machen Sie die Anwendung impliziten Bedingungen für doppelkolonische Regeln?
Lassen Sie mich wissen, ob weitere Anpassungen erforderlich sind.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post