Makefile.in 9.4 KB
Newer Older
1 2 3
# -*- Mode: Makefile; indent-tabs-mode: nil -*-
# vim: set filetype=makefile tabstop=8 shiftwidth=4 expandtab:

jjgarcia's avatar
jjgarcia committed
4
#
5
# Makefile for ECL
jjgarcia's avatar
jjgarcia committed
6 7 8
#
top_srcdir= @top_srcdir@
srcdir	= @srcdir@
9
datarootdir = @datarootdir@
10
datadir = @datadir@
11 12
mandir=@mandir@
manext=1
jjgarcia's avatar
jjgarcia committed
13 14 15 16

# Programs used by "make":
#

17
@SET_MAKE@
Daniel Kochmański's avatar
Daniel Kochmański committed
18 19 20
# CC may be either C or CXX compiler (depending on --with-cxx
# option). This compiler is used for building all contribs, modules
# and anything what goes through CMP module.
21
CC	= @ECL_CC@
Daniel Kochmański's avatar
Daniel Kochmański committed
22 23 24
# TRUE_CC is always C compiler. ECL core files (src/c/*) doesn't build
# with CXX compiler.
TRUE_CC = @CC@
25
CFLAGS	= -I. -I@true_builddir@ -I$(srcdir)/c -Iecl/gc    \
26 27
	-DECL_BUILD -DECL_API -DECL_NO_LEGACY           \
	@CPPFLAGS@ @CFLAGS@ @ECL_CFLAGS@ -c
28 29 30
LIBS	= @LIBS@
FASL_LIBS = @FASL_LIBS@
CORE_LIBS = @CORE_LIBS@
jjgarcia's avatar
jjgarcia committed
31 32
LDFLAGS	= @LDFLAGS@
RM	= @RM@
33
LN_S	= @LN_S@
jjgarcia's avatar
jjgarcia committed
34
EXE	= @EXEEXT@
35
CTAGS	= @CTAGS@
36
ETAGS	= @ETAGS@
37 38
RANLIB	= @RANLIB@
AR	= @AR@
39 40
DPP	= dpp$(EXE)
ECL_MIN = ecl_min$(EXE)
41
ECL     = ecl$(EXE)
42

jjgarcia's avatar
jjgarcia committed
43 44 45 46 47 48
# ==================== Where To Install Things ====================

# The default location for installation.  Everything is placed in
# subdirectories of this directory.  The default values for many of
# the variables below are expressed in terms of this one, so you may
# not need to change them.  This defaults to /usr/local.
49 50
prefix=@prefix@
exec_prefix=@exec_prefix@
51 52 53 54
bindir=@bindir@
libdir=@libdir@
includedir=@includedir@
ecldir=@ecldir@
jjgarcia's avatar
jjgarcia committed
55 56 57

# Programs used by "make install":
#
58
SHELL = @SHELL@
jjgarcia's avatar
jjgarcia committed
59
INSTALL	= @INSTALL@
60
INSTALL_DATA = @INSTALL_DATA@
jjgarcia's avatar
jjgarcia committed
61
INSTALL_PROGRAM = @INSTALL_PROGRAM@
62
INSTALL_SCRIPT = @INSTALL_SCRIPT@
63
INSTALL_LIBRARY = $(INSTALL_SCRIPT)
jjgarcia's avatar
jjgarcia committed
64
INSTALL_DATA = @INSTALL_DATA@
65
mkinstalldirs = $(top_srcdir)/bdwgc/install-sh -d
jjgarcia's avatar
jjgarcia committed
66 67 68

# Files

69
SUBDIRS = @SUBDIRS@
70 71 72
LIBRARIES = @LIBRARIES@
LSP_LIBRARIES = @LSP_LIBRARIES@
TARGETS = @TARGETS@
73
ECL_CMPDIR = @ECL_CMPDIR@
jjgarcia's avatar
jjgarcia committed
74

75 76 77 78 79 80 81
all: $(TARGETS) bin/ecl-config .git/tags TAGS
.PHONY: all
.SUFFIXES: .c .o .d .s

ifndef VERBOSE
.SILENT:
endif
jjgarcia's avatar
jjgarcia committed
82 83 84 85

%Makefile: $(srcdir)/%Makefile.in config.status
	./config.status

Daniel Kochmański's avatar
Daniel Kochmański committed
86
#
87 88 89
# When compiling the library itself, we have to remove the dllimport
# declarations, because the variables that they mark are in the
# in the library and can be referenced without indirection.
Daniel Kochmański's avatar
Daniel Kochmański committed
90
#
91
c/ecl/external.h: $(top_srcdir)/h/external.h
92
	test -d c/ecl || mkdir c/ecl
