Fix permissions handling (CVE-2010-0825).
[emacs.git] / lib-src / Makefile.in
blob0353c4412fb723eae7a4d22f894e45f1c9b8fb10
1 # Makefile for lib-src subdirectory in GNU Emacs.
2 # Copyright (C) 1985, 1987, 1988, 1993, 1994, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5 # This file is part of GNU Emacs.
7 # GNU Emacs 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.
12 # GNU Emacs 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.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21 # Avoid trouble on systems where the `SHELL' variable might be
22 # inherited from the environment.
23 SHELL = /bin/sh
25 # Following ../lisp/Makefile.in.
26 EMACS = ../src/emacs
27 EMACSOPT = -batch --no-site-file --multibyte
29 # ==================== Things `configure' will edit ====================
31 CC=@CC@
32 CFLAGS=@CFLAGS@
33 version=@version@
34 configuration=@configuration@
35 EXEEXT=@EXEEXT@
37 # Program name transformation.
38 TRANSFORM = @program_transform_name@
40 # ==================== Where To Install Things ====================
42 # The default location for installation. Everything is placed in
43 # subdirectories of this directory. The default values for many of
44 # the variables below are expressed in terms of this one, so you may
45 # not need to change them. This is set with the --prefix option to
46 # `../configure'.
47 prefix=@prefix@
49 # Like `prefix', but used for architecture-specific files. This is
50 # set with the --exec-prefix option to `../configure'.
51 exec_prefix=@exec_prefix@
53 # Where to install Emacs and other binaries that people will want to
54 # run directly (like etags). This is set with the --bindir option
55 # to `../configure'.
56 bindir=@bindir@
58 # Where to install and expect executable files to be run by Emacs
59 # rather than directly by users, and other architecture-dependent
60 # data. ${archlibdir} is usually below this. This is set with the
61 # --libexecdir option to `../configure'.
62 libexecdir=@libexecdir@
64 # Directory for local state files for all programs.
65 localstatedir=@localstatedir@
67 # Where to find the source code. This is set by the configure
68 # script's `--srcdir' option. However, the value of ${srcdir} in
69 # this makefile is not identical to what was specified with --srcdir,
70 # since the variable here has `/lib-src' added at the end.
72 # We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
73 srcdir=@srcdir@
74 VPATH=@srcdir@
76 # The top-level source directory, also set by configure.
77 top_srcdir=@top_srcdir@
79 # ==================== Emacs-specific directories ====================
81 # These variables hold the values Emacs will actually use. They are
82 # based on the values of the standard Make variables above.
84 # Where to put executables to be run by Emacs rather than the user.
85 # This path usually includes the Emacs version and configuration name,
86 # so that multiple configurations for multiple versions of Emacs may
87 # be installed at once. This can be set with the --archlibdir option
88 # to `../configure'.
89 archlibdir=@archlibdir@
91 gamedir=@gamedir@
92 gameuser=@gameuser@
94 # ==================== Utility Programs for the Build =================
96 # ../configure figures out the correct values for these.
97 INSTALL = @INSTALL@
98 INSTALL_PROGRAM = @INSTALL_PROGRAM@
99 INSTALL_DATA = @INSTALL_DATA@
100 INSTALL_SCRIPT = @INSTALL_SCRIPT@
101 # By default, we uphold the dignity of our programs.
102 INSTALL_STRIP =
104 # ========================== Lists of Files ===========================
106 # Things that a user might actually run,
107 # which should be installed in bindir.
108 INSTALLABLES = etags${EXEEXT} ctags${EXEEXT} emacsclient${EXEEXT} b2m${EXEEXT} ebrowse${EXEEXT} @LIB_SRC_EXTRA_INSTALLABLES@
109 INSTALLABLE_SCRIPTS = rcs-checkin grep-changelog
111 # Things that Emacs runs internally, or during the build process,
112 # which should not be installed in bindir.
113 UTILITIES= profile${EXEEXT} digest-doc${EXEEXT} sorted-doc${EXEEXT} \
114 movemail${EXEEXT} fakemail${EXEEXT} \
115 hexl${EXEEXT} update-game-score${EXEEXT}
117 DONT_INSTALL= test-distrib${EXEEXT} make-docfile${EXEEXT}
119 # Like UTILITIES, but they're not system-dependent, and should not be
120 # deleted by the distclean target.
121 SCRIPTS= rcs2log vcdiff
123 EXECUTABLES= ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}
125 # Additional -D flags for movemail (add to MOVE_FLAGS if desired):
126 # MAIL_USE_POP Support mail retrieval from a POP mailbox.
127 # MAIL_USE_MMDF Support MMDF mailboxes.
128 # MAIL_USE_FLOCK Use flock for file locking (see the comments
129 # about locking in movemail.c)
130 # MAIL_UNLINK_SPOOL Unlink the user's spool mailbox after reading
131 # it (instead of just emptying it).
132 # KERBEROS Support Kerberized POP.
133 # KRB5 Support Kerberos Version 5 pop instead of
134 # Version 4 (define this in addition to
135 # KERBEROS).
136 # HESIOD Support Hesiod lookups of user mailboxes.
137 # MAILHOST A string, the host name of the default POP
138 # mail host for the site.
139 MOVE_FLAGS=
141 # ========================== start of cpp stuff =======================
142 /* From here on, comments must be done in C syntax. */
144 #define THIS_IS_MAKEFILE
145 #define NOT_C_CODE
146 #include "../src/config.h"
148 /* Some s/SYSTEM.h files define this to request special libraries. */
149 #ifndef LIBS_SYSTEM
150 #define LIBS_SYSTEM
151 #endif
153 /* Some m/MACHINE.h files define this to request special libraries. */
154 #ifndef LIBS_MACHINE
155 #define LIBS_MACHINE
156 #endif
158 #ifndef C_SWITCH_SYSTEM
159 #define C_SWITCH_SYSTEM
160 #endif
162 #ifndef C_SWITCH_MACHINE
163 #define C_SWITCH_MACHINE
164 #endif
166 #undef MOVEMAIL_NEEDS_BLESSING
167 #ifndef MAIL_USE_FLOCK
168 #ifndef MAIL_USE_LOCKF
169 #define MOVEMAIL_NEEDS_BLESSING
170 #endif
171 #endif
173 #ifdef MOVEMAIL_NEEDS_BLESSING
174 #define BLESSMAIL blessmail
175 #else
176 #define BLESSMAIL
177 #endif
179 #ifdef KERBEROS
180 # ifdef HAVE_LIBKRB
181 KRB4LIB = -lkrb
182 # else
183 # ifdef HAVE_LIBKRB4
184 KRB4LIB = -lkrb4
185 # endif
186 # endif
187 # ifdef HAVE_LIBDES
188 DESLIB = -ldes
189 # else
190 # ifdef HAVE_LIBDES425
191 DESLIB = -ldes425
192 # endif
193 # endif
194 # ifdef HAVE_LIBKRB5
195 KRB5LIB = -lkrb5
196 # endif
197 # ifdef HAVE_LIBK5CRYPTO
198 CRYPTOLIB = -lk5crypto
199 # else
200 # ifdef HAVE_LIBCRYPTO
201 CRYPTOLIB = -lcrypto
202 # endif
203 # endif
204 # ifdef HAVE_LIBCOM_ERR
205 COM_ERRLIB = -lcom_err
206 # endif
207 #endif /* KERBEROS */
209 /* If HESIOD is defined, set this to "-lhesiod". */
210 #ifdef HAVE_LIBHESIOD
211 # ifdef HAVE_LIBRESOLV
212 HESIODLIB= -lhesiod -lresolv
213 # else
214 HESIODLIB= -lhesiod
215 # endif
216 #endif
218 LIBS_MOVE=$(KRB4LIB) $(DESLIB) $(KRB5LIB) $(CRYPTOLIB) $(COM_ERRLIB) $(HESIODLIB)
220 #ifdef HAVE_LIBLOCKFILE
221 LIBS_MAIL=-llockfile
222 #else
223 #ifdef HAVE_LIBMAIL
224 LIBS_MAIL=-lmail
225 #endif
226 #endif
228 LOADLIBES=LIBS_SYSTEM LIBS_MACHINE
230 /* We need to #define emacs to get the right versions of some files.
231 Some other files - those shared with other GNU utilities - need
232 HAVE_CONFIG_H #defined before they know they can take advantage of
233 the information in ../src/config.h. */
234 ALL_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
235 -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CPPFLAGS} ${CFLAGS}
236 LINK_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
237 -I. -I../src -I${srcdir} -I${srcdir}/../src ${LDFLAGS} ${CFLAGS}
238 CPP_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
239 -I. -I../src -I${srcdir} -I${srcdir}/../src ${CPPFLAGS} ${CFLAGS}
240 /* This was all of CPP_CFLAGS except -Demacs.
241 Now that -Demacs has been deleted from CPP_CFLAGS,
242 this is actually the same as CPP_CFLAGS, but let\'s not delete it yet. */
243 BASE_CFLAGS = C_SWITCH_SYSTEM C_SWITCH_MACHINE -DHAVE_CONFIG_H \
244 -I. -I../src -I${srcdir} -I${srcdir}/../src ${CPPFLAGS} ${CFLAGS}
246 .SUFFIXES: .m
248 /* This is the default compilation command.
249 But we should never rely on it, because some make version
250 failed to find it for getopt.o.
251 Using an explicit command made it work. */
252 .c.o:
253 ${CC} -c ${CPP_CFLAGS} $<
255 .m.o:
256 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
258 all: ${DONT_INSTALL} ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}
260 /* These targets copy the scripts into the build directory
261 so that they can be run from there in an uninstalled Emacs.
262 The "-" is prepended because some versions of cp barf when
263 srcdir is the current directory, and thus the file will be
264 copied into itself. */
265 rcs2log: $(srcdir)/rcs2log
266 -cp -p $(srcdir)/rcs2log rcs2log
268 rcs-checkin: $(srcdir)/rcs-checkin
269 -cp -p $(srcdir)/rcs-checkin rcs-checkin
271 grep-changelog: $(srcdir)/grep-changelog
272 -cp -p $(srcdir)/grep-changelog grep-changelog
274 vcdiff: $(srcdir)/vcdiff
275 -cp -p $(srcdir)/vcdiff vcdiff
277 #ifdef MOVEMAIL_NEEDS_BLESSING
278 blessmail:
279 $(EMACS) $(EMACSOPT) -l $(srcdir)/../lisp/mail/blessmail.el
280 chmod +x blessmail
281 #endif
283 maybe-blessmail: BLESSMAIL
284 #ifdef MOVEMAIL_NEEDS_BLESSING
285 /* Don\'t charge ahead and do it! Let the installer decide.
286 ./blessmail $(DESTDIR)${archlibdir}/movemail${EXEEXT} */
287 @if [ `wc -l <blessmail` != 2 ] ; then \
288 dir=`sed -n -e 's/echo mail directory = \(.*\)/\1/p' blessmail`; \
289 echo Assuming $$dir is really the mail spool directory, you should; \
290 echo run lib-src/blessmail $(DESTDIR)${archlibdir}/movemail${EXEEXT}; \
291 echo as root, to give movemail${EXEEXT} appropriate permissions.; \
292 echo Do that after running make install.; \
294 #endif
296 /* Install the internal utilities. Until they are installed, we can
297 just run them directly from lib-src. */
298 $(DESTDIR)${archlibdir}: all
299 @echo
300 @echo "Installing utilities run internally by Emacs."
301 umask 022; $(top_srcdir)/mkinstalldirs $(DESTDIR)${archlibdir}
302 if [ `(cd $(DESTDIR)${archlibdir} && /bin/pwd)` != `/bin/pwd` ]; then \
303 for file in ${UTILITIES}; do \
304 $(INSTALL_PROGRAM) $(INSTALL_STRIP) $$file $(DESTDIR)${archlibdir}/$$file ; \
305 done ; \
307 umask 022; $(top_srcdir)/mkinstalldirs $(DESTDIR)${gamedir}; \
308 touch $(DESTDIR)${gamedir}/snake-scores; \
309 touch $(DESTDIR)${gamedir}/tetris-scores
310 /* If the following commands fail, that is not a big deal.
311 update-game-score will detect at runtime that it is not setuid,
312 and handle things accordingly. */
313 -if chown ${gameuser} $(DESTDIR)${archlibdir}/update-game-score && chmod u+s $(DESTDIR)${archlibdir}/update-game-score; then \
314 chown ${gameuser} $(DESTDIR)${gamedir}; \
315 chmod u=rwx,g=rwx,o=rx $(DESTDIR)${gamedir}; \
317 if [ `(cd $(DESTDIR)${archlibdir} && /bin/pwd)` \
318 != `(cd ${srcdir} && /bin/pwd)` ]; then \
319 for file in ${SCRIPTS}; do \
320 $(INSTALL_SCRIPT) ${srcdir}/$$file $(DESTDIR)${archlibdir}/$$file; \
321 done ; \
324 install: $(DESTDIR)${archlibdir}
325 @echo
326 @echo "Installing utilities for users to run."
327 for file in ${INSTALLABLES} ; do \
328 $(INSTALL_PROGRAM) $(INSTALL_STRIP) $${file} $(DESTDIR)${bindir}/`echo $${file} | sed '$(TRANSFORM)'` ; \
329 chmod a+rx $(DESTDIR)${bindir}/`echo $${file} | sed '$(TRANSFORM)'`; \
330 done
331 for file in ${INSTALLABLE_SCRIPTS} ; do \
332 $(INSTALL_SCRIPT) ${srcdir}/$${file} $(DESTDIR)${bindir}/`echo $${file} | sed '$(TRANSFORM)'` ; \
333 chmod a+rx $(DESTDIR)${bindir}/`echo $${file} | sed '$(TRANSFORM)'`; \
334 done
336 uninstall:
337 (cd $(DESTDIR)${bindir}; \
338 for file in ${INSTALLABLES} ${INSTALLABLE_SCRIPTS}; do \
339 rm -f $(DESTDIR)${bindir}/`echo $${file} | sed '$(TRANSFORM)'` ; \
340 done)
341 (cd $(DESTDIR)${archlibdir} && \
342 rm -f ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS})
344 mostlyclean:
345 -rm -f core *.o getopt.h getopt.h-t
347 clean: mostlyclean
348 -rm -f ${INSTALLABLES} ${UTILITIES} ${DONT_INSTALL}
349 -rm -f fns*.el *.tab.c *.tab.h
351 distclean: clean
352 -rm -f TAGS
353 -rm -f Makefile Makefile.c blessmail
355 maintainer-clean: distclean
356 true
358 extraclean: maintainer-clean
359 -rm -f *~ \#*
361 /* Test the contents of the directory. */
362 check:
363 @echo "We don't have any tests for GNU Emacs yet."
365 tags: TAGS
366 TAGS: etags${EXEEXT}
367 etags *.[ch]
369 /* This verifies that the non-ASCII characters in the file \`testfile\'
370 have not been clobbered by whatever means were used to copy and
371 distribute Emacs. If they were clobbered, all the .elc files were
372 clobbered too. */
373 test-distrib${EXEEXT}: ${srcdir}/test-distrib.c
374 $(CC) ${ALL_CFLAGS} -o test-distrib ${srcdir}/test-distrib.c
375 ./test-distrib ${srcdir}/testfile
377 /* We need the following in order to create a <getopt.h> when the system
378 does not have one that works with the given compiler. */
379 GETOPT_H = @GETOPT_H@
380 getopt.h: getopt_.h
381 cp $(srcdir)/getopt_.h $@-t
382 mv $@-t $@
384 GETOPTOBJS = @GETOPTOBJS@
385 GETOPTDEPS = $(GETOPTOBJS) $(GETOPT_H)
386 getopt.o: ${srcdir}/getopt.c $(GETOPT_H) ${srcdir}/gettext.h
387 ${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt.c
388 getopt1.o: ${srcdir}/getopt1.c $(GETOPT_H)
389 ${CC} -c ${CPP_CFLAGS} ${srcdir}/getopt1.c
391 REGEXPOBJ = regex.o
392 REGEXPDEPS = $(REGEXPOBJ) $(srcdir)/../src/regex.h
394 regex.o: $(srcdir)/../src/regex.c $(srcdir)/../src/regex.h ../src/config.h
395 ${CC} -c ${BASE_CFLAGS} -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER ${srcdir}/../src/regex.c
397 etags${EXEEXT}: ${srcdir}/etags.c $(GETOPTDEPS) $(REGEXPDEPS) ../src/config.h
398 $(CC) ${ALL_CFLAGS} -DEMACS_NAME="\"GNU Emacs\"" -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o etags
400 ebrowse${EXEEXT}: ${srcdir}/ebrowse.c $(GETOPTDEPS) ../src/config.h
401 $(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" ${srcdir}/ebrowse.c $(GETOPTOBJS) $(LOADLIBES) -o ebrowse
403 /* We depend on etags to assure that parallel makes don\'t write two
404 etags.o files on top of each other. */
405 ctags${EXEEXT}: etags${EXEEXT}
406 $(CC) ${ALL_CFLAGS} -DCTAGS -DEMACS_NAME="\"GNU Emacs\"" -DVERSION="\"${version}\"" ${srcdir}/etags.c $(GETOPTOBJS) $(REGEXPOBJ) $(LOADLIBES) -o ctags
408 profile${EXEEXT}: ${srcdir}/profile.c ../src/config.h
409 $(CC) ${ALL_CFLAGS} ${srcdir}/profile.c $(LOADLIBES) -o profile
411 make-docfile${EXEEXT}: ${srcdir}/make-docfile.c ../src/config.h
412 $(CC) ${ALL_CFLAGS} ${srcdir}/make-docfile.c $(LOADLIBES) -o make-docfile
414 digest-doc${EXEEXT}: ${srcdir}/digest-doc.c
415 $(CC) ${ALL_CFLAGS} ${srcdir}/digest-doc.c $(LOADLIBES) -o digest-doc
417 sorted-doc${EXEEXT}: ${srcdir}/sorted-doc.c
418 $(CC) ${ALL_CFLAGS} ${srcdir}/sorted-doc.c $(LOADLIBES) -o sorted-doc
420 b2m${EXEEXT}: ${srcdir}/b2m.c ../src/config.h $(GETOPTDEPS)
421 $(CC) ${ALL_CFLAGS} ${srcdir}/b2m.c -DVERSION="\"${version}\"" \
422 $(GETOPTOBJS) $(LOADLIBES) -o b2m
424 movemail${EXEEXT}: movemail.o pop.o $(GETOPTDEPS)
425 $(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} movemail.o pop.o $(GETOPTOBJS) $(LOADLIBES) $(LIBS_MAIL) $(LIBS_MOVE) -o movemail
427 movemail.o: ${srcdir}/movemail.c ../src/config.h $(GETOPT_H)
428 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/movemail.c
430 pop.o: ${srcdir}/pop.c ../src/config.h
431 $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c
433 fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h
434 $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail
436 emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h $(GETOPTDEPS)
437 $(CC) ${ALL_CFLAGS} ${srcdir}/emacsclient.c $(GETOPTOBJS) \
438 -DVERSION="\"${version}\"" \
439 $(LOADLIBES) -o emacsclient
441 hexl${EXEEXT}: ${srcdir}/hexl.c ../src/config.h
442 $(CC) ${ALL_CFLAGS} ${srcdir}/hexl.c $(LOADLIBES) -o hexl
444 update-game-score${EXEEXT}: update-game-score.o $(GETOPTDEPS)
445 $(CC) ${LINK_CFLAGS} ${MOVE_FLAGS} update-game-score.o $(GETOPTOBJS) $(LOADLIBES) -o update-game-score
447 update-game-score.o: ${srcdir}/update-game-score.c ../src/config.h $(GETOPT_H)
448 $(CC) -c ${CPP_CFLAGS} ${srcdir}/update-game-score.c \
449 -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\""