32dc335626e583a964c4e531d82ae14ac2d85243
[sxemacs] / src / Makefile.am
1 ## SXEmacs Makefile.am
2
3 ## Copyright (C) 2007 Steve Youngs
4
5 ## This file is part of SXEmacs.
6
7 ## SXEmacs is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation, either version 3 of the License, or
10 ## (at your option) any later version.
11
12 ## SXEmacs is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ## GNU General Public License for more details.
16
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 ## Process this file with automake to produce Makefile.in
21
22 # Help the Developers and yourself. Just use the C locale and settings
23 # for the compilation. They can still be overriden by make LANG=<whatever>
24 # but that is general a not very good idea
25 LANG=C
26 LC_ALL=C
27
28 builddir = @builddir@
29 srcdir = @srcdir@
30 top_builddir = @top_builddir@
31 top_build_prefix = $(top_builddir)/
32 top_srcdir = @top_srcdir@
33 abs_builddir = @abs_builddir@
34 abs_top_builddir = @abs_top_builddir@
35 abs_top_srcdir = @abs_top_srcdir@
36
37 AM_CFLAGS = -Demacs $(OPENSSL_CFLAGS) -DUSE_SXEMACS_CONFIG_H -DXTSTRINGDEFINES
38 AM_CPPFLAGS = -I$(srcdir) -I$(builddir) -I$(top_builddir) $(c_switch_system) $(LTDLINCL)
39 AM_LDFLAGS = $(OPENSSL_LDFLAGS) $(ENT_LDFLAGS) $(LIBLTDL)
40
41 headerdir = $(includedir)/$(instvarsepdir)
42 sheaderdir = $(headerdir)/s
43 mheaderdir = $(headerdir)/m
44 archlibdir = ${libdir}/${instvardir}/${configuration}
45
46 sxesrcdir = $(sxe_srcdir)/src
47 bldsrcdir = $(builddir)
48 sxelispdir = $(top_srcdir)/lisp
49 bldlispdir = $(top_builddir)/lisp
50 sxelwlibdir = $(top_srcdir)/src/ui/lwlib
51 bldlwlibdir = $(top_builddir)/src/ui/lwlib
52 sxeemoddir = $(top_srcdir)/modules
53 bldemoddir = $(top_builddir)/modules
54 sxelibsrcdir = $(abs_top_srcdir)/lib-src
55 bldlibsrcdir = $(abs_top_builddir)/lib-src
56
57 ETAGS = $(top_builddir)/lib-src/etags
58 TAGS_DEPENDENCIES = $(ETAGS)
59
60 bin_PROGRAMS = sxemacs
61 bin_SCRIPTS = sxemacs.dmp
62 archlib_DATA = config.values DOC
63
64 pdumplibs = 
65 noinst_pdumplibs=
66 nodumplibs=
67 noinst_nodumplibs=
68 pdump_ldadd =
69
70 SUBDIRS=
71 sxe_subdirs=
72
73 pdumplibs        += libsxecore.a 
74 noinst_pdumplibs += libsxecore.a 
75 pdump_ldadd      += $(libsxecore_a_ldflags) 
76
77 # Inverse order of dependency for order dependendant
78 # linkers...
79
80 if NEED_LIBSXEUIGTK
81 pdumplibs += $(builddir)/ui/Gtk/libsxeuiGtk.a 
82 # sxe_subdirs += ui
83 endif
84
85 if NEED_LIBSXEUIX11
86 pdumplibs += $(builddir)/ui/X11/libsxeuiX11.a 
87 # sxe_subdirs += ui
88 endif
89
90 if NEED_LIBSXEUITTY
91 pdumplibs += $(builddir)/ui/TTY/libsxeuiTTY.a 
92 # sxe_subdirs += ui
93 endif
94
95 pdumplibs += $(builddir)/ui/libsxeui.a 
96 # pdump_ldadd +=
97 sxe_subdirs += ui
98
99 pdumplibs += $(builddir)/events/libsxeevents.a 
100 # pdump_ldadd +=
101 sxe_subdirs += events
102
103 # @FIXME@ Should probably be conditional on whether we really have ent
104 # things or not :-)
105 pdumplibs += $(builddir)/ent/libent.a
106 pdump_ldadd += $(ENT_LIBS)
107 sxe_subdirs += ent
108
109 # @FIXME@ Should probably be conditional on whether we really have media
110 # things or not :-)
111 pdumplibs += $(builddir)/media/libmm.a
112 pdump_ldadd += $(MM_LIBS)
113 sxe_subdirs += media
114
115
116 pdumplibs   += $(builddir)/mem/libsxemem.a
117 sxe_subdirs += mem
118 pdump_ldadd += $(libsxemem_a_ldflags)
119
120 if NEED_LIBMULE
121 pdumplibs += $(builddir)/mule/libmule.a
122 # pdump_ldadd +=
123 sxe_subdirs += mule
124 endif
125
126 if NEED_LIBSXEDB
127 pdumplibs += $(builddir)/database/libsxedb.a
128 pdump_ldadd += $(DB_LDFLAGS) $(DB_LIBS)
129 sxe_subdirs += database
130 endif
131
132 nodumplibs += libcruft.a
133 noinst_nodumplibs += libcruft.a
134 if USE_MEMALLOC
135 nodumplibs  += $(builddir)/mem/libmemalloc.a
136 # No need to add
137 # sxe_subdirs += mem
138 # because libsxemem already is there
139 endif
140 if DESCEND_LWLIB
141 nodumplibs += $(builddir)/ui/X11/libsxeX.a
142 endif
143
144 SUBDIRS += $(sxe_subdirs)
145
146 noinst_LIBRARIES = $(noinst_pdumplibs) $(noinst_nodumplibs)
147
148
149 acgen_headers = config.h sxe-paths.h
150 header_HEADERS = $(acgen_headers)               \
151         $(libsxecore_a_headers)                 \
152         emodules-ng.h
153
154 sheader_HEADERS = $(srcdir)/s/*.h
155 mheader_HEADERS = $(srcdir)/m/*.h
156
157 BUILT_SOURCES = sheap-adjust.h dump-id.c
158 EXTRA_DIST = sheap-adjust.h
159 CLEANFILES = core* stage1 stage2 *.stamp $(BUILT_SOURCES) \
160         sxemacs.dmp DOC config.values
161
162 ## binaries
163 sxemacs_SOURCES = $(header_HEADERS)
164 ##$(LOCK_OBJ) $(RTC_patch_objs)
165 EXTRA_sxemacs_SOURCES = lastfile.c profile.c sheap.c pre-crt0.c ecrt0.c
166 sxemacs_CPPFLAGS = $(AM_CPPFLAGS)
167 sxemacs_lddep = $(start_files) $(pdumplibs) $(nodumplibs)
168 if WITH_PDUMP
169 sxemacs_lddep += dump-id.o
170 endif
171 if BUILD_SHEAP
172 sxemacs_lddep += sheap.o
173 endif
174 if HAVE_SETITIMER
175 sxemacs_lddep += profile.o
176 endif
177 sxemacs_lddep += $(statmod_archives)
178 sxemacs_lddep += lastfile.o
179 if DESCEND_LWLIB
180 sxemacs_lddep += $(bldlwlibdir)/libsxelw-Xt.la
181 endif
182 sxemacs_LDFLAGS = $(AM_LDFLAGS) $(start_flags)
183 ## hm, rpath is gross, says njsf
184 #sxemacs_LDFLAGS += -Wl,-rpath,$(abs_top_builddir)/lwlib/$(LT_OBJDIR)
185 sxemacs_LDADD = $(sxemacs_lddep) $(OPENSSL_LIBS)
186 sxemacs_LDADD += $(sxemacs_ldadd)               \
187                  $(ld_switch_all) $(ld_libs_all)\
188                  $(lib_gcc) $(FFI_LIBS)         \
189                  $(LIBLTDL)
190 if WITH_BDWGC
191 sxemacs_CPPFLAGS += $(BDWGC_CPPFLAGS)
192 sxemacs_LDFLAGS += $(BDWGC_LDFLAGS) $(BDWGC_LIBS)
193 endif
194 sxemacs_DEPENDENCIES = $(sxemacs_lddep)
195
196 all_sources =
197
198 ## library stuff
199 libsxecore_a_headers =                                                  \
200         backtrace.h bloom.h broken-sun.h buffer.h dllist.h              \
201         bufslots.h bytecode.h casetab.h category.h                      \
202         chartab.h lisp-disunion.h                                       \
203         lisp.h lrecord.h lstream.h commands.h dict.h dumper.h elhash.h  \
204         dynacat.h extents.h general-slots.h hash.h iso-wide.h           \
205         line-number.h macros.h map.h mem-limits.h ndir.h opaque.h       \
206         process.h                                                       \
207         procimpl.h rangetab.h regex.h semaphore.h seq.h skiplist.h      \
208         specifier.h symeval.h symsinit.h syntax.h syscommctrl.h         \
209         sysdep.h sysdir.h sysfile.h sysproc.h syspwd.h                  \
210         syssignal.h systime.h syswait.h \
211         sxemacs.h
212 libsxecore_a_sources =                                                  \
213         abbrev.c alloc.c bloom.c buffer.c bytecode.c                    \
214         callint.c callproc.c casefiddle.c casetab.c category.c          \
215         chartab.c                                                       \
216         cmdloop.c cmds.c data.c dict.c dired.c dllist.c doc.c doprnt.c  \
217         dynarr.c editfns.c elhash.c emacs.c eval.c dynacat.c            \
218         extents.c fileio.c filemode.c fns.c general.c hash.c indent.c   \
219         intl.c line-number.c lread.c lstream.c macros.c map.c marker.c  \
220         md5.c                                                           \
221         objects.c opaque.c print.c process.c process-unix.c rangetab.c  \
222         regex.c search.c semaphore.c seq.c signal.c skiplist.c          \
223         strftime.c symbols.c syntax.c sysdep.c undo.c
224 libsxecore_a_SOURCES = $(libsxecore_a_headers) $(libsxecore_a_sources)
225 EXTRA_libsxecore_a_SOURCES = dumper.c realpath.c
226 libsxecore_a_CPPFLAGS = $(AM_CPPFLAGS) $(X_CFLAGS)
227 libsxecore_a_LIBADD = $(libsxecore_objs)
228 libsxecore_a_DEPENDENCIES = $(libsxecore_a_LIBADD)
229 all_sources += $(libsxecore_a_sources) $(libsxecore_objs:.o=.c)
230
231 libcruft_a_headers = debug.h effi.h emodules-ng.h openssl.h
232 libcruft_a_sources =
233 libcruft_a_SOURCES = $(libcruft_a_headers) $(libcruft_a_sources)
234 EXTRA_libcruft_a_SOURCES =                                              \
235         alloca.c debug.c effi.c emodules-ng.c                           \
236         filelock.c getloadavg.c inline.c openssl.c strcat.c tests.c
237 libcruft_a_CPPFLAGS =                                                   \
238         $(AM_CPPFLAGS) $(DB_CPPFLAGS) $(FFI_CPPFLAGS) $(X_CFLAGS)
239 libcruft_a_LIBADD = $(libcruft_objs)
240 libcruft_a_DEPENDENCIES = $(libcruft_a_LIBADD)
241 all_sources += $(libcruft_a_sources) $(extra_objs:.o=.c)
242
243
244 ### custom rules
245 SXEMACS = $(bldsrcdir)/sxemacs
246 AALFILE = $(bldlispdir)/auto-autoloads.el
247 AALCFILE = $(bldlispdir)/auto-autoloads.elc
248 BITCH = $(SXEMACS) -batch
249 SXE_DYLD_PATH = $(bldsrcdir):$(bldsrcdir)/$(LT_OBJDIR):$(bldlwlibdir):$(bldlwlibdir)/$(LT_OBJDIR):$(DESTDIR)$(libdir)
250 BATCHENV = DYLD_LIBRARY_PATH=$(SXE_DYLD_PATH):$$DYLD_LIBRARY_PATH:$(DYLD_LIBRARY_PATH) \
251         LD_LIBRARY_PATH=$(SXE_DYLD_PATH):$$LD_LIBRARY_PATH:$(LD_LIBRARY_PATH) \
252         SHLIB_PATH=$(SXE_DYLD_PATH):$$SHLIB_PATH:$(SHLIB_PATH)
253 BITCHENV = $(BATCHENV) \
254         EMACSDEBUGPATHS=1 EMACSPACKAGEPATH= \
255         SOURCE_TREE_ROOT=$(sxe_srcdir) \
256         BUILD_TREE_ROOT=$(sxe_blddir)
257 BATCH = $(BITCHENV) $(BITCH)
258 BATCHGDB = $(BITCHENV) gdb --args $(BITCH)
259 RM = rm -f
260 CROSSMAKE = (cd $$(dirname $@) && $(MAKE) $(AM_MAKEFLAGS) $$(basename $@))
261
262
263 sheap-adjust.h:
264         @echo "Resetting \`src/sheap-adjust.h'."; \
265         (echo "/*       Do not edit this file!" ; \
266          echo "         Automatically generated by SXEmacs */" ; \
267          echo "#define SHEAP_ADJUSTMENT 0") > $@
268
269 dump-id.c: $(bldlibsrcdir)/make-dump-id
270         $(bldlibsrcdir)/make-dump-id
271
272 #$(bldlispdir)/auto-autoloads.el \
273 #$(bldlispdir)/auto-autoloads.elc \
274 #$(bldlispdir)/update-elc.FORCE.stamp \
275 #$(bldlispdir)/update-elc.stamp: $(SXEMACS)
276 #       echo $(CROSSMAKE)
277 #
278 #$(emodblddir)/auto-autoloads.el:
279 #       echo $(CROSSMAKE)
280
281 DOC: $(SXEMACS) $(bldlispdir)/auto.stamp
282         if test -e $(bldlispdir)/auto.stamp; then \
283                 $(BATCH) -nd  -l $(sxelispdir)/make-docfile.el -- \
284                         -o $(bldsrcdir)/DOC -d $(sxesrcdir) \
285                         -i $(sxe_srcdir)/site-packages \
286                         $(sxesrcdir)/*.c \
287                         $(sxesrcdir)/*/*.c \
288                         $(sxesrcdir)/*/*/*.c \
289                         $(sxeemoddir)/*/*.c; \
290                 touch $@; \
291         fi
292
293 ## The `grep -v 'lt_lt_'' here is just a quick and dirty bandaid fix,
294 ## pure and simple.  These are duplicate entries that cause problems
295 ## for #'config-value.  The real fix lies in #'config-values-hash-table
296 ## or maybe in libtool somewhere. --SY.
297 EGREP = @EGREP@
298 config.values: config.h
299         @echo "Building config.values ..."
300         @echo ";;; Do not edit this file!" > $@
301         grep '^[^ ]*='\''.*'\''$$\|^#define ' $(top_builddir)/config.log | \
302                 grep -v 'lt_lt_' | \
303                 sed \
304                 -e 's/='\''\(.*\)'\''/ "\1"/g' \
305                 -e 's/^#define //' \
306                 -e '/^[^ ]*(/d' \
307                 -e 's/^\([^ ]*\) \([^"].*[^"]\)$$/\1 "\2"/' \
308                 -e 's/^\([^ ]*\) "\([0-9]*\)"$$/\1 \2/' \
309                 -e 's/^\(HAVE\|WITH\|ERROR\|LWLIB\)_\([^ ]*\) 1$$/\1_\2 t/' \
310                 -e 's/^\([^ ]*\) *$$/\1 ""/' \
311                 -e 's/\\"/\\\\"/g' \
312                 | sort | uniq >> $@
313 ## this is roughly what we do above
314 ## transform foo=bar to foo "bar"
315 ## remove #define's
316 ## foo <anything but a single digit> -> foo "<anything>"
317 ## foo "1234567890" -> foo 1234567890 (numbers != strings)
318 ## HAVE_foo 1 -> HAVE_foo t (<- t is more useful in elisp)
319 ## `foo ' -> `foo ""'
320
321 ### DUMP PHASE
322 ## another idea would be to create the real dump file upon installation,
323 ## as in use the install-exec-hook and create a new file from the newly
324 ## relinked sxemacs
325 ## one day (when SXE is linked with its own shared libraries) we HAVE to
326 ## go that way but at the moment it's okay the way it is
327 SXEDMP_FILEEXT=dmp
328 SXEMACS_FILENAME=sxemacs
329 SXEDMP_FILENAME=$(SXEMACS_FILENAME).$(SXEDMP_FILEEXT)
330
331 sxemacs.dmp: $(SXEMACS) $(archlib_DATA) $(bldlispdir)/update-elc.stamp
332         if test -e "$(bldlispdir)/update-elc.stamp"; then \
333                 $(BITCHENV) $(SXEMACS) -nd -batch \
334                                 -l $(sxelispdir)/loadup.el --dump $@; \
335                 if test -e "$(LT_OBJDIR)/$(LT_CONVENIENCE_PREFIX)sxemacs"; then \
336                         (cd $(LT_OBJDIR); \
337                         $(LN_S) -f "../$@" "$(LT_CONVENIENCE_PREFIX)$@"); \
338                 fi; \
339                 if test -e "$(LT_OBJDIR)/sxemacs"; then \
340                         (cd $(LT_OBJDIR); \
341                         $(LN_S) -f ../$@ $@); \
342                 fi; \
343                 $(BITCHENV) \
344                 SOURCE_TREE_ROOT= BUILD_TREE_ROOT= \
345                         $(BITCH) -f list-load-path-shadows; \
346         fi
347
348 ## alibi targets
349 $(bldlispdir)/update-elc.stamp $(bldlispdir)/auto.stamp:
350         :
351
352 SXE_SHOW_DUMP = $$($(BITCHENV) $(DESTDIR)$(bindir)/sxemacs -sd)
353
354 ## improve me, make me (the dump file) independent from the binary
355 install-exec-hook:
356         (cd $(DESTDIR)$(bindir) && $(RM) sxemacs.dmp)
357         (cd $(abs_builddir); \
358         $(BITCHENV) $(DESTDIR)$(bindir)/sxemacs -nd -batch \
359                 -l $(sxelispdir)/loadup.el \
360                 --dump $(DESTDIR)$(bindir)/sxemacs-$(old_version)-$(SXE_SHOW_DUMP).dmp)
361         (cd $(DESTDIR)$(bindir) && \
362                 $(LN_S) sxemacs-$(old_version)-$(SXE_SHOW_DUMP).dmp sxemacs.dmp)
363
364
365 ## someone who wants to use this actually needs repeat the fuss above
366 sxemacs.dmp.gdb: $(SXEMACS) $(AALFILE) \
367                 $(bldlispdir)/update-elc.stamp \
368                 $(archlib_DATA) DOC config.values
369         $(RM) $@
370         $(BATCHGDB) -l $(sxelispdir)/loadup.el dump
371         SOURCE_TREE_ROOT= BUILD_TREE_ROOT= \
372                 $(BITCH) -f list-load-path-shadows
373
374
375 #stage1: $(bin_PROGRAMS)
376 #       @touch $@
377 #
378 #stage2: stage1 $(DUMP_TARGET)
379 #       @touch $@
380 #
381 #all: stage1 stage2
382
383
384 # Help the SXEmacs developers get nice post-processed source files
385
386 ## Create preprocessor output (debugging purposes only)
387 .c.i:
388         $(COMPILE) -E -o $@ $<
389
390 ## Create assembler output (debugging purposes only)
391 .c.s:
392         $(COMPILE) -S -c $(cflags) $<