File: Makefile.in

package info (click to toggle)
swi-prolog 6.6.6-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 82,312 kB
  • sloc: ansic: 322,250; perl: 245,822; sh: 6,651; java: 5,254; makefile: 4,423; cpp: 4,153; ruby: 1,594; yacc: 843; xml: 82; sed: 12; sql: 6
file content (727 lines) | stat: -rw-r--r-- 22,939 bytes parent folder | download | duplicates (2)
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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
################################################################
# Makefile for SWI-Prolog 6.x
#
# Author:	Jan Wielemaker
#		J.Wielemake@cs.vu.nl
#		VU University Amsterdam
#		De Boelelaan 1081a
#		1081 HV  Amsterdam
#		The Netherlands
#
# This  Makefile  requires  GNU-Make,  often  installed  as  `gmake'  on
# Non-Linux systems.
#
# Public targets:
#
#	* make			Simply makes all programs in the current tree
#	* make install		Installs the libraries and public executables
#	* make install-bins	Link executables from $(bindir)
#	* make install-arch	Install machine dependent files
#	* make install-libs	Install machine independent files
#	* make install-lman	Install man files in Prolog lib hierarchy
#	* make check		Run some tests
#
# Building a profile-based version using gcc:
#
#       * make OPTIMISE=prof [PROFILE_SRC=<file>] [PROFILE_GOAL=<goal>]
#
# Copyright (C) University of Amsterdam, all rights reserved
#
# Copyright policy:
#
#	* LGPL (see file COPYING or http://www.swi-prolog.org/)
################################################################

.SUFFIXES: .i .pl

prefix=@prefix@
exec_prefix=@exec_prefix@
srcdir=@srcdir@
@VPATH@ @srcdir@
bindir=@bindir@
libdir=@libdir@
datarootdir=@datarootdir@
mandir=@mandir@
mansec=1
lmansec=3
smandir=$(mandir)/man$(mansec)
lmandir=$(mandir)/man$(lmansec)
plmandir=$(PLBASE)/man

PLVERSION=@PLVERSION@
PL=@PL@
PLWIN=@PL@-win
PLBASE=@PLBASE@
BOOTFILE=@BOOTFILE@

CC=@CC@
LDEXE=@LDEXE@
EXEEXT = @EXEEXT@
TXTEXT=@TXTEXT@
LIBS=@LIBS@
AWK=@AWK@
SED=sed
CHRPATH=@CHRPATH@
ETAGS=@ETAGS@
AR=@AR@
RANLIB=@RANLIB@
WINDRES=@WINDRES@
WINE=@WINE@
MSLIBEXE=@MSLIBEXE@
PLBUILD=@PLBUILD@
PLARCH=@PLARCH@
INSTALL_PLARCH=@INSTALL_PLARCH@
INSTALL=@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_SHOBJ=@INSTALL_PROGRAM@
INSTALL_SCRIPT=@INSTALL_SCRIPT@
INSTALL_DATA=@INSTALL_DATA@
MKDIR=@MKDIR@
REL_LN=$(srcdir)/rel-ln
RLPREFIX=@RLPREFIX@

COFLAGS=@COFLAGS@
CWFLAGS=@CWFLAGS@
CIFLAGS=@CIFLAGS@
CMFLAGS=@CMFLAGS@
CPFLAGS=
CFLAGS=	$(CWFLAGS) $(COFLAGS) $(CIFLAGS) $(CMFLAGS) $(CPFLAGS)
LDFLAGS=@LDFLAGS@ $(CPFLAGS)
STACKFLAGS=@STACKFLAGS@
SUBSYSTEMFLAGS=@SUBSYSTEMFLAGS@

MINGW=@MINGW@
MINGWPTHREAD=@MINGWPTHREAD@
DEFSTARTUP=@DEFSTARTUP@

HOST_TOOLCHAIN_FLAG=@HOST_TOOLCHAIN_FLAG@
HOST_OS_FLAG=@HOST_OS_FLAG@

CC_FOR_BUILD = @CC_FOR_BUILD@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@

PB=../boot
INCLUDEDIR=../include
EXPORTS=$(INCLUDEDIR)/SWI-Exports
DEF=$(PL).def
CINCLUDE=$(INCLUDEDIR)/SWI-Prolog.h
STREAMH=$(INCLUDEDIR)/SWI-Stream.h
STARTUPPATH=$(PL).prc
RUNTIMEDIR=../lib/$(PLARCH)
PLLIB=@PLLIB@
LNLIBS=@LNLIBS@
XLIBS=@XLIBS@
USEPLLIB=@USEPLLIB@
ifeq (@EXEFORMAT@,ELF)
LIBPLSO=
else
LIBPLSO=@USEPLLIB@
endif
RUNTIME=$(RUNTIMEDIR)/$(PLLIB)
SOEXT=@SO_EXT@
SOLIB=@SOLIB@
SHARED=@PLSO@
SHAREDV=$(SHARED).$(PLVERSION)
SONAMEOPT=@SONAMEOPT@
LIBRARYDIR=${PLBASE}/library
PLCUSTOM=${PLBASE}/customize
MKLIBS=@MKLIBS@
DEVPL=./swipl.sh

