Fix tempfile bug on platforms lacking mkostemp and mkstemp.
[bpt/emacs.git] / src / Makefile.in
index 90083eb..65927ba 100644 (file)
@@ -1,4 +1,4 @@
-# src/Makefile for GNU Emacs.
+### @configure_input@
 
 # Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2013 Free Software
 # Foundation, Inc.
@@ -469,6 +469,7 @@ emacs$(EXEEXT): temacs$(EXEEXT) $(ADDSECTION) \
 ## in the contents of the DOC file.
 ##
 $(etc)/DOC: $(libsrc)/make-docfile$(EXEEXT) $(obj) $(lisp)
+       $(MKDIR_P) $(etc)
        -rm -f $(etc)/DOC
        $(libsrc)/make-docfile -d $(srcdir) $(SOME_MACHINE_OBJECTS) $(obj) > $(etc)/DOC
        $(libsrc)/make-docfile -a $(etc)/DOC -d $(lispsource) `sed -n -e 's| \\\\||' -e 's|^[   ]*$$(lispsource)/||p' $(srcdir)/lisp.mk`
@@ -477,16 +478,19 @@ $(libsrc)/make-docfile$(EXEEXT):
        cd $(libsrc); $(MAKE) $(MFLAGS) make-docfile$(EXEEXT)
 
 buildobj.h: Makefile
-       echo "#define BUILDOBJ \"$(ALLOBJS) " "\"" >$@
+       for i in $(ALLOBJS); do \
+         echo "$$i" | sed 's,.*/,,; s/\.obj$$/\.o/; s/^/"/; s/$$/",/' \
+           || exit; \
+       done >$@.tmp
+       mv $@.tmp $@
 
 globals.h: gl-stamp; @true
 
 GLOBAL_SOURCES = $(base_obj:.o=.c) $(NS_OBJC_OBJ:.o=.m)
 
 gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
-       @rm -f gl-tmp
-       $(libsrc)/make-docfile -d $(srcdir) -g $(obj) > gl-tmp
-       $(srcdir)/../build-aux/move-if-change gl-tmp globals.h
+       $(libsrc)/make-docfile -d $(srcdir) -g $(obj) > gl.tmp
+       $(srcdir)/../build-aux/move-if-change gl.tmp globals.h
        echo timestamp > $@
 
 $(ALLOBJS): globals.h
@@ -494,10 +498,15 @@ $(ALLOBJS): globals.h
 $(lib)/libgnu.a: $(config_h)
        cd $(lib) && $(MAKE) libgnu.a
 
+## We have to create $(etc) here because init_cmdargs tests its
+## existence when setting Vinstallation_directory (FIXME?).
+## This goes on to affect various things, and the emacs binary fails
+## to start if Vinstallation_directory has the wrong value.
 temacs$(EXEEXT): stamp-oldxmenu $(ALLOBJS) \
                 $(lib)/libgnu.a $(EMACSRES)
        $(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
          -o temacs $(ALLOBJS) $(lib)/libgnu.a $(W32_RES_LINK) $(LIBES)
+       $(MKDIR_P) $(etc)
        $(TEMACS_POST_LINK)
        test "$(CANNOT_DUMP)" = "yes" || \
          test "X$(PAXCTL)" = X || $(PAXCTL) -r temacs$(EXEEXT)
@@ -557,7 +566,7 @@ mostlyclean:
        rm -f bootstrap-emacs$(EXEEXT) emacs-$(version)$(EXEEXT)
        rm -f buildobj.h
        rm -f globals.h gl-stamp
-       rm -f *.res
+       rm -f *.res *.tmp
 clean: mostlyclean
        rm -f emacs-*.*.*$(EXEEXT) emacs$(EXEEXT)
        -rm -rf $(DEPDIR)