-$(TEMACS): $(TLIB1) $(TLIB2) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES)
- $(LINK) -out:$(TEMACS) $(LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
+$(TEMACS): $(PREPARED_HEADERS) $(TLIB0) $(TLIB1) $(TLIB2) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES)
+ $(LINK) -out:$(TEMACS_TMP) $(LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
+ ..\nt\$(BLD)\addsection $(TEMACS_TMP) $(TEMACS) EMHEAP 16
+
+bootstrap: bootstrap-emacs
+
+#
+# Build a temacs with a sufficiently large PURESIZE to load the
+# Lisp files from loadup.el in source form.
+#
+bootstrap-temacs: bootstrap-clean
+ $(MAKE) $(MFLAGS) -f makefile.nt temacs CFLAGS="$(CFLAGS) -DPURESIZE=5000000"
+
+#
+# Dump an Emacs executable named bootstrap-emacs containing the
+# files from loadup.el in source form.
+#
+bootstrap-emacs: bootstrap-temacs
+ $(MAKEDIR)\$(BLD)\temacs.exe -batch -l loadup bootstrap
+ - mkdir ..\bin
+ $(CP) $(EMACS) ..\bin
+
+#
+# Force recompile of files that depend on PURESIZE
+#
+bootstrap-clean:
+ - $(DEL) $(BLD)\alloc.obj
+ - $(DEL) $(BLD)\data.obj
+ - $(DEL) $(BLD)\intervals.obj
+ - $(DEL) $(BLD)\keyboard.obj
+ - $(DEL) $(BLD)\keymap.obj