File: Makefile

package info (click to toggle)
swi-prolog 3.1.0-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,772 kB
  • ctags: 12,869
  • sloc: ansic: 43,657; perl: 12,577; lisp: 4,359; sh: 1,534; makefile: 798; awk: 14
file content (357 lines) | stat: -rw-r--r-- 9,944 bytes parent folder | download
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
# Generated automatically from Makefile.in by configure.
################################################################
# Makefile for SWI-Prolog 2.9
# $Id: Makefile.in,v 1.55 1998/08/06 13:26:36 jan Exp $
#
# Author:	Jan Wielemaker
#		jan@swi.psy.uva.nl
#		SWI
#		University of Amsterdam
#    		Roetersstraat 15
#		1018 WB  Amsterdam
#		The Netherlands
#
# 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 $(exec_prefix)/bin
#	* make install-arch	Install machine dependent files
#	* make install-libs	Install machine independent files
#
# Copyright (c) University of Amsterdam, all rights reserved
# 
# Copyright policy:
#	
#	* Free for personal, academic and internal prototyping purposes
#
#	* A licence is required for distributing commercial applications
#	  based on SWI-Prolog.  Contact prolog-request@swi.psy.uva.nl.
################################################################

PLVERSION=3.1.0

PL=pl
prefix=/usr
exec_prefix=${prefix}
srcdir=.
vpath %.c .
bindir=$(exec_prefix)/bin
#PLBASE=$(prefix)/lib/pl-$(PLVERSION)
PLBASE=$(prefix)/lib/swi-prolog
man_prefix=$(prefix)/man
mansec=1
lmansec=3
mandir=$(man_prefix)/man$(mansec)
lmandir=$(man_prefix)/man$(lmansec)
plmandir=$(man_prefix)/man$(mansec)

CC=gcc
LIBS=-ldl -lreadline -lncurses -lm 
AWK=mawk
SED=sed
ETAGS=etags
AR=ar
RANLIB=ranlib
ARCH=i586-linux
INSTALL=/usr/bin/install -c
INSTALL_PROGRAM=${INSTALL}
INSTALL_DATA=${INSTALL} -m 644

COFLAGS=-O2
CWFLAGS=-Wall
CIFLAGS=
CMFLAGS=
CFLAGS=	$(CWFLAGS) $(COFLAGS) $(CIFLAGS) $(CMFLAGS)
LDFLAGS=-export-dynamic 

PLFOREIGN=

DEFSTARTUP=.plrc

PB=../boot
INCLUDEDIR=../include
EXPORTS=$(INCLUDEDIR)/SWI-Exports
CINCLUDE=$(INCLUDEDIR)/SWI-Prolog.h
STREAMH=$(INCLUDEDIR)/SWI-Stream.h
STUBC=$(INCLUDEDIR)/stub.c
STARTUPPATH=$(PL).prc
RUNTIMEDIR=../runtime/$(ARCH)
PLLIB=libpl.a
RUNTIME=$(RUNTIMEDIR)/$(PLLIB)
LIBRARYDIR=${PLBASE}/library


OBJ=	pl-atom.o pl-wam.o pl-stream.o pl-error.o pl-arith.o pl-bag.o \
	pl-comp.o pl-rc.o \
	pl-dwim.o pl-ext.o pl-file.o pl-flag.o pl-fmt.o pl-funct.o \
	pl-gc.o pl-glob.o pl-itf.o pl-list.o pl-load.o \
	pl-modul.o pl-op.o pl-os.o pl-prims.o pl-pro.o pl-proc.o \
	pl-prof.o pl-read.o pl-rec.o pl-rl.o pl-setup.o pl-sys.o pl-table.o \
	pl-trace.o pl-util.o pl-wic.o pl-write.o pl-term.o pl-buffer.o
RCOBJ=	rc/access.o rc/build.o rc/html.o rc/rc.o rc/util.o

DEPOBJ=	pl-main.o
EXT=	pl-extend.o
ALLOBJ= $(OBJ) $(DEPOBJ) $(EXT)

PLINIT=	$(PB)/init.pl

SRC=	$(OBJ:.o=.c) $(DEPOBJ:.o=.c) $(EXT:.o=.c) pl-index.c pl-alloc.c
HDR=	config.h parms.h pl-buffer.h pl-ctype.h pl-incl.h pl-itf.h pl-main.h \
	pl-os.h pl-data.h

PLSRC=	../boot/syspred.pl ../boot/toplevel.pl ../boot/listing.pl \
	../boot/edit.pl ../boot/sort.pl ../boot/bags.pl ../boot/apply.pl \
	../boot/list.pl ../boot/writef.pl ../boot/history.pl \
	../boot/profile.pl ../boot/dwim.pl ../boot/rc.pl \
	../boot/foreign.pl ../boot/parms.pl ../boot/autoload.pl \
	../boot/qlf.pl ../boot/topvars.pl ../boot/messages.pl

