From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8878 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Support for out-of-tree build Date: Tue, 17 Nov 2015 20:51:28 +0100 Message-ID: <20151117195128.GI18372@port70.net> References: <20151112145026.GB18372@port70.net> <20151112203048.GB3818@brightrain.aerifal.cx> <20151112211024.GC18372@port70.net> <20151112215232.GC3818@brightrain.aerifal.cx> <20151112234137.GD3818@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1447789906 22898 80.91.229.3 (17 Nov 2015 19:51:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Nov 2015 19:51:46 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8891-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 17 20:51:46 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZymI3-0007Cv-9n for gllmg-musl@m.gmane.org; Tue, 17 Nov 2015 20:51:43 +0100 Original-Received: (qmail 26200 invoked by uid 550); 17 Nov 2015 19:51:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 26176 invoked from network); 17 Nov 2015 19:51:40 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Xref: news.gmane.org gmane.linux.lib.musl.general:8878 Archived-At: * Petr Hosek [2015-11-17 06:05:21 +0000]: > One minor improvement, we obviously don't need more than one .mk file per > directory. > > On Mon, Nov 16, 2015 at 6:45 PM Petr Hosek wrote: > > This is the final solution I've converged to. It's a bigger change than > > the previous version, but the implementation is actually cleaner. In > > nutshell, I've replaced all .sub files with .mk equivalent files which are > > included from the Makefile. I'm then filtering out all C object files which > > have assembly equivalent. This allowed me to simplify the build rules while > > we still support both in-tree and out-of-tree builds. Please let me know > > what you think, I'll be happy to iterate on this. > > > -SRCS = $(sort $(wildcard src/*/*.c arch/$(ARCH)/src/*.c)) > -OBJS = $(SRCS:.c=.o) > -LOBJS = $(OBJS:.o=.lo) > GENH = include/bits/alltypes.h > GENH_INT = src/internal/version.h > -IMPH = src/internal/stdio_impl.h src/internal/pthread_impl.h src/internal/libc.h > +IMPH = $(addprefix $(srcdir)/, src/internal/stdio_impl.h src/internal/pthread_impl.h src/internal/libc.h) > + > +ASM_SRCS = $(wildcard $(srcdir)/src/*/$(ARCH)/*.s) > +ASM_OBJS = $(ASM_SRCS:$(srcdir)/%.s=%.o) > +ASM_LOBJS = $(ASM_OBJS:.o=.lo) > + > +SRCS = $(sort $(wildcard $(srcdir)/src/*/*.c $(srcdir)/arch/$(ARCH)/src/*.c)) > +EXCLUDE_OBJS = $(foreach s,$(ASM_SRCS),$(dir $(patsubst $(srcdir)/%/,%,$(dir $(s))))$(notdir $(s:.s=.o))) > +EXCLUDE_LOBJS = $(EXCLUDE_OBJS:.o=.lo) > +OBJS = $(filter-out $(EXCLUDE_OBJS),$(SRCS:$(srcdir)/%.c=%.o)) crt/crt1.o crt/Scrt1.o crt/rcrt1.o crt/crti.o crt/crtn.o > +LOBJS = $(filter-out $(EXCLUDE_LOBJS),$(SRCS:$(srcdir)/%.c=%.lo)) i was afraid this might be O(nm), but it seems gnu make can use a hash. > +-include $(srcdir)/src/*/$(ARCH)$(ASMSUBARCH)/*.mk a .mk change might not trigger the rebuild of the right files, but that's true for the Makefile as well so that's ok. note that the .mk is much more powerful than the .sub was e.g. it can add a .s for which there is no corresponding .c since you only use one .mk per dir, it can have a fixed name, but including as *.mk is ok too. > -%.o: $(ARCH)/%.s > +$(ASM_OBJS): %.o: $(srcdir)/%.s > $(AS_CMD) $(CFLAGS_ALL_STATIC) > > -%.o: %.c $(GENH) $(IMPH) > +$(OBJS): %.o: $(srcdir)/%.c $(GENH) $(IMPH) > $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $< > i assume $(ASM_OBJS): and $(OBJS): are no longer necessary. (first rule only matches a .o under an $ARCH$SUBARCH dir) > -lib/libc.so: $(LOBJS) > +lib/libc.so: $(LOBJS) $(ASM_LOBJS) > $(CC) $(CFLAGS_ALL_SHARED) $(LDFLAGS_ALL) -nostdlib -shared \ > -Wl,-e,_dlstart -Wl,-Bsymbolic-functions \ > - -o $@ $(LOBJS) $(LIBCC) > + -o $@ $(LOBJS) $(ASM_LOBJS) $(LIBCC) > > -lib/libc.a: $(OBJS) > +lib/libc.a: $(OBJS) $(ASM_OBJS) > rm -f $@ > - $(AR) rc $@ $(OBJS) > + $(AR) rc $@ $(OBJS) $(ASM_OBJS) > $(RANLIB) $@ this change can be avoided if OBJS contains ASM_OBJS. otherwise i'm ok with this patch.