include $(srcdir)/common.mk

# MacOS
LIBPL_INSTALL_NAME=$(PLBASE)/lib/$(INSTALL_PLARCH)/$(SHARED)

OBJ+=	$(OSOBJ)
XOBJ=	@ALLOCA@ @EXTRAOBJ@
RCOBJ=	rc/access.o rc/build.o rc/html.o rc/util.o
TAIOBJ= libtai/caltime_utc.o libtai/caltime_tai.o libtai/leapsecs_sub.o \
	libtai/leapsecs_add.o libtai/caldate_fmjd.o libtai/caldate_mjd.o \
	libtai/leapsecs_init.o libtai/leapsecs_read.o libtai/tai_pack.o \
	libtai/tai_unpack.o
LIBOBJ= $(RCOBJ) $(TAIOBJ)
DEPLIBS=uxnt-lib plterm-lib rc-lib tai-lib $(MKLIBS)

PLOBJ=	pl-main.o

ALLOBJ= $(OBJ) $(PLOBJ) $(XOBJ)

PLINIT=	$(PB)/init.pl
ifeq ($(MINGW),true)
PLSRC+= ../boot/menu.pl
PLOSLIBS=wise.pl dde.pl progman.pl
endif

INCSRC=	pl-index.c pl-alloc.c pl-fli.c
SRC=	$(OBJ:.o=.c) $(PLOBJ:.o=.c) $(INCSRC)
HDR=	config.h parms.h pl-buffer.h pl-ctype.h pl-incl.h SWI-Prolog.h \
	pl-init.h pl-os.h pl-data.h

COMMON= README
UNICODE=blocks.pl unicode_data.pl
builddirs=../lib ../lib/$(PLARCH) os

# OPTIMISE=noprof: normal build; prof: build twice, using profiling
# information to optimise branches.  Normally set through
# configure --enable-useprofile
OPTIMISE=@OPTIMISE@
PROFILE_SRC=../bench/run.pl
PROFILE_GOAL=run(0.5)

all:	banner gitversion dirs $(OPTIMISE) swipl-ld$(EXEEXT)

noprof:	system headers plwin startup index
prof:
		$(MAKE) clean profclean
		$(MAKE) CPFLAGS=-fprofile-generate noprof
		$(DEVPL) -f none -s $(PROFILE_SRC) -q -g '$(PROFILE_GOAL),halt' -t 'halt(1)'
		$(MAKE) clean
		$(MAKE) CPFLAGS=-fprofile-use noprof
		$(MAKE) profclean

.c.o:
	$(CC) -c -I. -I$(srcdir) -I$(srcdir)/rc $(CFLAGS) $< @COUTOPT@
.c.i:
	$(CC) -E -I. -I$(srcdir) -I$(srcdir)/rc $(CFLAGS) $< @COUTOPT@

.PHONY:	system startup headers starticlib sharedlib index banner

system:		$(PL)$(EXEEXT)
startup:	$(STARTUPPATH)
headers:	parms.h $(CINCLUDE) $(STREAMH) @EXTRAHDR@
staticlib:	$(RUNTIME)
sharedlib:	$(RUNTIMEDIR)/$(SHARED)
index:		../library/INDEX.pl

banner:
		@echo "****************"
		@echo "Making SWI-Prolog $(PLVERSION) for $(PLARCH)"
		@echo "To be installed in $(bindir)/$(PL)$(EXEEXT)"
		@echo "Home (libraries) in $(PLBASE)"
		@echo "****************"


# $(CHRPATH) -c changes ELF DT_RPATH into DT_RUNPATH.  The latter can
# be overruled using LD_LIBRARY_PATH, which is what we need to be able
# to run our local copy of SWI-Prolog.

$(PL)$(EXEEXT):	$(DEPLIBS) $(PLOBJ) $(OSLIB)
		$(LDEXE) $(LDFLAGS) $(STACKFLAGS) -o $@ $(PLOBJ) -L../lib/$(PLARCH) $(USEPLLIB) $(LNLIBS) $(OSLIB)
		$(CHRPATH) -c $@ || true

$(STARTUPPATH):	$(PLINIT) $(PLSRC) $(PL)$(EXEEXT)
		rm -f $(STARTUPPATH)
		$(DEVPL) -O -o $(STARTUPPATH) -b $(PLINIT)
		ls -l $(STARTUPPATH)