93
	sed 's,__declspec(dllimport),,g' $(top_srcdir)/h/external.h > $@
94

Daniel Kochmański's avatar
Daniel Kochmański committed
95 96 97
ecl/external.h: c/ecl/external.h c/ecl/external.h
	cp -rf $(srcdir)/h/*.h $(srcdir)/h/impl ecl/

Daniel Kochmański's avatar
Daniel Kochmański committed
98 99 100 101 102 103 104 105 106 107 108 109 110
bin/$(ECL): $(ECL_MIN) compile.lsp ecl/external.h build-stamp $(top_srcdir)/lsp/*.lsp $(top_srcdir)/clos/*.lsp $(top_srcdir)/*cmp/*.lsp
	if [ -f CROSS-COMPILER ]; then \
		./CROSS-COMPILER compile; \
	else \
		ECLDIR=`pwd`/ ./$(ECL_MIN) compile; \
	fi
	if [ "x@SONAME@" != "x" -a -f "@SONAME@" ]; then \
	  ( mv @SONAME@ @SONAME3@ && \
	    $(RM) -f @SONAME2@ @SONAME1@ @SONAME@ && \
	    $(LN_S) @SONAME3@ @SONAME2@ && \
	    $(LN_S) @SONAME3@ @SONAME1@ && \
	    $(LN_S) @SONAME3@ @SONAME@ ) \
	fi
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

# prerequisite libraries
libeclgc.a: libeclatomic.a
	test -d ecl/gc || mkdir ecl/gc
	test -d ecl/gc/private || mkdir ecl/gc/private
	if (echo $(SUBDIRS) | grep gc); then \
	  cd gc && $(MAKE) install && cd .. && \
	  cp -rf $(srcdir)/@ECL_GC_DIR@/include/private/*.h ecl/gc/private/ && \
	  mv libgc.a libeclgc.a; \
	fi
libeclffi.a:
	if (echo $(SUBDIRS) | grep libffi); then \
	  cd libffi && $(MAKE) install && cd .. && \
	  sed -e 's,<ffitarget,<ecl/ffitarget,' ecl/ffi.h > ecl/foo.h && \
	  rm ecl/ffi.h && mv ecl/foo.h ecl/ffi.h && \
	  mv libffi.a libeclffi.a; \
	fi
libeclatomic.a:
	if (echo $(SUBDIRS) | grep atomic); then \
	  cd atomic && $(MAKE) && $(MAKE) install && cd .. && \
	  $(RM) -rf share ecl/atomic_ops_stack.h ecl/atomic_ops_malloc.h *atomic*gpl* && \
	  mv libatomic_ops.a libeclatomic.a; \
	fi
libeclgmp.a:
	if (echo $(SUBDIRS) | grep gmp); then \
	  cd gmp && $(MAKE) install && \
	  cd .. && mv include/gmp.h ecl/ && rmdir include &&  \
	  mv ./libgmp.a ./libeclgmp.a; \
	fi

# final objects archive
Daniel Kochmański's avatar
Daniel Kochmański committed
142
libeclmin.a: libeclgmp.a libeclatomic.a libeclgc.a libeclffi.a lsp/config.lsp $(ECL_CMPDIR)/cmpdefs.lsp ecl/external.h
143
	@echo "Building $@..."
Daniel Kochmański's avatar
Daniel Kochmański committed
144
	cd c; $(MAKE)
145

Daniel Kochmański's avatar
Daniel Kochmański committed
146
$(ECL_MIN): $(LIBRARIES) .gdbinit libeclmin.a
147 148 149 150 151
	@echo "Building $@..."
	if [ -f CROSS-COMPILER ]; then \
		touch $@; \
	else \
		$(CC) $(LDFLAGS) -o $@ \
Daniel Kochmański's avatar
Daniel Kochmański committed
152
		cinit.o c/all_symbols.o \
153 154 155
		-L./ libeclmin.a \
		$(CORE_LIBS) $(FASL_LIBS) $(LIBS);\
	fi
Daniel Kochmański's avatar
Daniel Kochmański committed
156 157 158
mini_ecl: $(ECL_MIN) bare2.lsp
	(echo '#!/bin/sh'; echo './$(ECL_MIN) bare2.lsp') > $@
	chmod +x $@
159 160

clean-ecl_min:
161
	$(RM) -rf $(DPP) $(ECL_MIN) libecl*.a c/
162 163
	for i in $(srcdir)/c/*/; do mkdir -p c/`basename $$i`; done

164 165
bare2.lsp:
	echo '(load "bare")(si::top-level)' > $@
jjgarcia's avatar
jjgarcia committed
166 167 168 169

