aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile.in
blob: 3b4b595cf46b87c8d057cfaeeae6adbb4a8b00e3 (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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
#
# Auto-configuring Makefile for the Netwide Assembler.
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the license given in the file "LICENSE"
# distributed in the NASM archive.

@SET_MAKE@

top_srcdir	= @top_srcdir@
srcdir		= @srcdir@
objdir		= @builddir@
VPATH		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= @bindir@
mandir		= @mandir@
datarootdir	= @datarootdir@

CC		= @CC@
CFLAGS		= @CFLAGS@
CPPFLAGS	= @CPPFLAGS@
BUILD_CFLAGS	= $(CPPFLAGS) $(CFLAGS) @DEFS@
INTERNAL_CFLAGS = -I$(srcdir) -I$(objdir) \
		  -I$(srcdir)/include -I$(objdir)/include \
		  -I$(srcdir)/x86 -I$(objdir)/x86 \
		  -I$(srcdir)/asm -I$(objdir)/asm \
		  -I$(srcdir)/disasm -I$(objdir)/disasm \
		  -I$(srcdir)/output -I$(objdir)/output
ALL_CFLAGS	= $(BUILD_CFLAGS) $(INTERNAL_CFLAGS)
LDFLAGS		= @LDFLAGS@
ALL_LDFLAGS     = $(ALL_CFLAGS) $(LDFLAGS)
LIBS		= @LIBS@

AR		= @AR@
RANLIB		= @RANLIB@
STRIP		= @STRIP@

PERL		= perl
PERLFLAGS	= -I$(srcdir)/perllib -I$(srcdir)
RUNPERL         = $(PERL) $(PERLFLAGS)

PYTHON3		= python3

INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@

# Optional tools
NROFF		= @NROFF@
ASCIIDOC	= @ASCIIDOC@
XMLTO		= @XMLTO@
MAKENSIS	= @MAKENSIS@
XZ              = @XZ@

# Optional targets
MANPAGES        = @MANPAGES@
NSIS            = @NSIS@

MKDIR_P		= @MKDIR_P@
RM_F		= rm -f
RM_RF		= rm -rf
LN_S		= @LN_S@
FIND		= find

# Binary suffixes
O              	= @OBJEXT@
X              	= @EXEEXT@
A		= @LIBEXT@

# Debug stuff
ifeq ($(TRACE),1)
	CFLAGS += -DNASM_TRACE
endif

.SUFFIXES:
.SUFFIXES: $(X) .$(O) .$(A) .xml .1 .c .i .s .txt .time

.PHONY: all doc rdf install clean distclean cleaner spotless install_rdf test
.PHONY: install_doc everything install_everything strip perlreq dist tags TAGS
.PHONY: nothing manpages nsis

.c.$(O):
	$(CC) -c $(ALL_CFLAGS) -o $@ $<

.c.s:
	$(CC) -S $(ALL_CFLAGS) -o $@ $<

.c.i:
	$(CC) -E $(ALL_CFLAGS) -o $@ $<

.txt.xml:
	$(ASCIIDOC) -b docbook -d manpage -o $@ $<

.xml.1:
	$(XMLTO) man --skip-validation $< 2>/dev/null

#-- Begin File Lists --#
NASM    = asm/nasm.$(O)
NDISASM = disasm/ndisasm.$(O)

PROGOBJ = $(NASM) $(NDISASM)
PROGS   = nasm$(X) ndisasm$(X)

LIBOBJ_NW = stdlib/snprintf.$(O) stdlib/vsnprintf.$(O) stdlib/strlcpy.$(O) \
	stdlib/strnlen.$(O) stdlib/strrchrnul.$(O) \
	\
	nasmlib/ver.$(O) \
	nasmlib/alloc.$(O) nasmlib/asprintf.$(O) nasmlib/errfile.$(O) \
	nasmlib/crc64.$(O) nasmlib/md5c.$(O) \
	nasmlib/string.$(O) nasmlib/nctype.$(O) \
	nasmlib/file.$(O) nasmlib/mmap.$(O) nasmlib/ilog2.$(O) \
	nasmlib/realpath.$(O) nasmlib/path.$(O) \
	nasmlib/filename.$(O) nasmlib/rlimit.$(O) \
	nasmlib/zerobuf.$(O) nasmlib/readnum.$(O) nasmlib/bsi.$(O) \
	nasmlib/rbtree.$(O) nasmlib/hashtbl.$(O) \
	nasmlib/raa.$(O) nasmlib/saa.$(O) \
	nasmlib/strlist.$(O) \
	nasmlib/perfhash.$(O) nasmlib/badenum.$(O) \
	\
	common/common.$(O) \
	\
	x86/insnsa.$(O) x86/insnsb.$(O) x86/insnsd.$(O) x86/insnsn.$(O) \
	x86/regs.$(O) x86/regvals.$(O) x86/regflags.$(O) x86/regdis.$(O) \
	x86/disp8.$(O) x86/iflag.$(O) \
	\
	asm/error.$(O) \
	asm/floats.$(O) \
	asm/directiv.$(O) asm/directbl.$(O) \
	asm/pragma.$(O) \
	asm/assemble.$(O) asm/labels.$(O) asm/parser.$(O) \
	asm/preproc.$(O) asm/quote.$(O) asm/pptok.$(O) \
	asm/listing.$(O) asm/eval.$(O) asm/exprlib.$(O) asm/exprdump.$(O) \
	asm/stdscan.$(O) \
	asm/strfunc.$(O) asm/tokhash.$(O) \
	asm/segalloc.$(O) \
	asm/rdstrnum.$(O) \
	asm/srcfile.$(O) \
	macros/macros.$(O) \
	\
	output/outform.$(O) output/outlib.$(O) output/legacy.$(O) \
	output/nulldbg.$(O) output/nullout.$(O) \
	output/outbin.$(O) output/outaout.$(O) output/outcoff.$(O) \
	output/outelf.$(O) \
	output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
	output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
	output/codeview.$(O) \
	\
	disasm/disasm.$(O) disasm/sync.$(O)

# Warnings depend on all source files, so handle them separately
WARNOBJ   = asm/warnings.$(O)

LIBOBJ    = $(LIBOBJ_NW) $(WARNOBJ)
ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW)
ALLOBJ    = $(PROGOBJ) $(LIBOBJ)