.PHONY: dirs
dirs:
		@for d in $(builddirs); do \
		  if [ ! -d $$d ]; then mkdir $$d; fi; \
		done

$(RUNTIME):	dirs $(OBJ) $(LIBOBJ) $(XOBJ)
		rm -f $@
		$(AR) r $@ $(OBJ) $(LIBOBJ) $(XOBJ)
		$(RANLIB) $@

ifeq ($(SOEXT),dylib)
$(RUNTIMEDIR)/$(SHARED):	dirs $(OBJ) $(LIBOBJ) $(XOBJ)
		$(CC) -dynamiclib -current_version $(PLVERSION) \
			-install_name $(LIBPL_INSTALL_NAME) \
			$(COFLAGS) -o $@ \
			$(OBJ) $(LIBOBJ) $(XOBJ) $(LDFLAGS) $(LIBS)
else
ifeq ($(SOEXT),dll)
$(RUNTIMEDIR)/$(SHARED):	dirs $(OBJ) $(LIBOBJ) $(XOBJ) $(OSLIB)
		$(CC) -shared $(COFLAGS) -o $@ $(SONAMEOPT) \
			$(OBJ) $(LIBOBJ) $(XOBJ) $(LDFLAGS) $(OSLIB) $(LIBS)
		(cd $(RUNTIMEDIR) && $(MSLIBEXE) /def:libswipl.def)
else
$(RUNTIMEDIR)/$(SHAREDV):	dirs $(OBJ) $(LIBOBJ) $(XOBJ)
		$(CC) -shared $(COFLAGS) -o $@ $(SONAMEOPT) \
			$(OBJ) $(LIBOBJ) $(XOBJ) $(LDFLAGS) $(LIBS)

$(RUNTIMEDIR)/$(SHARED):	$(RUNTIMEDIR)/$(SHAREDV)
		( cd ../lib/$(PLARCH) && rm -f $(SHARED) && ln -s $(SHAREDV) $(SHARED) )
endif
endif

ifeq ($(MINGW),true)
OSLIB=	../lib/$(PLARCH)/libuxnt.a

$(OSLIB):	uxnt-lib
uxnt-lib:
		@(cd os/windows && $(MAKE) COFLAGS="$(COFLAGS)")

plterm-lib:
		@(cd win32/console && $(MAKE) COFLAGS="$(COFLAGS)")

plwin:		$(PLWIN)$(EXEEXT)

swipl-res.o:	$(srcdir)/swipl.rc $(srcdir)/swipl.ico
		$(WINDRES) -o $@ $<

pl-ntmain.o:	pl-ntmain.c
	$(CC) -c -I. -I$(srcdir) -I$(srcdir)/rc -I$(srcdir)/os $(CFLAGS) $< -o $@

$(PLWIN)$(EXEEXT):	swipl-res.o pl-ntmain.o $(DEPLIBS) $(OSLIB)
	$(LDEXE) $(LDFLAGS) $(STACKFLAGS) $(SUBSYSTEMFLAGS) \
		-o $@ swipl-res.o pl-ntmain.o -L../lib/$(PLARCH) -lplterm \
		$(USEPLLIB) $(LNLIBS) $(XLIBS) $(LIBS) $(OSLIB)

else
OSLIB=

uxnt-lib:
plterm-lib:
plwin:
endif

rc-lib:		$(RCOBJ)
		@(cd rc && $(MAKE) COFLAGS="$(COFLAGS)")
tai-lib:	$(TAIOBJ)
		@(cd libtai && $(MAKE) COFLAGS="$(COFLAGS)")

