diff options
author | Thomas Bushnell <thomas@gnu.org> | 1996-10-24 19:23:47 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1996-10-24 19:23:47 +0000 |
commit | ae34c667030c0bca9e82b601dd65018f5c489c3b (patch) | |
tree | 951ac27e0099e5004932f183dc2743c7fd4085bc /Makeconf | |
parent | 37c961ca47578631358b90b07d752f7862b3c8f1 (diff) |
Wed Oct 23 01:36:35 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* Makeconf ($(target)): Repair rule for building of .prof_d
files.
($(target), $(target).prof): Refer to generated variables
(-CFLAGS, -LFLAGS, -LDLIBS) by the base name ($*) not $@.
(_libext): Likewise.
Mon Oct 21 22:22:49 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* Makeconf (cleantarg) [makemode == library]: Add $(libname)_p.a.
(targets) [makemode == library]: Include $(libname)_p.a in default
value.
($(libdir)/$(libname)_p.a) [makemode == library]: New rule.
($(libname)_p.a) [makemode == library]: New rule.
(%_p.o): Two new rules (depend on %.c or %.S).
(make_deps): Make dependency now specify $*_p.o too.
($(addsuffix .prof,$(target))): New rule to link profiled objects.
($(target)): Surround usual build rule with if prof-depend == nil.
($(addsuffix .prof_d, $(target))): Include this if not a library.
Also a new rule to build them.
($(target)) [prof-depend == t]: Kludge to write out its dependencies.
Tue Oct 15 12:29:26 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* Makeconf (relink): Remove $(linktarg) always.
(linktarg) [makemode == library]: Set variable.
(linktarg): And also a default.
* Makefile (%-relink): Set no_deps=t here.
(relink): Do $(lib-subdirs) too.
Diffstat (limited to 'Makeconf')
-rw-r--r-- | Makeconf | 69 |
1 files changed, 59 insertions, 10 deletions
@@ -117,15 +117,20 @@ endif ifeq ($(makemode),library) clean := yes - cleantarg := $(libname).a $(libname).so + cleantarg := $(libname).a $(libname).so $(libname)_p.a + linktarg := $(libname).so ifndef installhdrsubdir installhdrsubdir = hurd endif ifndef targets - targets = $(libname).a $(libname).so + targets = $(libname).a $(libname).so $(libname)_p.a endif endif +ifeq ($(linktarg),) + linktarg:=$(cleantarg) +endif + # This is a hack to give all hurd utilities a default bug-reporting # address (defined in libhurdbugaddr/bugaddr.c). BUGADDR = $(..)libhurdbugaddr/libhurdbugaddr.a @@ -175,6 +180,9 @@ $(INSTALLED_LOCAL_HEADERS): $(top_srcdir)/$(installhdrsubdir)/%: endif libs: $(INSTALLED_LOCAL_HEADERS) +$(libdir)/$(libname)_p.a: $(libname)_p.a + $(INSTALL_DATA) $(libname)_p.a $(libdir)/$(libname)_p.a + $(RANLIB) $(libdir)/$(libname)_p.a $(libdir)/$(libname).a: $(libname).a $(INSTALL_DATA) $(libname).a $(libdir)/$(libname).a $(RANLIB) $(libdir)/$(libname).a @@ -211,7 +219,7 @@ endif # is used in LDFLAGS. __libext=.so __libext-static=.a -_libext=$(__libext$(findstring -static,$(LDFLAGS) $($@-LDFLAGS))) +_libext=$(__libext$(findstring -static,$(LDFLAGS) $($*-LDFLAGS))) libsubst=$(basename ${lib})$(_libext) libsubst-override=${$(notdir $(basename ${lib}))-libsubst} @@ -221,12 +229,28 @@ _libsubst=${libsubst$(patsubst %,-override,${libsubst-override})} # dependencies of other shared objects it encounters. rpath := -Wl,-rpath-link=.:$(subst $. ,:,$(dir $(wildcard ../lib*/lib*.so))) +# Main rule to link executables +# +# (prof-depend is a special kind of run not normally used; see the rules +# below for %.prof_d which uses it.) +ifeq ($(prof-depend),) $(target): %$(target-suffix): $(BUGADDR) - $(CC) $(rpath) $(CFLAGS) $($@-CFLAGS) $(LDFLAGS) $($@-LDFLAGS) $(BUGADDR_REF) \ + $(CC) $(rpath) $(CFLAGS) $($*-CFLAGS) $(LDFLAGS) $($*-LDFLAGS) $(BUGADDR_REF) \ -o $@ \ '-Wl,-(' $(filter %.o,$^) \ - $(foreach lib,$(filter-out %.o,$+),${_libsubst}) $($@-LDLIBS) $(LDLIBS) \ + $(foreach lib,$(filter-out %.o,$+),${_libsubst}) $($*-LDLIBS) $(LDLIBS) \ '-Wl,-)' +endif + +# Just like above, but tell how to make .prof versions of programs. +$(addsuffix .prof,$(target)): %$(target-suffix).prof: $(BUGADDR) + $(CC) -pg $(CFLAGS) $($*-CFLAGS) $(LDFLAGS) $($*-LDFLAGS) \ + $(BUGADDR_REF) -static \ + -o $@ \ + '-Wl,-(' $(filter %.o,$^) \ + $(patsubst %.a,%_p.a,$(filter-out %.o,$+)) \ + $($*-LDLIBS) $(LDLIBS) \ + '-Wl,-)' ifeq ($(makemode),library) $(libname).a: $(OBJS) @@ -234,6 +258,11 @@ $(libname).a: $(OBJS) $(AR) r $@ $^ $(RANLIB) $@ +$(libname)_p.a: $(patsubst %.o,%_p.o,$(OBJS)) + rm -f $(libname)_p.a + $(AR) r $@ $^ + $(RANLIB) $@ + $(libname).so: $(patsubst %.o,%_pic.o,$(OBJS)) $(library_deps) $(CC) -shared -Wl,-soname=$(libname).so -o $(libname).so \ $(rpath) $(CFLAGS) $(LDFLAGS) $($@-LDFLAGS) $^ @@ -273,11 +302,10 @@ endif ifeq ($(clean),yes) clean: rm -f *.d *.*_d *.o *Server.c *User.c *_S.h *_U.h $(cleantarg) -ifneq ($(makemode),library) relink: - rm -f $(cleantarg) -endif + rm -f $(linktarg) endif + clean: relink: @@ -319,12 +347,19 @@ relink: vpath libutil.% $(libdir)/ -# Default rule to build PIC object files. +# Default rules to build PIC object files. %_pic.o: %.c $(COMPILE.c) $< -DPIC -fPIC -o $@ %_pic.o: %.S $(COMPILE.S) $< -DPIC -o $@ + +# Default rules to build profiled object files. +%_p.o: %.c + $(COMPILE.c) $< -DPROF -pg -o $@ + +%_p.o: %.S + $(COMPILE.S) $< -DPROF -o $@ # How to build RPC stubs @@ -387,6 +422,10 @@ ifneq ($(no_deps),t) -include $(subst Server.o,.migsh_d,$(filter %Server.o,$(OBJS))) /dev/null -include $(subst User.o,.miguh_d,$(filter %User.o,$(OBJS))) /dev/null +ifneq ($(makemode),library) +-include $(addsuffix .prof_d,$(target)) /dev/null +endif + # For each .o file we need a .d file. -include $(subst .o,.d,$(filter %.o,$(OBJS))) /dev/null @@ -413,9 +452,18 @@ endif %.miguh_d: %.migu_d sed -e 's/User\.c/_U\.h/' -e 's/migu_d/miguh_d/' < $< > $@ +%.prof_d: Makefile + $(MAKE) $* prof-depend=t no_deps=t + +ifeq ($(prof-depend),t) +$(target): %: FORCE + rm -f $@.prof_d + echo $@.prof: $(subst .o,_p.o,$(filter-out FORCE,$+)) > $@.prof_d +endif + define make-deps set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MG $< | \ -sed > $@.new -e 's/$*\.o:/$*.o $*_pic.o $@:/' \ +sed > $@.new -e 's/$*\.o:/$*.o $*_pic.o $*_p.o $@:/' \ -e 's% [^ ]*/gcc-lib/[^ ]*\.h%%g' mv -f $@.new $@ endef @@ -436,3 +484,4 @@ endef %: %.sh $(top_srcdir)/sh-version.sed sed -f $(top_srcdir)/sh-version.sed < $< > $@ chmod +x $@ + |