summary refs log tree commit diff stats
path: root/compiler/nim.cfg
Commit message (Expand)AuthorAgeFilesLines
* [backport] use old style hints in .cfg files (#18917)Miran2021-09-291-2/+2
* strict effects (#18777)Andreas Rumpf2021-09-021-0/+5
* rename nimFpRoundtrips => nimPreviewFloatRoundtrip (#18566)Timothee Cour2021-07-231-1/+1
* make -d:nimFpRoundtrips work consistently in vm vs rt, fix #18400, etc (#18531)Timothee Cour2021-07-201-0/+1
* change `--hint[X] => --hint:X` in nim repo (avoids shell quoting issues) (#18...Timothee Cour2021-05-261-2/+2
* IC: bugfixes (WIP) (#16836)Andreas Rumpf2021-02-021-3/+1
* remove nim.cfg file change lefover [backport:1.2] (#15469)Andreas Rumpf2020-10-021-6/+0
* closureiters: fixes #15243 (#15454) [backport:1.2]Andreas Rumpf2020-10-021-0/+7
* init checks and 'out' parameters (#14521)Andreas Rumpf2020-06-231-0/+4
* Only print the link command when listCmd is active; fix docs (#13603)Clyybber2020-03-071-1/+0
* make case-object transitions explicit, make unknownLineInfo a const, replace ...Jasper Jenkins2020-01-171-5/+0
* more arc features (#13098)Andreas Rumpf2020-01-101-0/+1
* ic: update to serialize paddingAtEndAraq2019-09-051-1/+1
* disable IC and the SQLite dependency for version 1Andreas Rumpf2019-09-031-0/+2
* makes devel green againAndreas Rumpf2019-07-141-1/+3
* makes --styleCheck:error the default for the Nim compiler itselfAraq2019-07-141-0/+2
* disable the new CaseTransition warning for the Nim compiler itselfAraq2019-06-031-0/+4
* fixes #1286; object case transitions are now soundAndreas Rumpf2019-05-271-0/+1
* compiler/nim.cfg: cleanup --pathAraq2018-09-211-2/+0
* disable -d:nimIncremental for develAraq2018-06-111-1/+1
* incremental compilation subsystem compiles againAndreas Rumpf2018-05-301-0/+1
* compiler API: final cleanups; improve security by diabling 'gorge' and friendsAndreas Rumpf2018-05-291-1/+1
* Remove docgen.nim's dependency on things being in pathSamadi van Koten2016-11-281-2/+0
* changed the compiler's path handling; fixes #546Andreas Rumpf2016-05-311-1/+1
* preparations for Nimble NimScript integrations; minor cleanupsAraq2015-08-181-1/+0
* Rename compiler configuration file to fix "nim check" within the repoZahary Karadjov2015-08-031-0/+21
class='alt'>
fe9ac5f7 ^
6087f759 ^
ab203acf ^
c4a75720 ^
b0a511f9 ^
828716e7 ^
fe9ac5f7 ^
080493c0 ^

c4a75720 ^
6e988941 ^
4393412d ^
2dec7483 ^
5c24b64f ^



a371d736 ^
5c24b64f ^


3aa8f1e0 ^
5c24b64f ^
fe9ac5f7 ^
53bc4753 ^
38db6ab5 ^

4a216fe8 ^
fe9ac5f7 ^




bf721f2e ^
c9337674 ^
d4409bae ^
c9337674 ^
d4409bae ^






b630db7f ^
d4409bae ^


c9337674 ^
cfc6bb4c ^
d29105fa ^
8c99938d ^
6087f759 ^
5c24b64f ^
828716e7 ^
5c24b64f ^
d34e5534 ^
b630db7f ^
828716e7 ^

d34e5534 ^
6087f759 ^
b630db7f ^
5c24b64f ^

8c99938d ^
9f453ca3 ^
cfc6bb4c ^
080493c0 ^
8c99938d ^
b630db7f ^
b773f053 ^
2234d19a ^
fcd9aa9f ^
e8888624 ^
828716e7 ^
a6166c4d ^
b630db7f ^
ae7cc86b ^
b630db7f ^
b2f70da5 ^

1df10adf ^
b630db7f ^
ae7cc86b ^
2234d19a ^
bf761bcb ^
b630db7f ^
7f66b5eb ^
b630db7f ^

7f66b5eb ^
b630db7f ^
b0547ba9 ^
b630db7f ^

b0547ba9 ^
b630db7f ^
b0547ba9 ^
b630db7f ^

b0547ba9 ^
4393412d ^
a371d736 ^
4393412d ^
fad4fb18 ^
4a216fe8 ^
04cbc981 ^
a2d276c7 ^
601ad988 ^
a2d276c7 ^

4a216fe8 ^

3b264751 ^
a371d736 ^
4a216fe8 ^
ed2eb754 ^



b630db7f ^

f7392630 ^

601ad988 ^
b630db7f ^
dacba5fd ^

b630db7f ^

c4a75720 ^
b0a511f9 ^
828716e7 ^
c4a75720 ^
435882f1 ^
6b0b7ccf ^
29441535 ^
4a216fe8 ^
48b19713 ^
fe9ac5f7 ^
4c646872 ^
48b19713 ^
4393412d ^


b630db7f ^
4393412d ^


a371d736 ^
d9ab24c2 ^
b630db7f ^
d9ab24c2 ^
b630db7f ^
24e6e40f ^
6b0b7ccf ^
24e6e40f ^
4a216fe8 ^
fe9ac5f7 ^
4c646872 ^
b630db7f ^
c4a75720 ^




350e0e0a ^
4c646872 ^
6087f759 ^
c4a75720 ^
53bc4753 ^
b630db7f ^
cd966a87 ^

53bc4753 ^
b630db7f ^

6b0b7ccf ^



e3d9ee2c ^
4bf895db ^




a371d736 ^
4bf895db ^
cd966a87 ^
4bf895db ^
a371d736 ^
4bf895db ^
cd966a87 ^
4bf895db ^
a371d736 ^
4bf895db ^


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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

                

                
                                    




                                








                                                                            
                                                        
    
                                 
     
 




                                                
                                       
 




                                                                                
                    
                      
                                   
                             
                                   





                                     






                                                   
           
                                                                    
                                                             
                                                                
                                                          
                                                                             
                                        
                                                         

                                                                                
                                                                                
                                                             
                                                
 



                                        
                                      


       
                                                                     
                                                          
                                 
                                                                                   

                                                                      
 




                                                                           
                                                               
                                                                 
                                                      
 






                                                                      
                                                                            


                                                                         
 
                                                                 
                                                       
                                                                  
                                                
                                             
 
                                
                                                            
                                                       

                                 
                                         
                                     
                                                                      

                                                                        
                                                                              
                                                                        
                                                                                  
                                                                                         
                                         
                                   
                             
                                        
                                                                                       
                                    
                                                                
 
                                           
                                     
                                                                                           

                                                                                           
 
                                       
                                     
                                            
 
                                      
                                     

                                                                                           
 
                                         
                                     

                                                                                           
 
                                        
                                     

                                                                                           
 
                                                  
                                                        
 
                                              
                                 
                               
 
                                   

                                             

             
                                    
                                            
 



                          

                                                                        

                                                                            
 
                                    

               

                            
                                                                            
                                
                                                                
                 
 
               
        
                                          
                                                                   
                                                                      
                          
                                             


                                                                             
                                          


                                                                        
                                                         
                                          
                                                                                         
                                          
                                                                                         
 
                 
          
                                           
                                              
                          
                                                                              




                                                 
                                              
                                               
                                                   
                                                     
                                                  
                                                                                

                                         
                                          

                                                                           



                                   
 




                                
                                         
 
                   
            
                                                 
 
                
                      
                              


                                  
NIM ?= nim
NIMC ?= $(NIM) c
OBJDIR ?= .obj
OUTDIR ?= target
# These paths are quoted in recipes.
PREFIX ?= /usr/local
MANPREFIX ?= $(PREFIX)/share/man
MANPREFIX1 ?= $(MANPREFIX)/man1
MANPREFIX5 ?= $(MANPREFIX)/man5
TARGET ?= release
# This must be single-quoted, because it is not a real shell substitution.
# The default setting is at {the binary's path}/../libexec/chawan.
# You may override it with any path if your system does not have a libexec
# directory, but make sure to surround it with quotes if it contains spaces.
# (This way, the cha binary can be directly executed without installation.)
LIBEXECDIR ?= '$${%CHA_BIN_DIR}/../libexec/chawan'
# If overridden, take libexecdir that was specified.
# Otherwise, just install to libexec/chawan.
ifeq ($(LIBEXECDIR),'$${%CHA_BIN_DIR}/../libexec/chawan')
LIBEXECDIR_CHAWAN = "$(DESTDIR)$(PREFIX)/libexec/chawan"
else
LIBEXECDIR_CHAWAN = $(LIBEXECDIR)
endif

# These paths are quoted in recipes.
OUTDIR_TARGET = $(OUTDIR)/$(TARGET)
OUTDIR_BIN = $(OUTDIR_TARGET)/bin
OUTDIR_LIBEXEC = $(OUTDIR_TARGET)/libexec/chawan
OUTDIR_CGI_BIN = $(OUTDIR_LIBEXEC)/cgi-bin
OUTDIR_MAN = $(OUTDIR_TARGET)/share/man

# I won't take this from the environment for obvious reasons. Please override it
# in the make command if you must, or (preferably) fix your environment so it's
# not needed.
DANGER_DISABLE_SANDBOX = 0

# Nim compiler flags
ifeq ($(TARGET),debug)
FLAGS += -d:debug --debugger:native
else ifeq ($(TARGET),release)
FLAGS += -d:release -d:strip -d:lto
else ifeq ($(TARGET),release0)
FLAGS += -d:release --stacktrace:on
else ifeq ($(TARGET),release1)
FLAGS += -d:release --debugger:native
endif

ifneq ($(CFLAGS),)
FLAGS += $(foreach flag,$(CFLAGS),--passc:$(flag))
endif
ifneq ($(LDFLAGS),)
FLAGS += $(foreach flag,$(LDFLAGS),--passl:$(flag))
endif

.PHONY: all
all: $(OUTDIR_BIN)/cha $(OUTDIR_BIN)/mancha $(OUTDIR_CGI_BIN)/http \
	$(OUTDIR_CGI_BIN)/gemini $(OUTDIR_LIBEXEC)/gmi2html \
	$(OUTDIR_CGI_BIN)/gopher $(OUTDIR_LIBEXEC)/gopher2html \
	$(OUTDIR_CGI_BIN)/finger $(OUTDIR_CGI_BIN)/about \
	$(OUTDIR_CGI_BIN)/file $(OUTDIR_CGI_BIN)/ftp $(OUTDIR_CGI_BIN)/sftp \
	$(OUTDIR_LIBEXEC)/dirlist2html \
	$(OUTDIR_CGI_BIN)/man $(OUTDIR_CGI_BIN)/spartan \
	$(OUTDIR_CGI_BIN)/stbi $(OUTDIR_CGI_BIN)/jebp $(OUTDIR_CGI_BIN)/canvas \
	$(OUTDIR_CGI_BIN)/sixel $(OUTDIR_CGI_BIN)/resize \
	$(OUTDIR_LIBEXEC)/urldec $(OUTDIR_LIBEXEC)/urlenc $(OUTDIR_LIBEXEC)/nc \
	$(OUTDIR_LIBEXEC)/md2html $(OUTDIR_LIBEXEC)/ansi2html
	ln -sf "$(OUTDIR)/$(TARGET)/bin/cha" cha

ifeq ($(shell uname), Linux)
chaseccomp = lib/chaseccomp/chaseccomp.o

lib/chaseccomp/chaseccomp.o: .FORCE
	(cd lib/chaseccomp && $(MAKE))
.FORCE:
endif

$(OUTDIR_BIN)/cha: src/*.nim src/**/*.nim src/**/*.c res/* res/**/* \
		$(chaseccomp) res/map/idna_gen.nim nim.cfg
	@mkdir -p "$(OUTDIR_BIN)"
	$(NIMC) --nimcache:"$(OBJDIR)/$(TARGET)/cha" -d:libexecPath=$(LIBEXECDIR) \
                -d:disableSandbox=$(DANGER_DISABLE_SANDBOX) $(FLAGS) \
		-o:"$(OUTDIR_BIN)/cha" src/main.nim

$(OUTDIR_BIN)/mancha: adapter/tools/mancha.nim
	@mkdir -p "$(OUTDIR_BIN)"
	$(NIMC) --nimcache:"$(OBJDIR)/$(TARGET)/mancha" $(FLAGS) \
		-o:"$(OUTDIR_BIN)/mancha" $(FLAGS) adapter/tools/mancha.nim

$(OBJDIR)/genidna: res/genidna.nim res/map/IdnaMappingTable.txt
	$(NIMC) --nimcache:"$(OBJDIR)/idna_gen_cache" -d:danger \
		-o:"$(OBJDIR)/genidna" res/genidna.nim

res/map/idna_gen.nim: $(OBJDIR)/genidna
	$(OBJDIR)/genidna > res/map/idna_gen.nim

$(OBJDIR)/gencharwidth: res/gencharwidth.nim
	$(NIMC) --nimcache:"$(OBJDIR)/charwidth_gen_cache" -d:danger \
		-o:"$(OBJDIR)/gencharwidth" res/gencharwidth.nim

res/map/charwidth_gen.nim: $(OBJDIR)/gencharwidth res/map/EastAsianWidth.txt
	$(OBJDIR)/gencharwidth > res/map/charwidth_gen.nim

src/utils/strwidth.nim: res/map/charwidth_gen.nim src/utils/proptable.nim

twtstr = src/utils/twtstr.nim src/utils/map.nim src/types/opt.nim
dynstream = src/io/dynstream.nim src/io/dynstream_aux.c
lcgi = $(dynstream) $(twtstr) $(sandbox) adapter/protocol/lcgi.nim
lcgi_ssl = $(lcgi) adapter/protocol/lcgi_ssl.nim
sandbox = src/utils/sandbox.nim $(chaseccomp)

$(OUTDIR_CGI_BIN)/man: $(twtstr)
$(OUTDIR_CGI_BIN)/http: adapter/protocol/curl.nim $(sandbox)
$(OUTDIR_CGI_BIN)/about: res/chawan.html res/license.md
$(OUTDIR_CGI_BIN)/file: $(twtstr)
$(OUTDIR_CGI_BIN)/ftp: $(lcgi)
$(OUTDIR_CGI_BIN)/sftp: $(lcgi) $(twtstr)
$(OUTDIR_CGI_BIN)/gemini: $(lcgi_ssl)
$(OUTDIR_CGI_BIN)/stbi: adapter/img/stbi.nim adapter/img/stb_image.c \
		adapter/img/stb_image.h $(sandbox) $(dynstream)
$(OUTDIR_CGI_BIN)/jebp: adapter/img/jebp.c adapter/img/jebp.h $(sandbox)
$(OUTDIR_CGI_BIN)/sixel: src/types/color.nim $(sandbox) $(twtstr) $(dynstream)
$(OUTDIR_CGI_BIN)/canvas: src/types/canvastypes.nim src/types/path.nim \
	src/io/bufreader.nim src/types/color.nim $(sandbox) $(dynstream) $(twtstr)
$(OUTDIR_CGI_BIN)/resize: adapter/img/stb_image_resize.h adapter/img/stb_image_resize.c \
	$(sandbox) $(dynstream) $(twtstr)
$(OUTDIR_LIBEXEC)/urlenc: $(twtstr)
$(OUTDIR_LIBEXEC)/nc: $(lcgi)
$(OUTDIR_LIBEXEC)/gopher2html: $(twtstr)
$(OUTDIR_LIBEXEC)/ansi2html: src/types/color.nim src/io/poll.nim $(twtstr) $(dynstream)
$(OUTDIR_LIBEXEC)/md2html: $(twtstr)
$(OUTDIR_LIBEXEC)/dirlist2html: $(twtstr) src/utils/strwidth.nim

$(OUTDIR_CGI_BIN)/%: adapter/protocol/%.nim
	@mkdir -p "$(OUTDIR_CGI_BIN)"
	$(NIMC) $(FLAGS) --nimcache:"$(OBJDIR)/$(TARGET)/$(subst $(OUTDIR_CGI_BIN)/,,$@)" \
		-d:disableSandbox=$(DANGER_DISABLE_SANDBOX) -d:curlLibName=$(CURLLIBNAME) \
		-o:"$@" $<

$(OUTDIR_CGI_BIN)/%: adapter/protocol/%
	@mkdir -p "$(OUTDIR_CGI_BIN)"
	install -m755 $< "$(OUTDIR_CGI_BIN)"

$(OUTDIR_CGI_BIN)/%: adapter/img/%.nim
	@mkdir -p "$(OUTDIR_CGI_BIN)"
	$(NIMC) $(FLAGS) --nimcache:"$(OBJDIR)/$(TARGET)/$(subst $(OUTDIR_CGI_BIN)/,,$@)" \
                -d:disableSandbox=$(DANGER_DISABLE_SANDBOX) -o:"$@" $<

$(OUTDIR_LIBEXEC)/%: adapter/format/%.nim
	@mkdir -p "$(OUTDIR_LIBEXEC)"
	$(NIMC) $(FLAGS) --nimcache:"$(OBJDIR)/$(TARGET)/$(subst $(OUTDIR_LIBEXEC)/,,$@)" \
		-o:"$@" $<

$(OUTDIR_LIBEXEC)/%: adapter/tools/%.nim
	@mkdir -p "$(OUTDIR_LIBEXEC)"
	$(NIMC) $(FLAGS) --nimcache:"$(OBJDIR)/$(TARGET)/$(subst $(OUTDIR_LIBEXEC)/,,$@)" \
		-o:"$@" $<

$(OUTDIR_LIBEXEC)/urldec: $(OUTDIR_LIBEXEC)/urlenc
	(cd "$(OUTDIR_LIBEXEC)" && ln -sf urlenc urldec)

$(OBJDIR)/man/cha-%.md: doc/%.md md2manpreproc
	@mkdir -p "$(OBJDIR)/man"
	./md2manpreproc $< > $@

doc/cha-%.5: $(OBJDIR)/man/cha-%.md
	pandoc --standalone --to man $< -o $@

.PHONY: clean
clean:
	rm -rf "$(OBJDIR)/$(TARGET)"
	(cd lib/chaseccomp && $(MAKE) clean)

.PHONY: distclean
distclean: clean
	rm -rf "$(OUTDIR)"

manpages1 = cha.1 mancha.1
manpages5 = cha-config.5 cha-mailcap.5 cha-mime.types.5 cha-localcgi.5 \
	cha-urimethodmap.5 cha-protocols.5 cha-api.5 cha-troubleshooting.5 \
	cha-image.5

manpages = $(manpages1) $(manpages5)

.PHONY: manpage
manpage: $(manpages:%=doc/%)

protocols = http about file ftp sftp gopher gemini finger man spartan stbi \
	jebp sixel canvas resize
converters = gopher2html md2html ansi2html gmi2html dirlist2html
tools = urlenc nc

.PHONY: install
install:
	mkdir -p "$(DESTDIR)$(PREFIX)/bin"
	install -m755 "$(OUTDIR_BIN)/cha" "$(DESTDIR)$(PREFIX)/bin"
	install -m755 "$(OUTDIR_BIN)/mancha" "$(DESTDIR)$(PREFIX)/bin"
# intentionally not quoted
	mkdir -p $(LIBEXECDIR_CHAWAN)/cgi-bin
	for f in $(protocols); do \
	install -m755 "$(OUTDIR_CGI_BIN)/$$f" $(LIBEXECDIR_CHAWAN)/cgi-bin; \
	done
	for f in $(converters) $(tools); \
	do install -m755 "$(OUTDIR_LIBEXEC)/$$f" $(LIBEXECDIR_CHAWAN); \
	done
# urldec is just a symlink to urlenc
	(cd $(LIBEXECDIR_CHAWAN) && ln -sf urlenc urldec)
	mkdir -p "$(DESTDIR)$(MANPREFIX1)"
	for f in $(manpages1); do install -m644 "doc/$$f" "$(DESTDIR)$(MANPREFIX1)"; done
	mkdir -p "$(DESTDIR)$(MANPREFIX5)"
	for f in $(manpages5); do install -m644 "doc/$$f" "$(DESTDIR)$(MANPREFIX5)"; done

.PHONY: uninstall
uninstall:
	rm -f "$(DESTDIR)$(PREFIX)/bin/cha"
	rm -f "$(DESTDIR)$(PREFIX)/bin/mancha"
# intentionally not quoted
	for f in $(protocols); do rm -f $(LIBEXECDIR_CHAWAN)/cgi-bin/$$f; done
# notes:
# * png has been removed in favor of stbi
# * data has been moved back into the main binary
# * gmifetch has been replaced by gemini
# * cha-finger has been renamed to finger
	rm -f $(LIBEXECDIR_CHAWAN)/cgi-bin/png
	rm -f $(LIBEXECDIR_CHAWAN)/cgi-bin/data
	rm -f $(LIBEXECDIR_CHAWAN)/cgi-bin/gmifetch
	rm -f $(LIBEXECDIR_CHAWAN)/cgi-bin/cha-finger
	rmdir $(LIBEXECDIR_CHAWAN)/cgi-bin || true
	for f in $(converters) $(tools); do rm -f $(LIBEXECDIR_CHAWAN)/$$f; done
# urldec is just a symlink to urlenc
	rm -f $(LIBEXECDIR_CHAWAN)/urldec
	rmdir $(LIBEXECDIR_CHAWAN) || true
	for f in $(manpages5); do rm -f "$(DESTDIR)$(MANPREFIX5)/$$f"; done
	for f in $(manpages1); do rm -f "$(DESTDIR)$(MANPREFIX1)/$$f"; done

.PHONY: submodule
submodule:
	git submodule update --init

test/net/run: test/net/run.nim
	$(NIMC) test/net/run.nim

.PHONY: test_js
test_js:
	(cd test/js && ./run_js_tests.sh)

.PHONY: test_layout
test_layout:
	(cd test/layout && ./run_layout_tests.sh)

.PHONY: test_net
test_net: test/net/run
	(cd test/net && ./run)

.PHONY: test
test: test_js test_layout test_net