SUBDIRS  = stdlib nasmlib output asm disasm x86 common macros
XSUBDIRS = test doc nsis rdoff
DEPDIRS  = . include config x86 rdoff $(SUBDIRS)
#-- End File Lists --#

all: dirs
	$(MAKE) $(PROGS) rdf

NASMLIB = libnasm.$(A)

dirs:
	$(MKDIR_P) $(SUBDIRS) $(XSUBDIRS)

$(NASMLIB): $(LIBOBJ)
	$(RM_F) $(NASMLIB)
	$(AR) cq $(NASMLIB) $(LIBOBJ)
	$(RANLIB) $(NASMLIB)

nasm$(X): $(NASM) $(NASMLIB)
	$(CC) $(ALL_LDFLAGS) -o nasm$(X) $(NASM) $(NASMLIB) $(LIBS)

ndisasm$(X): $(NDISASM) $(NASMLIB)
	$(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $(NDISASM) $(NASMLIB) $(LIBS)

#-- Begin Generated File Rules --#

# These source files are automagically generated from data files using
# Perl scripts. They're distributed, though, so it isn't necessary to
# have Perl just to recompile NASM from the distribution.

# Perl-generated source files
PERLREQ = config/unconfig.h \
	  x86/insnsb.c x86/insnsa.c x86/insnsd.c x86/insnsi.h x86/insnsn.c \
	  x86/regs.c x86/regs.h x86/regflags.c x86/regdis.c x86/regdis.h \
	  x86/regvals.c asm/tokhash.c asm/tokens.h asm/pptok.h asm/pptok.c \
	  x86/iflag.c x86/iflaggen.h \
	  macros/macros.c \
	  asm/pptok.ph asm/directbl.c asm/directiv.h \
	  asm/warnings.c include/warnings.h doc/warnings.src \
	  version.h version.mac version.mak nsis/version.nsh

INSDEP = x86/insns.dat x86/insns.pl x86/insns-iflags.ph x86/iflags.ph

config/unconfig.h: config/config.h.in
	$(RUNPERL) $(srcdir)/tools/unconfig.pl \
		'$(srcdir)' config/config.h.in config/unconfig.h

x86/iflag.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -fc \
		$(srcdir)/x86/insns.dat x86/iflag.c
x86/iflaggen.h: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -fh \
		$(srcdir)/x86/insns.dat x86/iflaggen.h
x86/insnsb.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -b \
		$(srcdir)/x86/insns.dat x86/insnsb.c
x86/insnsa.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -a \
		$(srcdir)/x86/insns.dat x86/insnsa.c
x86/insnsd.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -d \
		$(srcdir)/x86/insns.dat x86/insnsd.c
x86/insnsi.h: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -i \
		$(srcdir)/x86/insns.dat x86/insnsi.h
x86/insnsn.c: $(INSDEP)
	$(RUNPERL) $(srcdir)/x86/insns.pl -n \
		$(srcdir)/x86/insns.dat x86/insnsn.c

# These files contains all the standard macros that are derived from
# the version number.
version.h: version version.pl
	$(RUNPERL) $(srcdir)/version.pl h < $(srcdir)/version > version.h
version.mac: version version.pl
	$(RUNPERL) $(srcdir)/version.pl mac < $(srcdir)/version > version.mac
version.sed: version version.pl
	$(RUNPERL) $(srcdir)/version.pl sed < $(srcdir)/version > version.sed
version.mak: version version.pl
	$(RUNPERL) $(srcdir)/version.pl make < $(srcdir)/version > version.mak
nsis/version.nsh: version version.pl
	$(RUNPERL) $(srcdir)/version.pl nsis < $(srcdir)/version > nsis/version.nsh

# This source file is generated from the standard macros file
# `standard.mac' by another Perl script. Again, it's part of the
# standard distribution.
macros/macros.c: macros/macros.pl asm/pptok.ph version.mac \
	$(srcdir)/macros/*.mac $(srcdir)/output/*.mac
	$(RUNPERL) $(srcdir)/macros/macros.pl version.mac \
		$(srcdir)/macros/*.mac $(srcdir)/output/*.mac

# These source files are generated from regs.dat by yet another
# perl script.
x86/regs.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl c \
		$(srcdir)/x86/regs.dat > x86/regs.c
x86/regflags.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl fc \
		$(srcdir)/x86/regs.dat > x86/regflags.c
x86/regdis.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl dc \
		$(srcdir)/x86/regs.dat > x86/regdis.c
x86/regdis.h: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl dh \
		$(srcdir)/x86/regs.dat > x86/regdis.h
x86/regvals.c: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl vc \
		$(srcdir)/x86/regs.dat > x86/regvals.c
x86/regs.h: x86/regs.dat x86/regs.pl
	$(RUNPERL) $(srcdir)/x86/regs.pl h \
		$(srcdir)/x86/regs.dat > x86/regs.h

# Extract warnings from source code. This is done automatically if any
# C files have changed; the script is fast enough that that is
# reasonable, but doesn't update the time stamp if the files aren't
# changed, to avoid rebuilding everything every time. Track the actual
# dependency by the empty file asm/warnings.time.
WARNFILES = asm/warnings.c include/warnings.h doc/warnings.src

warnings:
	$(RM_F) $(WARNFILES)
	$(MAKE) asm/warnings.time

asm/warnings.time: $(ALLOBJ_NW:.$(O)=.c)
	: > asm/warnings.time
	$(MAKE) $(WARNFILES:=.time)

asm/warnings.c.time: asm/warnings.pl asm/warnings.time
	$(RUNPERL) $(srcdir)/asm/warnings.pl c asm/warnings.c $(srcdir)
	: > asm/warnings.c.time

asm/warnings.c: asm/warnings.c.time
	@: Side effect

include/warnings.h.time: asm/warnings.pl asm/warnings.time
	$(RUNPERL) $(srcdir)/asm/warnings.pl h include/warnings.h $(srcdir)
	: > include/warnings.h.time

include/warnings.h: include/warnings.h.time
	@: Side effect

doc/warnings.src.time: asm/warnings.pl asm/warnings.time
	$(RUNPERL) $(srcdir)/asm/warnings.pl doc doc/warnings.src $(srcdir)
	: > doc/warnings.src.time

doc/warnings.src : doc/warnings.src.time
	@: Side effect

# Assembler token hash
asm/tokhash.c: x86/insns.dat x86/regs.dat asm/tokens.dat asm/tokhash.pl \
	perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/tokhash.pl c \
		$(srcdir)/x86/insns.dat $(srcdir)/x86/regs.dat \
		$(srcdir)/asm/tokens.dat > asm/tokhash.c

# Assembler token metadata
asm/tokens.h: x86/insns.dat x86/regs.dat asm/tokens.dat asm/tokhash.pl \
	perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/tokhash.pl h \
		$(srcdir)/x86/insns.dat $(srcdir)/x86/regs.dat \
		$(srcdir)/asm/tokens.dat > asm/tokens.h

# Preprocessor token hash
asm/pptok.h: asm/pptok.dat asm/pptok.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/pptok.pl h \
		$(srcdir)/asm/pptok.dat asm/pptok.h
asm/pptok.c: asm/pptok.dat asm/pptok.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/pptok.pl c \
		$(srcdir)/asm/pptok.dat asm/pptok.c
asm/pptok.ph: asm/pptok.dat asm/pptok.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/asm/pptok.pl ph \
		$(srcdir)/asm/pptok.dat asm/pptok.ph

# Directives hash
asm/directiv.h: asm/directiv.dat nasmlib/perfhash.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/nasmlib/perfhash.pl h \
		$(srcdir)/asm/directiv.dat asm/directiv.h
asm/directbl.c: asm/directiv.dat nasmlib/perfhash.pl perllib/phash.ph
	$(RUNPERL) $(srcdir)/nasmlib/perfhash.pl c \
		$(srcdir)/asm/directiv.dat asm/directbl.c

#-- End Generated File Rules --#

perlreq: $(PERLREQ)

# This rule is only used for RDOFF
.$(O)$(X):
	$(CC) $(ALL_LDFLAGS) -o $@ $< $(RDFLIB) $(NASMLIB) $(LIBS)

RDFLN    = cd rdoff && ln -s
RDFLNPFX =

#-- Begin RDOFF Shared Rules --#

RDFLIBOBJ = rdoff/rdoff.$(O) rdoff/rdfload.$(O) rdoff/symtab.$(O) \
	    rdoff/collectn.$(O) rdoff/rdlib.$(O) rdoff/segtab.$(O) \
	    rdoff/hash.$(O)

RDFPROGS = rdoff/rdfdump$(X) rdoff/ldrdf$(X) rdoff/rdx$(X) rdoff/rdflib$(X) \
	   rdoff/rdf2bin$(X)
RDF2BINLINKS = rdoff/rdf2com$(X) rdoff/rdf2ith$(X) \
	    rdoff/rdf2ihx$(X) rdoff/rdf2srec$(X)

RDFLIB = rdoff/librdoff.$(A)
RDFLIBS = $(RDFLIB) $(NASMLIB)

rdoff/rdfdump$(X): rdoff/rdfdump.$(O) $(RDFLIBS)
rdoff/ldrdf$(X): rdoff/ldrdf.$(O) $(RDFLIBS)
rdoff/rdx$(X): rdoff/rdx.$(O) $(RDFLIBS)
rdoff/rdflib$(X): rdoff/rdflib.$(O) $(RDFLIBS)
rdoff/rdf2bin$(X): rdoff/rdf2bin.$(O) $(RDFLIBS)
rdoff/rdf2com$(X): rdoff/rdf2bin$(X)
	$(RM_F) rdoff/rdf2com$(X)
	$(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2com$(X)
rdoff/rdf2ith$(X): rdoff/rdf2bin$(X)
	$(RM_F) rdoff/rdf2ith$(X)
	$(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ith$(X)
rdoff/rdf2ihx$(X): rdoff/rdf2bin$(X)
	$(RM_F) rdoff/rdf2ihx$(X)
	$(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2ihx$(X)
rdoff/rdf2srec$(X): rdoff/rdf2bin$(X)
	$(RM_F) rdoff/rdf2srec$(X)
	$(RDFLN) $(RDFLNPFX)rdf2bin$(X) $(RDFLNPFX)rdf2srec$(X)

#-- End RDOFF Shared Rules --#

rdf: $(RDFPROGS) $(RDF2BINLINKS)

$(RDFLIB): $(RDFLIBOBJ)
	$(RM_F) $(RDFLIB)
	$(AR) cq $(RDFLIB) $(RDFLIBOBJ)
	$(RANLIB) $(RDFLIB)

#-- Begin NSIS Rules --#

nsis/arch.nsh: nsis/getpearch.pl nasm$(X)
	$(PERL) $(srcdir)/nsis/getpearch.pl nasm$(X) > nsis/arch.nsh

# Should only be done after "make everything".
# The use of redirection here keeps makensis from moving the cwd to the
# source directory.
nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh
	$(MAKENSIS) -Dsrcdir="$(srcdir)" -Dobjdir="$(objdir)" - < nsis/nasm.nsi

#-- End NSIS Rules --#

# Generated manpages, also pregenerated for distribution
manpages: nasm.1 ndisasm.1

install: $(PROGS)
	$(MKDIR_P) $(DESTDIR)$(bindir)
	$(INSTALL_PROGRAM) $(PROGS) $(DESTDIR)$(bindir)/
	$(MKDIR_P) $(DESTDIR)$(mandir)/man1
	$(INSTALL_DATA) $(srcdir)/nasm.1 $(DESTDIR)$(mandir)/man1/nasm.1
	$(INSTALL_DATA) $(srcdir)/ndisasm.1 $(DESTDIR)$(mandir)/man1/ndisasm.1

clean:
	for d in . $(SUBDIRS) $(XSUBDIRS); do \
		$(RM_F) "$$d"/*.$(O) "$$d"/*.s "$$d"/*.i "$$d"/*.$(A) ; \
	done
	$(RM_F) $(PROGS)
	$(RM_F) nasm-*-installer-*.exe
	$(RM_F) tags TAGS
	$(RM_F) nsis/arch.nsh
	$(RM_F) perlbreq.si
	$(RM_F) $(RDFPROGS) $(RDF2BINLINKS)

distclean: clean
	$(RM_F) config.log config.status config/config.h
	for d in . $(SUBDIRS) $(XSUBDIRS); do \
		$(RM_F) "$$d"/.\# "$$d"/\# "$$d"/*~ "$$d"/*.bak \
			"$$d"/*.lst "$$d"/*.bin ; \
	done
	$(RM_F) test/*.$(O)
	$(RM_RF) autom4te*.cache
	$(RM_F) Makefile *.dep

cleaner: clean
	$(RM_F) $(PERLREQ) *.1 nasm.spec
	$(MAKE) -C doc clean
	$(RM_F) *.dep */*.time

spotless: distclean cleaner
	$(RM_F) doc/Makefile

strip:
	$(STRIP) --strip-unneeded $(PROGS)

TAGS:
	$(RM_F) TAGS
	$(FIND) . -name '*.[hcS]' -print | xargs etags -a

tags:
	$(RM_F) tags
	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a

cscope:
	$(RM_F) cscope.out cscope.files
	$(FIND) . -name '*.[hcS]' -print > cscope.files
	cscope -b -f cscope.out

rdf_install install_rdf install_rdoff:
	$(MKDIR_P) $(DESTDIR)$(bindir)
	for f in $(RDFPROGS); do \
		$(INSTALL_PROGRAM) "$$f" '$(DESTDIR)$(bindir)'/ ; \
	done
	cd '$(DESTDIR)$(bindir)' && \
	for f in $(RDF2BINLINKS); do \
		bn=`basename "$$f"` && $(RM_F) "$$bn" && \
		$(LN_S) rdf2bin$(X) "$$bn" ; \
	done
	$(MKDIR_P) $(DESTDIR)$(mandir)/man1
	$(INSTALL_DATA) $(srcdir)/rdoff/*.1 $(DESTDIR)$(mandir)/man1/

doc: doc/warnings.src
	$(MAKE) -C doc all

doc_install install_doc:
	$(MAKE) -C doc install

# Dummy target to prevent accidental invocation of the default "all" target
nothing:

always_everything: dirs
	$(MAKE) all doc

everything: always_everything
	$(MAKE) $(MANPAGES) $(NSIS) nothing

install_everything: everything install install_doc install_rdf

dist:
	$(MAKE) alldeps
	$(MAKE) spotless perlreq manpages spec $(MANPAGES)
	autoheader
	autoconf
	$(RM_RF) ./autom4te*.cache

tar: dist
	tar -cv --exclude CVS -C .. -f - | \
		$(XZ) -9e > \
		../nasm-`cat version`-`date +%Y%m%d`.tar.xz `basename \`pwd\``

spec: nasm.spec

ALLPERLSRC := $(shell find $(srcdir) -type f -name '*.p[lh]')

perlbreq.si: $(ALLPERLSRC)
	sed -n -r -e 's/^[[:space:]]*use[[:space:]]+([^[:space:];]+).*$$/BuildRequires: perl(\1)/p' $(ALLPERLSRC) | \
	sed -r -e '/perl\((strict|warnings|Win32.*)\)/d' | \
	sort | uniq > perlbreq.si

nasm.spec: nasm.spec.in nasm.spec.sed version.sed perlbreq.si
	sed -f version.sed -f nasm.spec.sed \
	< nasm.spec.in > nasm.spec

splint:
	splint -weak *.c

test: $(PROGS)
	cd test && $(RUNPERL) performtest.pl --nasm=../nasm *.asm

golden: $(PROGS)
	cd test && $(RUNPERL) performtest.pl --golden --nasm=../nasm *.asm

travis: $(PROGS)
	$(PYTHON3) travis/nasm-t.py run

#
# Rules to run autogen if necessary
#
configure: configure.ac autoconf/aclocal.m4
	sh autogen.sh --recheck

config.status: configure
	@if [ ! -f config.status ]; then \
		echo "*** ERROR: Need to run configure!" 1>&2 ; \
		exit 1; \
	fi
	sh config.status --recheck

Makefile: config.status Makefile.in doc/Makefile.in
	sh config.status

doc/Makefile: Makefile

config/config.h: config.status

#
# Dummy rules that changes make behavior
# (at end to avoid confusing non-GNU makes)
#
.SECONDARY:

.DELETE_ON_ERROR:

#
# Does this version of this file have external dependencies?  This definition
# will be automatically updated by mkdep.pl as needed.
#
EXTERNAL_DEPENDENCIES = 1

#
# Generate dependency information for this Makefile only.
# If this Makefile has external dependency information, then
# the dependency information will remain external, so it doesn't
# pollute the git logs.
#
Makefile.dep: $(PERLREQ) tools/mkdep.pl config.status
	$(RUNPERL) tools/mkdep.pl -M Makefile.in -- $(DEPDIRS)

dep: Makefile.dep

#
# This build dependencies in *ALL* makefiles, and forces all
# dependencies to be inserted inline.  For that reason, it should only
# be invoked manually or via "make dist".  It should be run before
# creating release archives.
#
alldeps: $(PERLREQ) tools/syncfiles.pl tools/mkdep.pl
	$(RUNPERL) tools/syncfiles.pl Makefile.in Mkfiles/*.mak
	$(RUNPERL) tools/mkdep.pl -i -M Makefile.in Mkfiles/*.mak -- \
		$(DEPDIRS)
	$(RM_F) *.dep
	if [ -f config.status ]; then \
		sh config.status; \
	fi

# Strip internal dependency information from all Makefiles; this makes
# the output good for git checkin
cleandeps: $(PERLREQ) tools/syncfiles.pl tools/mkdep.pl
	$(RUNPERL) tools/syncfiles.pl Makefile.in Mkfiles/*.mak
	$(RUNPERL) tools/mkdep.pl -e -M Makefile.in Mkfiles/*.mak -- \
		$(DEPDIRS)
	$(RM_F) *.dep
	if [ -f config.status ]; then \
		sh config.status; \
	fi

#-- Magic hints to mkdep.pl --#
# @object-ending: ".$(O)"
# @path-separator: "/"
# @external: "Makefile.dep"
# @include-command: "include"
# @selfrule: "1"
#-- Everything below is generated by mkdep.pl - do not edit --#
include Makefile.dep