all:	banner \
	headers rc-lib system startup index runtime \
	pl-bite chpl plld \
	swipl swiplbin

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

system:		$(PL)
startup:	$(STARTUPPATH)
headers:	parms.h $(EXPORTS) $(CINCLUDE) $(STREAMH) $(STUBC)
runtime:	$(RUNTIME)

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


$(PL):		$(ALLOBJ)
		$(CC) $(LDFLAGS) -o $(PL) -Lrc $(ALLOBJ) -lrc $(LIBS)


$(STARTUPPATH):	$(PLINIT) $(PLSRC) pl-wam.o pl-wic.o
		./$(PL) -O -o $(STARTUPPATH) -b $(PLINIT)


$(RUNTIME):	$(OBJ) $(RCOBJ) $(DEPOBJ)
		if [ ! -d ../runtime ]; then mkdir ../runtime; fi
		if [ ! -d $(RUNTIMEDIR) ]; then mkdir $(RUNTIMEDIR); fi
		rm -f $@
		$(AR) r $@ $(OBJ) $(RCOBJ) $(DEPOBJ)
		$(RANLIB) $@

rc-lib:
		@(cd rc && $(MAKE))

index:
		./$(PL) -x $(STARTUPPATH) \
			-f none \
			-g make_library_index\(\'../library\'\) \
			-t halt

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

$(EXPORTS):	Makefile $(srcdir)/pl-itf.h $(INCLUDEDIR)
		echo \#\!$(bindir)/$(PL) > $(EXPORTS)
		grep '^__pl_export' $(srcdir)/pl-itf.h | \
			$(SED) 's/.*\(PL_[a-zA-Z0-9_]*\).*/\1/' | \
			grep -v '_t$$' | \
			sort -u >> $(EXPORTS)

$(CINCLUDE):	$(srcdir)/pl-itf.h $(INCLUDEDIR)
		cp $(srcdir)/pl-itf.h $(CINCLUDE)

$(STREAMH):	$(srcdir)/pl-stream.h $(INCLUDEDIR)
		cp $(srcdir)/pl-stream.h $@

$(STUBC):	$(srcdir)/pl-extend.c $(INCLUDEDIR)
		$(SED) 's/"pl-itf.h"/<SWI-Prolog.h>/' $(srcdir)/pl-extend.c > $@

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

pl-main.o:	parms.h
pl-setup.o:	parms.h
pl-wic.o:	parms.h
pl-funct.o:	$(srcdir)/pl-funct.ih
pl-atom.o:	$(srcdir)/pl-funct.ih
pl-wam.o:	pl-alloc.c pl-index.c pl-fli.c

$(srcdir)/pl-funct.ih:	$(srcdir)/ATOMS
		cd $(srcdir) ; $(AWK) -f defatom.awk < ATOMS

$(srcdir)/pl-atom.ih:	$(srcdir)/ATOMS
		cd $(srcdir) ; $(AWK) -f defatom.awk < ATOMS

pl-bite:	$(srcdir)/pl-bite.c
		$(CC) -I. -I$(srcdir) $(CFLAGS) -o $@ $(srcdir)/pl-bite.c

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

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

tags:		TAGS

TAGS:		$(SRC)
		$(ETAGS) $(SRC) $(HDR)

swipl:
		echo "." > $@
swiplbin:	
		echo ".." > $@

pl-funcs.h:	$(SRC)
		mkproto -p $(SRC) > $@

install:	dv-install

dv-install:	install-arch install-libs install-bins

install-bins:	install-arch
		-if [ ! -d $(bindir)  ];    then mkdir $(bindir);     fi
		if [ -r $(bindir)/$(PL) ]; then \
		    mv -f $(bindir)/$(PL) $(bindir)/$(PL).old; \
		fi
		for f in $(PL) chpl plld plrc; do \
		    ( cd $(bindir); rm -f $$f; ln -s ../lib/swi-prolog/bin/$(ARCH)/$$f . ); \
		done


install-arch:	idirs iruntime
		for f in $(PL) pl-bite chpl plld rc/plrc; do \
		    $(INSTALL_PROGRAM) $$f $(PLBASE)/bin/$(ARCH); \
		done

install-libs:	idirs iboot ilib iruntime iinclude iman
		$(INSTALL_DATA) $(STARTUPPATH) $(PLBASE)/boot.prc
		$(INSTALL_DATA) swipl $(PLBASE)
		$(INSTALL_DATA) swiplbin $(PLBASE)/bin/swipl
		$(INSTALL_DATA) README.bin $(PLBASE)
#		$(INSTALL_DATA) ../LICENSE $(PLBASE)
		cd $(PLBASE)/library; \
		   ../bin/$(ARCH)/$(PL) \
			-f none \
			-g make_library_index\('.'\) \
			-t halt

installdirs=	bin bin/$(ARCH) lib lib/$(ARCH) man boot library \
		include runtime runtime/$(ARCH)

iruntime:
		if [ ! -d $(PLBASE)/runtime/$(ARCH) ]; then \
			mkdir $(PLBASE)/runtime/$(ARCH); \
		fi
		if [ -f $(RUNTIME) ]; then \
			$(INSTALL_DATA) $(RUNTIME) $(PLBASE)/runtime/$(ARCH); \
		fi

idirs:
		-if [ ! -d $(prefix)/lib  ];    then mkdir $(prefix)/lib;     fi
		-if [ ! -d $(PLBASE)  ];    then mkdir $(PLBASE); 	fi
		for d in $(installdirs); do \
			if [ ! -d $(PLBASE)/$$d ]; then \
				mkdir $(PLBASE)/$$d; \
			fi; \
		done


iboot:		
		cd ../boot; \
		for f in *.pl; do $(INSTALL_DATA) $$f $(PLBASE)/boot; done
ilib:		
		cd ../library; \
		for f in *.pl MANUAL; do \
			$(INSTALL_DATA) $$f $(PLBASE)/library; \
		done

iinclude:       
		cd ../include; \
		for f in SWI-Prolog.h SWI-Stream.h stub.c; do \
		    if [ -f $$f ]; then \
			$(INSTALL_DATA) $$f $(PLBASE)/include; \
		    fi; \
		done
#		for f in SWI-Prolog.h SWI-Exports SWI-Stream.h stub.c; do \
#		if [ -d $(prefix)/include -a -w $(prefix)/include ]; then \
#		    $(INSTALL_DATA) ../include/SWI-Prolog.h $(prefix)/include; \
#		fi
		ln -s ../lib/swi-prolog/include/SWI-Prolog.h \
		      ../lib/swi-prolog/include/SWI-Stream.h \
		      $(prefix)/include

iman:
		$(INSTALL_DATA) pl.1 $(plmandir)/$(PL).$(mansec)
		$(INSTALL_DATA) $(srcdir)/chpl.1 $(plmandir)/chpl.$(mansec)
		$(INSTALL_DATA) $(srcdir)/plld.1 $(plmandir)/plld.$(mansec)
#		$(INSTALL_DATA) $(srcdir)/readline.3 $(plmandir)/readline.$(lmansec)
#		-if [ ! -d $(man_prefix) ]; then mkdir $(man_prefix); fi
#		-if [ ! -d $(mandir)  ];    then mkdir $(mandir);     fi
#		-if [ ! -d $(lmandir) ];    then mkdir $(lmandir);    fi
#		-$(INSTALL_DATA) $(plmandir)/$(PL).$(mansec) $(mandir)
#		-$(INSTALL_DATA) $(plmandir)/chpl.$(mansec) $(mandir)
#		-$(INSTALL_DATA) $(plmandir)/plld.$(mansec) $(mandir)
#		-if [ ! -r $(lmandir)/readline.$(lmansec) ]; then \
#		  $(INSTALL_DATA) $(plmandir)/readline.$(lmansec) $(lmandir); \
#		fi

#
# runtime-only environment installation
#

RTHOME=		$(prefix)/lib/rt-pl-$(PLVERSION)
RTDIRS=		$(RTHOME) $(RTHOME)/bin $(RTHOME)/lib $(RTHOME)/lib/$(ARCH) \
		$(RTHOME)/man $(RTHOME)/bin/$(ARCH)

rt-install:
		@echo "****************"
		@echo "Creating runtime environment in $(RTHOME)"
		@echo "****************"
		@for d in $(RTDIRS); do \
		    if [ ! -d $$d ]; then \
			echo mkdir $$d; \
			mkdir $$d; \
		    fi; \
		done
		$(INSTALL_PROGRAM) $(PL) $(RTHOME)/bin/$(ARCH)/pl
		$(INSTALL_PROGRAM) chpl $(RTHOME)/bin/$(ARCH)/chpl
		$(INSTALL_DATA) $(srcdir)/pl.1 $(RTHOME)/man/pl.1
		$(INSTALL_DATA) $(srcdir)/chpl.1 $(RTHOME)/man/chpl.1
		$(INSTALL_DATA) swipl $(RTHOME)/swipl
		$(INSTALL_DATA) swiplbin $(RTHOME)/bin/swipl
		$(INSTALL_DATA) $(srcdir)/README.RT $(RTHOME)
#		-cd $(bindir); rm -f plrt; ln -s $(RTHOME)/bin/$(ARCH)/pl plrt

#
# Cleanup
#

clean:
		@(cd rc && $(MAKE) clean)
		rm -f *.o a.out core *~ #* parms.h

distclean:	clean
		@(cd rc && $(MAKE) distclean)
		rm -f config.log config.cache

realclean:	clean
		rm -f $(STARTUPPATH)
		rm -f config.log config.cache
		rm -rf $(PL) pl-bite ../startup ../include ../runtime

debclean:	clean
		rm -f plld