.gdbinit: $(srcdir)/util/gdbinit
	cp $(srcdir)/util/gdbinit $@

170
$(ECL_CMPDIR)/cmpdefs.lsp: $(ECL_CMPDIR)/cmpdefs.pre
jgarcia's avatar
jgarcia committed
171
	sed -e 's,@ecldir\\@,$(ecldir),g' \
172 173
	    -e 's,@libdir\\@,$(libdir),g' \
	    -e 's,@includedir\\@,$(includedir),g' < $(ECL_CMPDIR)/cmpdefs.pre > $@
174 175

# @SONAME_LDFLAGS@ expansion may contain @libdir@ on OSX
176
compile.lsp: compile.pre
177 178 179
	sed -e 's,@ecldir\\@,$(ecldir),g' \
            -e 's,@libdir\\@,$(libdir),g' < compile.pre > compile.lsp

180
bin/ecl-config: bin/ecl-config.pre
jgarcia's avatar
jgarcia committed
181
	sed -e 's,@libdir\\@,$(libdir),' \
182 183
	    -e 's,@includedir\\@,$(includedir),' \
	    -e 's,~A,$(libdir),' bin/ecl-config.pre > bin/ecl-config
184

185
build-stamp: config.status
186 187
	echo "#" `uname -a` > $@
	head -8 config.log | tail -6 >> $@
Daniel Kochmański's avatar
Daniel Kochmański committed
188

189
install:
190 191
# Here we would use the option -s but the install program in sourceforge-solaris
# is broken.
jgarcia's avatar
jgarcia committed
192
	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) \
193
	  $(DESTDIR)$(ecldir) $(DESTDIR)$(includedir) $(DESTDIR)$(includedir)/ecl
194
	for i in $(TARGETS); do \
195
	  $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir); \
196
	done
