summaryrefslogtreecommitdiff
path: root/Makeconf
diff options
context:
space:
mode:
Diffstat (limited to 'Makeconf')
-rw-r--r--Makeconf65
1 files changed, 60 insertions, 5 deletions
diff --git a/Makeconf b/Makeconf
index e7de80b2..8bd23143 100644
--- a/Makeconf
+++ b/Makeconf
@@ -117,15 +117,18 @@ endif
ifeq ($(makemode),library)
all: $(libname).a $(libname).so
-install: $(libname).a $(installhdrs) $(libname).so
- ifdef installhdrs
- $(INSTALL_DATA) $(installhdrs) $(includedir)/hurd/
- endif
+install: $(libdir)/$(libname).a $(libdir)/$(libname).so $(addprefix $(includedir)/hurd/,$(installhdrs))
+
+$(libdir)/$(libname).a: $(libname).a
$(INSTALL_DATA) $(libname).a $(libdir)/$(libname).a
$(RANLIB) $(libdir)/$(libname).a
+$(libdir)/$(libname).so: $(libname).so
$(INSTALL_DATA) $(libname).so $(libdir)/$(libname).so
-endif
+$(addprefix $(includedir)/hurd/,$(installhdrs)): $(includedir)/hurd/%: %
+ $(INSTALL_DATA) $< $@
+
+endif
# Provide default.
install:
@@ -263,4 +266,56 @@ $(foreach if,$(hurddefs),$(if)_S.h $(if)Server.c $(if)_U.h $(if)User.c): $(ht)
FORCE:
+
+# How to build automatic dependencies
+
+# For each file generated by MiG we need a .d file.
+# These lines assume that every Makefile that uses a foo_S.h or foo_U.h file
+# also mentions the associated fooServer.o or fooUser.o file.
+include $(subst Server.o,.migs_d,$(filter %Server.o,$(OBJS)))
+include $(subst User.o,.migu_d,$(filter %User.o,$(OBJS)))
+include $(subst Server.o,.migsh_d,$(filter %Server.o,$(OBJS)))
+include $(subst User.o,.miguh_d,$(filter %User.o,$(OBJS)))
+
+# For each .o file we need a .d file.
+include $(subst .o,.d,$(OBJS))
+
+
+# Here is how to build those dependency files
+
+# Dependencies for fooServer.c files.
+%.migs_d: %.defs
+ (set -e; $(CPP) $(CPPFLAGS) $(MIGSFLAGS) $($*-MIGSFLAGS) \
+ -DSERVERPREFIX=S_ -M -MG $< | \
+ sed -e 's/\.defs\.o:/Server\.c $@:/' > $@)
+
+# Dependencies for fooUser.c files.
+%.migu_d: %.defs
+ (set -e; $(CPP) $(CPPFLAGS) $(MIGUFLAGS) $($*-MIGUFLAGS) \
+ -M -MG $< | \
+ sed -e 's/\.defs\.o:/User\.c $@:/' > $@)
+
+# The associated .h files are build by the same CCP, so a simple massaging
+# of the previous two will work.
+%.migsh_d: %.migs_d
+ sed -e 's/Server\.c/_S\.h/' -e 's/migs_d/migsh_d/' < $< > $@
+%.miguh_d: %.migu_d
+ sed -e 's/User\.c/_U\.h/' -e 's/migu_d/miguh_d/' < $< > $@
+
+# Here is how to make .d files from .c files
+%.d: %.c
+ (set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MG $< | \
+ sed -e 's/\.o/& $@/' > $@)
+
+# Here is how to make .d files from .S files
+%.d: %.S
+ (set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MG $< | \
+ sed -e 's/\.o/& $@/' > $@)
+
+# .s files don't go through the preprocessor, so we do this
+# This rule must come *after* the genuine ones above, so that
+# make doesn't build a .s file and then make an empty dependency
+# list.
+%.d: %.s
+ echo '$*.o: $*.s' > $*.d