-GHC/PrimopWrappers.hs: $(GHC_COMPILER_DIR)/prelude/primops.txt
- rm -f $@
- $(GHC_GENPRIMOP) --make-haskell-wrappers < $< > $@
+# These two lines are required for pre-processing compiler/prelude/primops.txt
+SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
+SRC_CPP_OPTS += ${GhcCppOpts}
+
+ifeq "$(BootingFromHc)" "YES"
+GHC/PrimopWrappers.hs: GHC/Prim.hs
+ touch GHC/PrimopWrappers.hs
+else
+GHC/PrimopWrappers.hs: $(GHC_COMPILER_DIR)/prelude/primops.txt GHC/Prim.hs
+ @$(RM) $@
+ $(GENPRIMOP) --make-haskell-wrappers < $< > $@
+endif
+
+GHC/Prim.hs: $(GHC_COMPILER_DIR)/prelude/primops.txt
+ @$(RM) $@
+ $(GENPRIMOP) --make-haskell-source < $< > $@
+
+EXCLUDED_SRCS = GHC/Prim.hs
+EXTRA_HADDOCK_SRCS = GHC/Prim.hs