forked from brombres/Rogue
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
231 lines (195 loc) · 8.46 KB
/
Makefile
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
.PHONY: test
ROGUEC_SRC = $(shell find Source/RogueC | grep ".rogue$$" )
ROGUEC_ROGUE_FLAGS =
ROGUEC_CPP_FLAGS = -Wall -std=gnu++11 -fno-strict-aliasing -Wno-invalid-offsetof
DEFAULT_CXX = \"$(CXX) $(ROGUEC_CPP_FLAGS)\"
BINDIR = /usr/local/bin
ifeq ($(OS),Windows_NT)
SUDO_CMD =
PLATFORM = Windows
else
SUDO_CMD = sudo
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
PLATFORM = macOS
else
PLATFORM = Linux
endif
endif
all: roguec rogo
-include Local.mk
remake: libraries touch_roguec roguec rogo
debug: libraries
@echo -------------------------------------------------------------------------------
@echo "Recompiling RogueC.rogue -> RogueC.cpp with --debug..."
@echo -------------------------------------------------------------------------------
cd Source/RogueC && mkdir -p Build
rogo version
cd Source/RogueC && roguec RogueC.rogue --gc=manual --main --output=Build/RogueC --debug $(ROGUEC_ROGUE_FLAGS)
mkdir -p Programs
$(CXX) $(ROGUEC_CPP_FLAGS) -DDEFAULT_CXX="$(DEFAULT_CXX)" Source/RogueC/Build/RogueC.cpp -o Programs/RogueC/$(PLATFORM)/roguec
exhaustive: roguec
@echo -------------------------------------------------------------------------------
@echo "Recompiling RogueC.rogue -> RogueC.cpp with --api=* --threads"
@echo -------------------------------------------------------------------------------
cd Source/RogueC && mkdir -p Build
rogo version
cd Source/RogueC && roguec RogueC.rogue --gc=manual --main --output=Build/RogueC --api=* $(ROGUEC_ROGUE_FLAGS) --define=NO_LIBFFI --threads
mkdir -p Programs
$(CXX) $(ROGUEC_CPP_FLAGS) -DDEFAULT_CXX="$(DEFAULT_CXX)" Source/RogueC/Build/RogueC.cpp -o Programs/RogueC/$(PLATFORM)/roguec
roguec: bootstrap_roguec $(BINDIR)/roguec libraries rogo Source/RogueC/Version.rogue Source/RogueC/Build/RogueC.cpp Programs/RogueC/$(PLATFORM)/roguec
rogo: Source/RogueC/Build/Rogo.cpp Programs/RogueC/$(PLATFORM)/rogo $(BINDIR)/rogo
update_bootstrap:
mkdir -p Source/RogueC/Bootstrap
cp Source/RogueC/Build/RogueC.h Source/RogueC/Build/RogueC.cpp Source/RogueC/Bootstrap
touch_roguec:
touch Source/RogueC/RogueC.rogue
bootstrap:
@echo -------------------------------------------------------------------------------
@echo Recompiling Programs/RogueC/$(PLATFORM)/roguec from C++ bootstrap source...
@echo -------------------------------------------------------------------------------
mkdir -p Programs/RogueC/$(PLATFORM);
$(CXX) $(ROGUEC_CPP_FLAGS) -DDEFAULT_CXX="$(DEFAULT_CXX)" Source/RogueC/Bootstrap/RogueC.cpp -o Programs/RogueC/$(PLATFORM)/roguec
touch Source/RogueC/RogueC.rogue
bootstrap_roguec:
@if [ ! -f "Programs/RogueC/$(PLATFORM)/roguec" ]; \
then \
if [ -f "Programs/RogueC/roguec" ]; \
then \
echo "\nRemoving executable from old location Programs/RogueC/roguec"; \
rm -f Programs/RogueC/roguec; \
echo "\nRemoving libraries from old location Programs/RogueC/Libraries"; \
rm -r Programs/RogueC/Libraries; \
fi; \
if [ -f "$(BINDIR)/roguec" ]; \
then \
echo "\nUnlinking old program location by removing $(BINDIR)/roguec"; \
$(SUDO_CMD) rm $(BINDIR)/roguec; \
fi; \
echo -------------------------------------------------------------------------------; \
echo Compiling Programs/RogueC/$(PLATFORM)/roguec from C++ bootstrap source...; \
echo -------------------------------------------------------------------------------; \
echo $(CXX) $(ROGUEC_CPP_FLAGS) -DDEFAULT_CXX="$(DEFAULT_CXX)" Source/RogueC/Bootstrap/RogueC.cpp -o Programs/RogueC/$(PLATFORM)/roguec; \
mkdir -p Programs/RogueC/$(PLATFORM); \
$(CXX) $(ROGUEC_CPP_FLAGS) -DDEFAULT_CXX="$(DEFAULT_CXX)" Source/RogueC/Bootstrap/RogueC.cpp -o Programs/RogueC/$(PLATFORM)/roguec; \
echo touch Source/RogueC/RogueC.rogue; \
touch Source/RogueC/RogueC.rogue; \
fi;
version:
rogo version
Source/RogueC/Version.rogue:
rogo version
Source/RogueC/Build/RogueC.cpp: $(ROGUEC_SRC)
@echo -------------------------------------------------------------------------------
@echo "Recompiling RogueC.rogue -> RogueC.cpp..."
@echo -------------------------------------------------------------------------------
cd Source/RogueC && mkdir -p Build
rogo version
cd Source/RogueC && roguec RogueC.rogue --gc=manual --main --output=Build/RogueC $(ROGUEC_ROGUE_FLAGS)
Source/RogueC/Build/Rogo.cpp: $(ROGUEC_SRC) Source/Tools/Rogo.rogue
@echo -------------------------------------------------------------------------------
@echo "Recompiling Rogo.rogue -> Rogo.cpp..."
@echo -------------------------------------------------------------------------------
mkdir -p Source/RogueC/Build
roguec Source/Tools/Rogo.rogue --gc=manual --main --output=Source/RogueC/Build/Rogo $(ROGUEC_ROGUE_FLAGS)
Programs/RogueC/$(PLATFORM)/roguec: Source/RogueC/Build/RogueC.cpp
@echo -------------------------------------------------------------------------------
@echo "Recompiling RogueC.cpp -> Programs/RogueC/$(PLATFORM)/roguec..."
@echo -------------------------------------------------------------------------------
mkdir -p Programs
$(CXX) $(ROGUEC_CPP_FLAGS) -DDEFAULT_CXX="$(DEFAULT_CXX)" Source/RogueC/Build/RogueC.cpp -o Programs/RogueC/$(PLATFORM)/roguec
Programs/RogueC/$(PLATFORM)/rogo: Source/RogueC/Build/Rogo.cpp
@echo -------------------------------------------------------------------------------
@echo "Compiling Rogo.cpp -> Programs/RogueC/$(PLATFORM)/rogo..."
@echo -------------------------------------------------------------------------------
mkdir -p Programs
$(CXX) -pthread $(ROGUEC_CPP_FLAGS) -DDEFAULT_CXX="$(DEFAULT_CXX)" Source/RogueC/Build/Rogo.cpp -o Programs/RogueC/$(PLATFORM)/rogo
libraries:
@mkdir -p Programs/RogueC/$(PLATFORM)
@if [ -z "$(IGNORE_LIBS)" -a $$(rsync -rtvk --exclude=".*" --exclude=".*/" --delete --exclude=.*.sw? --dry-run Source/Libraries Programs/RogueC/$(PLATFORM) | wc -l) -gt 4 ]; \
then \
echo "==== Updating Libraries ===="; \
rsync -rtvk --delete --exclude=".*" --exclude=".*/" Source/Libraries Programs/RogueC/$(PLATFORM) | tail -n +2 | (tac 2> /dev/null || tail -r) | tail -n +4 | (tac 2> /dev/null || tail -r); \
fi
libs: libraries
if:
echo $(COPY_COUNT)
$(BINDIR)/roguec:
@echo -------------------------------------------------------------------------------
@echo Creating $(BINDIR)/roguec linked to Programs/RogueC/$(PLATFORM)/roguec
@echo -------------------------------------------------------------------------------
printf "%s\nexec \"%s/Programs/RogueC/$(PLATFORM)/roguec\" \"%c@\"\n" '#!/bin/sh' `pwd` '$$' > roguec.script
@echo Copying roguec.script to $(BINDIR)/roguec
$(SUDO_CMD) cp roguec.script $(BINDIR)/roguec; \
$(SUDO_CMD) chmod a+x $(BINDIR)/roguec; \
rm roguec.script
@echo
@echo You can execute the following as a simple test:
@echo
@echo " echo println '\"Hello World!\"' > Hello.rogue"
@echo ' roguec Hello.rogue --execute'
@echo
$(BINDIR)/rogo:
@echo -------------------------------------------------------------------------------
@echo Creating $(BINDIR)/rogo linked to Programs/RogueC/$(PLATFORM)/rogo
@echo -------------------------------------------------------------------------------
printf "%s\nexec \"%s/Programs/RogueC/$(PLATFORM)/rogo\" \"%c@\"\n" '#!/bin/sh' `pwd` '$$' > rogo.script
@echo Copying rogo.script to $(BINDIR)/rogo
$(SUDO_CMD) cp rogo.script $(BINDIR)/rogo; \
$(SUDO_CMD) chmod a+x $(BINDIR)/rogo; \
rm rogo.script
test:
rogo test
x2:
make remake
sleep 1
make remake
x3:
make remake
sleep 1
make remake
sleep 1
make remake
revert: revert_cpp_source libraries bootstrap
revert_cpp_source:
git checkout Source/RogueC/Bootstrap && rm -f Programs/RogueC/$(PLATFORM)/roguec
.PHONY: clean
clean:
rm -rf Programs/RogueC/$(PLATFORM)
rm -rf Source/RogueC/Build
rm -f Hello.cpp
rm -f Hello.h
rm -f ./a.out
rm -f ./hello
unlink:
@if [ -f "$$(which roguec)" ]; \
then \
echo "Unlinking roguec by removing $$(which roguec)'"; \
$(SUDO_CMD) rm -f $$(which roguec); \
$(SUDO_CMD) rm -f $(BINDIR)/roguec; \
else \
if [ -f "$(BINDIR)/roguec" ]; \
then \
echo "Unlinking roguec by removing $(BINDIR)/roguec'"; \
$(SUDO_CMD) rm -f $(BINDIR)/roguec; \
else \
echo "No roguec to unlink" ; \
fi \
fi; \
\
if [ -f "$$(which rogo)" ]; \
then \
echo "Unlinking rogo by removing $$(which rogo)'"; \
$(SUDO_CMD) rm -f $$(which rogo); \
$(SUDO_CMD) rm -f $(BINDIR)/rogo; \
else \
if [ -f "$(BINDIR)/rogo" ]; \
then \
echo "Unlinking rogo by removing $(BINDIR)/rogo'"; \
$(SUDO_CMD) rm -f $(BINDIR)/rogo; \
else \
echo "No rogo to unlink" ; \
fi \
fi
docs:
cd Source/DocGen && make