add support for flattening recursive-let
[ghc-hetmet.git] / includes / ghc.mk
index 007ce4b..8d4fd47 100644 (file)
@@ -18,9 +18,17 @@ includes_H_CONFIG   = includes/ghcautoconf.h
 includes_H_PLATFORM = includes/ghcplatform.h
 
 #
-# All header files
+# All header files are in includes/{one of these subdirectories}
 #
-includes_H_FILES = $(filter-out $(includes_H_CONFIG) $(includes_H_PLATFORM),$(wildcard includes/*.h includes/*/*.h includes/*/*/*.h))
+includes_H_SUBDIRS += .
+includes_H_SUBDIRS += rts
+includes_H_SUBDIRS += rts/prof
+includes_H_SUBDIRS += rts/storage
+includes_H_SUBDIRS += stg
+
+includes_H_FILES := $(wildcard $(patsubst %,includes/%/*.h,$(includes_H_SUBDIRS)))
+# This isn't necessary, but it makes the paths look a little prettier
+includes_H_FILES := $(subst /./,/,$(includes_H_FILES))
 
 #
 # Options
@@ -46,7 +54,7 @@ endif
 
 ifneq "$(BINDIST)" "YES"
 
-ifneq "$(TARGETPLATFORM)"  "$(HOSTPLATFORM)"
+ifeq "$(PORTING_HOST)" "YES"
 
 $(includes_H_CONFIG) :
        @echo "*** Cross-compiling: please copy $(includes_H_CONFIG) from the target system"
@@ -116,7 +124,7 @@ endif
 
 includes_DERIVEDCONSTANTS = includes/DerivedConstants.h
 
-ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
+ifeq "$(PORTING_HOST)" "YES"
 
 DerivedConstants.h :
        @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
@@ -129,7 +137,7 @@ includes_dist-derivedconstants_PROG   = mkDerivedConstants$(exeext)
 
 $(eval $(call build-prog,includes,dist-derivedconstants,0))
 
-$(includes_dist-derivedconstants_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(wildcard includes/*.h) $(wildcard rts/*.h)
+$(includes_dist-derivedconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
 includes/dist-derivedconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
 
 ifneq "$(BINDIST)" "YES"
@@ -144,7 +152,7 @@ endif
 
 includes_GHCCONSTANTS = includes/GHCConstants.h
 
-ifneq "$(TARGETPLATFORM)" "$(HOSTPLATFORM)"
+ifeq "$(PORTING_HOST)" "YES"
 
 $(includes_GHCCONSTANTS) :
        @echo "*** Cross-compiling: please copy DerivedConstants.h from the target system"
@@ -159,7 +167,7 @@ includes_dist-ghcconstants_CC_OPTS = -DGEN_HASKELL
 $(eval $(call build-prog,includes,dist-ghcconstants,0))
 
 ifneq "$(BINDIST)" "YES"
-$(includes_dist-ghcconstants_depfile) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(wildcard includes/*.h) $(wildcard rts/*.h)
+$(includes_dist-ghcconstants_depfile_c_asm) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_FILES) $$(rts_H_FILES)
 
 includes/dist-ghcconstants/build/mkDerivedConstants.o : $(includes_H_CONFIG) $(includes_H_PLATFORM)
 
@@ -180,16 +188,14 @@ $(eval $(call all-target,includes,,\
   $(includes_H_CONFIG) $(includes_H_PLATFORM) \
   $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS)))
 
-includes_subdirs = $(sort $(subst includes/,,$(foreach d,$(includes_H_FILES),$(dir $(d)))))
-
 install: install_includes
 
 .PHONY: install_includes
 install_includes :
-       $(INSTALL_DIR) $(DESTDIR)$(ghcheaderdir)
-       for d in $(includes_subdirs); do \
-               $(INSTALL_DIR) $(DESTDIR)$(ghcheaderdir)/$$d; \
-       done
-       for i in $(subst includes/,,$(includes_H_FILES) $(includes_H_CONFIG) $(includes_H_PLATFORM)); do \
-               $(INSTALL_HEADER) $(INSTALL_OPTS) includes/$$i $(DESTDIR)$(ghcheaderdir)/$$i; \
-       done
+       $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)")
+       $(foreach d,$(includes_H_SUBDIRS), \
+           $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)/$d") && \
+           $(call INSTALL_HEADER,$(INSTALL_OPTS),includes/$d/*.h,"$(DESTDIR)$(ghcheaderdir)/$d/") && \
+       ) true
+       $(call INSTALL_HEADER,$(INSTALL_OPTS),$(includes_H_CONFIG) $(includes_H_PLATFORM),"$(DESTDIR)$(ghcheaderdir)/")
+