../library/INDEX.pl:	../library ../library/[a-z]*.pl $(DEVPL) $(STARTUPPATH)
		$(DEVPL) -x $(STARTUPPATH) \
			-f none -F none \
			-g make_library_index\(\'../library\'\) \
			-t halt

$(INCLUDEDIR):
		if [ ! -d $@ ]; then $(MKDIR) $@; fi

# Create SWI-Exports, used for importing and exporting symbols on behalf of
# the AIX version.

exports:	$(EXPORTS)
def:		$(DEF)

$(EXPORTS):	Makefile $(srcdir)/SWI-Prolog.h $(INCLUDEDIR)
		echo \#\!$(bindir)/$(PL)$(EXEEXT) > $@
		grep '^PL_EXPORT' $(srcdir)/SWI-Prolog.h $(srcdir)/SWI-Stream.h | \
		    $(SED) -e 's/.*[	*]\(_*PL_[a-zA-Z0-9_]*\).*/\1/' \
			   -e 's/.*[	*]\(S[a-zA-Z_]*\).*/\1/' | \
		    grep -v '_t$$' | grep -v '^PL_extension$$' | \
		    grep -v PL_w32thread_raise | grep -v PL_win_message_proc | \
		    grep -v PL_w32_wrap_ansi_console | \
		    grep -v PL_wait_for_console_input | \
		    grep -v Swinsock | \
		    sort -u >> $@

# Create pl.def, required for exporting symbols from pl.exe for the Cygwin
# platform

$(DEF):		$(srcdir)/SWI-Prolog.h
		echo EXPORTS > $@
		grep '^PL_EXPORT' $(srcdir)/SWI-Prolog.h $(srcdir)/SWI-Stream.h | \
		    $(SED) -e 's/.*[	*]\(_*PL_[a-zA-Z0-9_]*\).*/\1/' \
			   -e 's/.*[	*]\(S[a-zA-Z_]*\).*/\1/' | \
		    grep -v '_t$$' | grep -v '^PL_extension$$' | \
		    grep -v PL_w32thread_raise | grep -v PL_win_message_proc | \
		    grep -v PL_w32_wrap_ansi_console | \
		    grep -v PL_wait_for_console_input | \
		    grep -v Swinsock | \
		    sort -u >> $@

$(CINCLUDE):	$(srcdir)/SWI-Prolog.h $(INCLUDEDIR)
		cp $(srcdir)/SWI-Prolog.h $(CINCLUDE)

$(STREAMH):	$(srcdir)/os/SWI-Stream.h $(INCLUDEDIR)
		cp $(srcdir)/os/SWI-Stream.h $@

parms.h:	Makefile
		@echo "#ifndef PLHOME"				> $@%
		@echo "#define PLHOME       \"$(PLBASE)\""     >> $@%
		@echo "#endif"				       >> $@%
		@echo "#ifndef DEFSTARTUP"		       >> $@%
		@echo "#define DEFSTARTUP   \"$(DEFSTARTUP)\"" >> $@%
		@echo "#endif"				       >> $@%
		@echo $(PLVERSION) | \
		$(AWK) -F. '{ printf("#define PLVERSION %d\n", $$1 * 10000 + $$2 * 100 + $$3); }' >> $@%
		@echo "#ifndef PLARCH"			       >> $@%
		@echo "#define PLARCH	    \"$(PLARCH)\""     >> $@%
		@echo "#endif"				       >> $@%
		@echo "#define C_LIBS	    \"$(LNLIBS)\""     >> $@%
		@echo "#define C_PLLIB	    \"$(USEPLLIB)\""   >> $@%
		@echo "#define C_LIBPLSO    \"$(LIBPLSO)\""    >> $@%
		@echo "#ifndef C_CC"			       >> $@%
		@echo "#define C_CC	    \"$(CC)\""	       >> $@%
		@echo "#endif"				       >> $@%
		@echo "#ifndef C_CFLAGS"		       >> $@%
		@echo "#define C_CFLAGS	    \"$(CMFLAGS) $(CIFLAGS)\"" >> $@%
		@echo "#endif"				       >> $@%
		@echo "#ifndef C_LDFLAGS"		       >> $@%
		@echo "#define C_LDFLAGS    \"$(LDFLAGS)\""    >> $@%
		@echo "#endif"				       >> $@%
		@if cmp -s $@% $@; then rm $@%; else mv $@% $@; fi

.PHONY: gitversion
gitversion:
		@$(srcdir)/mkversion.sh
version.h:	gitversion
pl-version.o:	version.h

$(ALLOBJ):	parms.h \
		$(srcdir)/pl-funct.ih $(srcdir)/pl-vmi.h \
		$(srcdir)/pl-inline.h
pl-wam.o:	pl-alloc.c pl-index.c pl-fli.c pl-vmi.c \
		$(srcdir)/pl-vmi.h $(srcdir)/pl-jumptable.ic \
		$(srcdir)/pl-codelist.h
pl-prims.o:	pl-termwalk.c
pl-rec.o:	pl-termwalk.c
pl-copyterm.o:	pl-termwalk.c
pl-arith.o:	$(srcdir)/pl-segstack.h
pl-comp.o:	$(srcdir)/pl-vmi.h
pl-read.o:	pl-umap.c
pl-prof.o:	pentium.c
os/pl-dtoa.o:	os/dtoa.c
pl-text.o:	$(srcdir)/pl-codelist.h
$(srcdir)/pl-vmi.h $(srcdir)/pl-jumptable.ic $(srcdir)/pl-codetable.c: $(srcdir)/.vmi-sentinel
$(srcdir)/.vmi-sentinel:	$(srcdir)/pl-vmi.c mkvmi$(EXEEXT_FOR_BUILD)
		./mkvmi$(EXEEXT_FOR_BUILD) "$(srcdir)"
		@touch $@

mkvmi$(EXEEXT_FOR_BUILD):	mkvmi.c
		$(CC_FOR_BUILD) -g -O2 -o $@ $(srcdir)/mkvmi.c


ifdef RLPREFIX
pl-rl.o:	pl-rl.c
		$(CC) -c -I$(RLPREFIX)/include -I. -I$(srcdir) -I$(srcdir)/rc $(CFLAGS) $< @COUTOPT@
endif

$(srcdir)/pl-funct.ih $(srcdir)/pl-atom.ih: $(srcdir)/.defatom-sentinel
$(srcdir)/.defatom-sentinel: $(srcdir)/ATOMS defatom
		./defatom "$(srcdir)"
		@touch $@

defatom:	defatom.c
		$(CC) $(CFLAGS) -o $@ $(srcdir)/defatom.c

swipl-ld$(EXEEXT):	$(srcdir)/swipl-ld.c parms.h $(srcdir)/pl-vmi.h $(srcdir)/pl-atom.ih $(OSLIB)
	$(CC) $(LDFLAGS) $(HOST_TOOLCHAIN_FLAG) $(HOST_OS_FLAG) \
		-I. -I$(srcdir) $(CFLAGS) -o $@ $(srcdir)/swipl-ld.c $(OSLIB)

.PHONY: tags
tags:
		(cd $(srcdir) && $(ETAGS) *.[ch] os/*.[ch] rc/*.[ch])

cppout:		gitversion parms.h $(ALLOBJ:.o=.i) $(LIBOBJ:.o=.i)

.PHONY: check
check:
		$(DEVPL) -q -f $(srcdir)/test.pl -O -F none -g test,halt -t 'halt(1)'

.PHONY: ln-install install dv-install

ln-install:
		@$(MAKE) INSTALL_DATA=`pwd`/../packages/ln-install \
			 INSTALL_SHOBJ=`pwd`/../packages/ln-install \
			 install

install:	@INSTALLTARGET@

ifeq ($(MINGW),true)
dv-install:	dv-install-common install-mingw install-readme
else
dv-install:	dv-install-common install-bins install-pkgconfig install-man
endif

.PHONY: dv-install-common install-arch install-libs html-install

dv-install-common:	install-arch install-libs html-install

install-bins:	install-arch
		-if [ ! -d $(DESTDIR)$(bindir)  ]; then $(MKDIR) $(DESTDIR)$(bindir); fi
		for f in $(PL)$(EXEEXT) swipl-ld$(EXEEXT) swipl-rc$(EXEEXT); do \
		    $(REL_LN) $(DESTDIR)$(PLBASE)/bin/$(INSTALL_PLARCH)/$$f $(DESTDIR)$(bindir); \
		done

install-arch:	idirs iruntime
		for f in $(PL)$(EXEEXT) swipl-ld$(EXEEXT) rc/swipl-rc$(EXEEXT); do \
		    $(INSTALL_PROGRAM) $$f $(DESTDIR)$(PLBASE)/bin/$(INSTALL_PLARCH); \
		done

install-libs:	idirs iboot ilib iruntime iinclude icustom install-demo
		$(INSTALL_DATA) $(STARTUPPATH) "$(DESTDIR)$(PLBASE)/$(BOOTFILE)"
		echo . > "$(DESTDIR)$(PLBASE)/swipl.home"
		echo .. > "$(DESTDIR)$(PLBASE)/bin/swipl.home"
		$(DEVPL) -C "$(DESTDIR)$(PLBASE)" -f none -F none \
			-g 'make_library_index(library)' \
			-t halt

.PHONY:	install-mingw install-plterm install-plwin install-mkboot install-icon iruntime

install-mingw:	install-plterm install-plwin install-mkboot install-icon

install-plterm:	idirs
		if [ -f $(RUNTIMEDIR)/plterm.$(SOEXT) ]; then \
		  $(INSTALL_SHOBJ) $(RUNTIMEDIR)/plterm.$(SOEXT) $(DESTDIR)$(PLBASE)/$(SOLIB)/$(INSTALL_PLARCH) ; \
		  $(INSTALL_DATA) $(RUNTIMEDIR)/plterm.$(SOEXT).a $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH) ; \
		fi
		$(INSTALL_DATA) ../include/console.h $(DESTDIR)$(PLBASE)/include/plterm.h

install-plwin:	idirs iruntime
		$(INSTALL_PROGRAM) $(PLWIN)$(EXEEXT) $(DESTDIR)$(PLBASE)/bin/$(INSTALL_PLARCH)

install-mkboot:	idirs
		$(INSTALL_DATA) $(srcdir)/win32/misc/mkboot.bat $(DESTDIR)$(PLBASE)/bin/$(INSTALL_PLARCH)

install-icon:
		$(INSTALL_DATA) $(srcdir)/swipl.ico "$(DESTDIR)$(PLBASE)"

install-demo:	idirs
		$(INSTALL_DATA) ../demo/likes.pl $(DESTDIR)$(PLBASE)/demo
		$(INSTALL_DATA) ../demo/README $(DESTDIR)$(PLBASE)/demo/README$(TXTEXT)

installdirs=	bin bin/$(INSTALL_PLARCH) lib lib/$(INSTALL_PLARCH) boot \
		demo customize \
		include include/sicstus include/Yap \
		library \
		library/clp library/unicode library/dcg \
		library/dialect library/dialect/yap library/dialect/iso \
		library/dialect/ciao library/dialect/ciao/engine \
		library/dialect/ciao/regtypes \
		library/dialect/sicstus \
		library/dialect/swi \
		library/dialect/ifprolog \
		library/dialect/hprolog

.PHONY: iruntime install-implib

iruntime:	idirs
		if [ -f $(RUNTIME) ]; then \
		  $(INSTALL_DATA) $(RUNTIME) $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH); \
		  $(RANLIB) $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH)/$(PLLIB); \
		fi
ifeq ($(SOEXT),dylib)
		if [ -f $(RUNTIMEDIR)/$(SHARED) ]; then \
		  $(INSTALL_DATA) $(RUNTIMEDIR)/$(SHARED) $(DESTDIR)$(PLBASE)/$(SOLIB)/$(INSTALL_PLARCH) ; \
		fi
else
ifeq ($(SOEXT),dll)
		if [ -f $(RUNTIMEDIR)/$(SHARED) ]; then \
		  $(INSTALL_SHOBJ) $(RUNTIMEDIR)/$(SHARED) $(DESTDIR)$(PLBASE)/$(SOLIB)/$(INSTALL_PLARCH) ; \
		  $(INSTALL_DATA) $(RUNTIMEDIR)/libswipl.dll.a $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH) ; \
		  $(INSTALL_DATA) $(RUNTIMEDIR)/libswipl.def $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH) ; \
		  if [ -f $(RUNTIMEDIR)/libswipl.lib ]; then \
		    $(INSTALL_DATA) $(RUNTIMEDIR)/libswipl.lib $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH) ; \
		  fi ; \
		fi
else
		if [ -f $(RUNTIMEDIR)/$(SHAREDV) ]; then \
		  $(INSTALL_SHOBJ) $(RUNTIMEDIR)/$(SHAREDV) $(DESTDIR)$(PLBASE)/$(SOLIB)/$(INSTALL_PLARCH) ; \
		( cd $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH) && rm -f $(SHARED) && ln -s $(SHAREDV) $(SHARED) ) ; \
		fi
endif
endif

install-implib:	idirs
		$(INSTALL_DATA) libswiplimp.a $(DESTDIR)$(PLBASE)/lib/$(INSTALL_PLARCH)

.PHONY:	idirs iboot ilib iclp idcg idialect iswi iyap iifprolog ihprolog isicstus iciao iiso iunicode \
	icustom iinclude install-pkgconfig install-man install-lman install-readme html-install

idirs:
		if [ ! -d $(DESTDIR)$(libdir)  ]; then $(MKDIR) $(DESTDIR)$(libdir); fi
		if [ ! -d $(DESTDIR)$(PLBASE) ]; then $(MKDIR) $(DESTDIR)$(PLBASE); fi
		for d in $(installdirs); do \
			if [ ! -d $(DESTDIR)$(PLBASE)/$$d ]; then \
				$(MKDIR) $(DESTDIR)$(PLBASE)/$$d; \
			fi; \
		done


iboot:		idirs
		for f in $(PLINIT) $(PLSRC); do $(INSTALL_DATA) $$f $(DESTDIR)$(PLBASE)/boot; done

ilib:		idirs iclp idcg idialect iunicode
		for f in $(PLLIBS) $(PLOSLIBS); do \
			$(INSTALL_DATA) ../library/$$f $(DESTDIR)$(PLBASE)/library; \
		done

iclp:		idirs
		for f in $(CLP); do \
			$(INSTALL_DATA) ../library/clp/$$f $(DESTDIR)$(PLBASE)/library/clp; \
		done

idcg:		idirs
		for f in $(DCG); do \
			$(INSTALL_DATA) ../library/dcg/$$f $(DESTDIR)$(PLBASE)/library/dcg; \
		done

idialect:	idirs iswi iyap iiso isicstus iciao iifprolog ihprolog
		for f in $(DIALECT); do \
			$(INSTALL_DATA) ../library/dialect/$$f $(DESTDIR)$(PLBASE)/library/dialect; \
		done

iswi:		idirs
		for f in $(SWI); do \
			$(INSTALL_DATA) ../library/dialect/swi/$$f $(DESTDIR)$(PLBASE)/library/dialect/swi; \
		done

iyap:		idirs
		for f in $(YAP); do \
			$(INSTALL_DATA) ../library/dialect/yap/$$f $(DESTDIR)$(PLBASE)/library/dialect/yap; \
		done
		$(INSTALL_DATA) $(srcdir)/compat/YapInterface.h $(DESTDIR)$(PLBASE)/include/Yap/YapInterface.h

iifprolog:	idirs
		for f in $(IFPROLOG); do \
			$(INSTALL_DATA) ../library/dialect/ifprolog/$$f $(DESTDIR)$(PLBASE)/library/dialect/ifprolog; \
		done

ihprolog:	idirs
		for f in $(HPROLOG); do \
			$(INSTALL_DATA) ../library/dialect/hprolog/$$f $(DESTDIR)$(PLBASE)/library/dialect/hprolog; \
		done

isicstus:	idirs
		for f in $(SICSTUS); do \
			$(INSTALL_DATA) ../library/dialect/sicstus/$$f $(DESTDIR)$(PLBASE)/library/dialect/sicstus; \
		done
		$(INSTALL_DATA) $(srcdir)/compat/sicstus.h $(DESTDIR)$(PLBASE)/include/sicstus/sicstus.h

iciao:		idirs
		for f in $(CIAO); do \
			$(INSTALL_DATA) ../library/dialect/ciao/$$f $(DESTDIR)$(PLBASE)/library/dialect/ciao; \
		done
		for f in $(CIAO_ENGINE); do \
			$(INSTALL_DATA) ../library/dialect/ciao/engine/$$f $(DESTDIR)$(PLBASE)/library/dialect/ciao/engine; \
		done
		for f in $(CIAO_REGTYPES); do \
			$(INSTALL_DATA) ../library/dialect/ciao/regtypes/$$f $(DESTDIR)$(PLBASE)/library/dialect/ciao/regtypes; \
		done

iiso:		idirs
		for f in $(ISO); do \
			$(INSTALL_DATA) ../library/dialect/iso/$$f $(DESTDIR)$(PLBASE)/library/dialect/iso; \
		done

iunicode:	idirs
		for f in $(UNICODE); do \
			$(INSTALL_DATA) ../library/unicode/$$f $(DESTDIR)$(PLBASE)/library/unicode; \
		done

icustom:		idirs
		$(INSTALL_DATA) ../customize/README $(DESTDIR)$(PLCUSTOM)/README$(TXTEXT)
ifeq ($(MINGW),true)
		$(INSTALL_DATA) ../customize/dotplrc $(DESTDIR)$(PLCUSTOM)/pl.ini
		$(INSTALL_DATA) ../customize/dotxpcerc $(DESTDIR)$(PLCUSTOM)/xpce.ini
else
		$(INSTALL_DATA) ../customize/dotplrc $(DESTDIR)$(PLCUSTOM)
		$(INSTALL_DATA) ../customize/dotxpcerc $(DESTDIR)$(PLCUSTOM)
		$(INSTALL_SCRIPT) ../customize/edit $(DESTDIR)$(PLCUSTOM)
endif

iinclude:	idirs
		for f in SWI-Prolog.h SWI-Exports SWI-Stream.h; do \
		    if [ -f ../include/$$f ]; then \
			$(INSTALL_DATA) ../include/$$f $(DESTDIR)$(PLBASE)/include; \
		    fi; \
		done

install-pkgconfig:	idirs
		if [ ! -d $(DESTDIR)$(libdir)/pkgconfig ]; then $(MKDIR) $(DESTDIR)$(libdir)/pkgconfig; fi
		$(INSTALL_DATA) swipl.pc $(DESTDIR)$(libdir)/pkgconfig/

install-man:
		-if [ ! -d $(DESTDIR)$(mandir) ]; then $(MKDIR) $(DESTDIR)$(mandir); fi
		-if [ ! -d $(DESTDIR)$(smandir)  ];    then $(MKDIR) $(DESTDIR)$(smandir); fi
		-$(INSTALL_DATA) swipl.1 $(DESTDIR)$(smandir)/$(PL).$(mansec)
		-$(INSTALL_DATA) $(srcdir)/swipl-rc.1 $(DESTDIR)$(smandir)/swipl-rc.$(mansec)
		-$(INSTALL_DATA) $(srcdir)/swipl-ld.1 $(DESTDIR)$(smandir)/swipl-ld.$(mansec)

install-lman:
		if [ ! -d $(DESTDIR)$(plmandir) ]; then $(MKDIR) $(DESTDIR)$(plmandir); fi
		$(INSTALL_DATA) swipl.1 $(DESTDIR)$(plmandir)/$(PL).$(mansec)
		$(INSTALL_DATA) $(srcdir)/swipl-rc.1 $(DESTDIR)$(plmandir)/swipl-rc.$(mansec)
		$(INSTALL_DATA) $(srcdir)/swipl-ld.1 $(DESTDIR)$(plmandir)/swipl-ld.$(mansec)

install-readme:	idirs
		$(INSTALL_DATA) ../README $(DESTDIR)$(PLBASE)/README$(TXTEXT)
		$(INSTALL_DATA) ../VERSION $(DESTDIR)$(PLBASE)
		$(INSTALL_DATA) ../COPYING $(DESTDIR)$(PLBASE)/COPYING$(TXTEXT)
		$(INSTALL_DATA) ../man/windows.html $(DESTDIR)$(PLBASE)/doc

html-install:
		if [ -d ../man/Manual ]; then \
		  if [ ! -d $(DESTDIR)$(PLBASE)/doc ]; then $(MKDIR) $(DESTDIR)$(PLBASE)/doc; fi; \
		  if [ ! -d $(DESTDIR)$(PLBASE)/doc/Manual ]; then $(MKDIR) $(DESTDIR)$(PLBASE)/doc/Manual; fi; \
		  for f in ../man/Manual/*.html ../man/Manual/*.gif; do \
		    $(INSTALL_DATA) $$f $(DESTDIR)$(PLBASE)/doc/Manual; \
		  done; \
		fi

################################################################
# WINDOWS INSTALLER
################################################################

NSISDEFS=/DSWIPL=swipl /DPTHREAD=$(MINGWPTHREAD) /DZLIB=zlib1 /DBOOT=$(BOOTFILE) /DMINGW=1
ifneq (,$(findstring 64,$(PLARCH)))
NSISDEFS+=/DWIN64
endif
NSISEXE=C:/Program Files (x86)/NSIS/makensis.exe
SWIPLNSI=$(shell winepath -w "$(PLBASE)/../pl.nsi")

.PHONY: installer
installer:
		$(INSTALL_DATA) $(srcdir)/win32/installer/options.ini "$(PLBASE)/.."
		$(INSTALL_DATA) $(srcdir)/win32/installer/pl.nsi "$(PLBASE)/.."
		$(INSTALL_DATA) $(srcdir)/win32/installer/mkinstaller.pl "$(PLBASE)/.."
		$(WINE) "$(NSISEXE)" $(NSISDEFS) "$(SWIPLNSI)"


#
# Export (Linux binary distribution
#

export: install-lman
	../scripts/make-export $(DESTDIR)$(PLBASE)
	$(INSTALL_SCRIPT) ../scripts/swipl.sh $(DESTDIR)$(PLBASE)/bin/swipl
	$(INSTALL_SCRIPT) ../scripts/swipl-ld.sh $(DESTDIR)$(PLBASE)/bin/swipl-ld
	$(INSTALL_SCRIPT) ../scripts/swipl-rc.sh $(DESTDIR)$(PLBASE)/bin/swipl-rc
	$(INSTALL_DATA) ../scripts/README.LinuxBin $(DESTDIR)$(PLBASE)/README$(TXTEXT)

#
# Cleanup
#

clean:
		[ ! -f os/windows/Makefile ] || $(MAKE) -C os/windows $@
		[ ! -f win32/console/Makefile ] || $(MAKE) -C win32/console $@
		[ ! -f rc/Makefile ] || $(MAKE) -C rc $@
		[ ! -f libtai/Makefile ] || $(MAKE) -C libtai $@
		rm -f *.o $(ALLOBJ) os/*.o a.out core *~ #* parms.h
		rm -rf *.dSYM

profclean:
		[ ! -f rc/Makefile ] || $(MAKE) -C rc $@
		[ ! -f libtai/Makefile ] || $(MAKE) -C libtai $@
		rm -f *.gcda

distclean:	clean profclean
		[ ! -f rc/Makefile ] || $(MAKE) -C rc $@
		[ ! -f libtai/Makefile ] || $(MAKE) -C libtai $@
		[ ! -f ../man/Makefile ] || $(MAKE) -C ../man $@
		(cd ../src && rm -f pl-atom.ic pl-atom.ih pl-funct.ic pl-funct.ih .defatom-sentinel)
		(cd ../src && rm -f pl-codetable.c pl-vmi.h pl-jumptable.ic .vmi-sentinel)
		rm -f defatom mkvmi
		rm -rf $(INCLUDEDIR) ../lib
		rm -f ../library/INDEX.pl
		rm -f Makefile config.h config.status parms.h version.h
		rm -f $(DEVPL) swipl.home swiplbin $(STARTUPPATH)
		rm -f $(PL)$(EXEEXT)
		rm -f  swipl-ld$(EXEEXT)
		rm -f  swipl.1 libswiplimp.a $(DEF)
		rm -f config.log config.cache swipl.pc
		rm -rf $(PACKAGE_TMPDIR)

realclean:	clean
		rm -f $(STARTUPPATH)
		rm -f config.log config.cache
		rm -rf $(PL)$(EXEEXT) ../startup ../include ../lib