Date: Tue, 17 Nov 2015 20:51:28 +0100 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: Support for out-of-tree build * Petr Hosek <phosek@...omium.org> [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 <phosek@...omium.org> 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.
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.