197 198 199 200 201 202
	if [ -d encodings ]; then \
	  $(mkinstalldirs) $(DESTDIR)$(ecldir)/encodings; \
	  for i in ./encodings/*; do \
	    $(INSTALL_DATA) $$i $(DESTDIR)$(ecldir)/encodings; \
	  done \
	fi
203 204 205 206 207 208 209 210
	$(mkinstalldirs) $(DESTDIR)$(includedir)/ecl
	for i in `(cd ecl && find . -type d)`; do \
	  k="$(DESTDIR)$(includedir)/ecl/$$i"; \
	  test -d "$$k" || $(mkinstalldirs) $$k; \
	done
	for i in `(cd ecl && find . -name '*.h')`; do echo $$i; \
	  $(INSTALL_DATA) ecl/$$i $(DESTDIR)$(includedir)/ecl/$$i; \
	done
211
	$(INSTALL_SCRIPT) bin/ecl-config $(DESTDIR)$(bindir)
212
	for i in build-stamp help.doc TAGS ; do \
jgarcia's avatar
jgarcia committed
213
	  $(INSTALL_DATA) $$i $(DESTDIR)$(ecldir); \
214
	done
jgarcia's avatar
jgarcia committed
215
	for i in $(LSP_LIBRARIES) $(LIBRARIES); do \
216
	  if test -s $$i ; then \
217 218
	   if echo $$i | grep dll; then \
	    $(INSTALL_LIBRARY) $$i $(DESTDIR)$(bindir); \
219 220
	   fi; \
	   $(INSTALL_LIBRARY) $$i $(DESTDIR)$(libdir); \
221
	  fi \
222
	done
223 224 225
	if [ "x@SONAME3@" != "x" -a -f "@SONAME3@" ]; then \
	  ( $(INSTALL_LIBRARY) @SONAME3@ $(DESTDIR)$(libdir) && \
	    cd $(DESTDIR)$(libdir) && $(RM) -f @SONAME2@ @SONAME1@ @SONAME@ && \
226 227 228
	    $(LN_S) @SONAME3@ @SONAME2@ && \
	    $(LN_S) @SONAME3@ @SONAME1@ && \
	    $(LN_S) @SONAME3@ @SONAME@ ) \
229
	fi
230
	$(INSTALL_PROGRAM) c/$(DPP) $(DESTDIR)$(ecldir)
231
	$(INSTALL_PROGRAM) $(ECL_MIN) $(DESTDIR)$(ecldir)
232
	for i in `cat modules`; do \
233 234 235 236
	  case $$i in \
	    *.fas) $(INSTALL_PROGRAM) $$i $(DESTDIR)$(ecldir);; \
	    *) $(INSTALL_DATA) $$i $(DESTDIR)$(ecldir);; \
	  esac \
237
	done
238
	for i in LICENSE COPYING; do \
239
	  $(INSTALL_DATA) $(top_srcdir)/../$$i $(DESTDIR)$(ecldir); \
240
	done
241
	$(MAKE) -C doc install
242

243
flatinstall: build-stamp
jgarcia's avatar
jgarcia committed
244
	$(MAKE) DESTDIR=$(DESTDIR) bindir=$(prefix) libdir=$(prefix) \
245
	  includedir=$(prefix) ecldir=$(prefix) install
jjgarcia's avatar
jjgarcia committed
246

jjgarcia's avatar
jjgarcia committed
247
uninstall:
248 249 250
	for i in $(ECL) ecl-config; do $(RM) $(DESTDIR)$(bindir)/$$i; done
	for i in $(LSP_LIBRARIES) $(LIBRARIES) LICENSE LGPL \
			@SONAME@ @SONAME1@ @SONAME2@ @SONAME3@; do \
jgarcia's avatar
jgarcia committed
251 252
	  $(RM) $(DESTDIR)$(libdir)/$$i || : ; \
	done
253
	$(MAKE) -C doc uninstall
254
	$(RM) -r $(DESTDIR)$(includedir)/ecl $(DESTDIR)$(ecldir)
jjgarcia's avatar
jjgarcia committed
255

256 257
clean: mostlyclean
	$(RM) -r *
258
mostlyclean: clean-ecl_min clean_lisp
259
	(cd tests && $(MAKE) clean)
260
	-for i in $(SUBDIRS); do (test -d $$i && cd $$i && $(MAKE) clean); done
261
	$(RM) -r $(ECL_MIN) $(ECL) help.doc core a.out TAGS
jjgarcia's avatar
jjgarcia committed
262
	$(RM) config.version config.log config.cache
263
	$(RM) *.c *.o *.a *.eclh *.h *.data *.fas *.dat *.la *.so *.dylib
jjgarcia's avatar
jjgarcia committed
264
clean_lisp:
265
	-$(RM) help.doc $(TARGETS)
Daniel Kochmański's avatar
Daniel Kochmański committed
266
	-for i in lsp cmp clos tk ext; do $(RM) lib$$i.a $$i/?*.{o,eclh,data,c,sdat,h,fas}; done
jjgarcia's avatar
jjgarcia committed
267 268
distclean: clean
realclean: distclean
269 270 271 272 273 274
#
# Rebuild ECL using recent changes and compare
#
test_changes:
	test -d old || mkdir old
	cp -rf lsp clos cmp old/
275
	$(MAKE) clean_lisp; $(MAKE) -C c clean; $(RM) -f $(ECL)
276
	$(MAKE)
jjgarcia's avatar
jjgarcia committed
277
	for i in lsp clos cmp; do diff --exclude=\*.o $$i old/$$i; done
278
#
279 280 281
# Run test suite
#
check:
282 283
	cd tests && $(MAKE) clean && $(MAKE) check TESTS="$(TESTS)"

284
#
285 286 287 288 289
# Rebuild ECL using its own image and compare. Does not work
# right now.
#
selfbuild:
	exit 2
290
	test -d stage2 || mkdir stage2
jjgarcia's avatar
jjgarcia committed
291
	cp -rf lsp clos cmp stage2
Daniel Kochmański's avatar
Daniel Kochmański committed
292
	-for i in lsp cmp clos tk; do test -f lib$$i.a && mv lib$$i.a stage2; done
293
	$(MAKE) clean_lisp
294
	./ecl compile
Daniel Kochmański's avatar
Daniel Kochmański committed
295
	-for i in lsp clos cmp tk; do test -d $$i && diff --exclude=\*.o $$i stage2/$$i; done | less
296

297
.git/tags:
298
	( cd $(srcdir)/../.git && test "x$(CTAGS)" != "x" && $(CTAGS) -f tags -R --langmap=c:+.d ../src || false) || echo "tags generation failed, but this does not break the build."
299 300 301 302

# Make sure to also include *.d files; and match DPP's idiosyncracies
# like "@si::foo" and "@(defun si::foo".  This rule is allowed to fail
# when etags does not exist.
303
TAGS:
304
	-if test "x$(ETAGS)" != "x"; then \
305
	srcfiles=`find $(srcdir)/c $(srcdir)/h -name '*.[chd]'` && \
306 307
	$(ETAGS) --language=c    -o $@ $$srcfiles && \
	$(ETAGS) --language=none -o $@ --append \
308 309
	      --regex='/@\([-:*a-zA-z]+\)/\1/' \
	      --regex='/@(defun \([-:*a-zA-z]+\)/\1/' \
310 311
	      $$srcfiles; \
	fi
312
	touch $@