blob: 2202820a2978bd4bb3c6810295680b0822e26896 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
make jobserver integration
==========================
It seems to be possible with both GNU Make and pmake/BSD Make.
GNU Make
--------
Modify command to start with +:
myapp: main.slul
+cslul $(srcdir)/main.slul
NOTE!!! GNU Make 4.4 will change how the jobserver works from a pipe to mkfifo.
pmake/BSD Make
--------------
BSD Make seems to create the file descriptors if the recipe contains $(MAKE)
somewhere (even in arguments to commands). The file descriptors have high
numbers such as 15,16.
myapp: main.slul
cslul --ignore $(MAKE) $(srcdir)/main.slul
Combined solution
-----------------
myapp: main.slul
+cslul $(srcdir) --outdir . --jobserver $(MAKE)
Checking MAKEFLAGS
------------------
Jobserver FD detection:
GNU Make:
--jobserver-auth=3,4
BSD Make:
-J 15,16
Detecting -n option (don't run commands):
GNU Make:
n (first word is n)
BSD Make:
-n (contains option -n)
Fortunately, BSD make does not add the targets in MAKEFLAGS, so
if there is a target called "n", it will not show up.
Additionally, -t might need to be detected (touch targets):
GNU and BSD Make:
-t (contains option -t)
Supporting pthreads
-------------------
Threading (or forking) is necessary to support
parallel compilation of a single module.
Perhaps something like this in the cslul Makefile:
THREADFLAGS = $(THREADS:pthread=-pthread -DENABLE_PTHREAD)
THREADFLAGS = $(THREADS:winapi=-DENABLE_WINAPI_THREADS)
.c.o:
$(CC) ... $(THREADFLAGS) $(CFLAGS)
cslul:
$(CC) ... $(THREADFLAGS) $(CFLAGS)
Then, in the source:
#if defined(ENABLE_PTHREAD)
...
#elif defined(ENABLE_WINAPI_THREADS)
...
#else
...
#endif
Makefile invocation:
make THREADS=pthread cslul
|