From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: Out-of-tree builds
Date: Fri, 7 Feb 2014 02:01:36 +0100 [thread overview]
Message-ID: <20140207010135.GE1685@port70.net> (raw)
In-Reply-To: <20140206233121.GD1685@port70.net>
[-- Attachment #1: Type: text/plain, Size: 363 bytes --]
* Szabolcs Nagy <nsz@port70.net> [2014-02-07 00:31:22 +0100]:
>
> VPATH=$(SOMEDIR)
> %.o: $(ARCH)/%.s
>
attached a make diff that can do out-of-tree build, by specifying
M=relative/path/to/musl
- config is not ready
- directory creation is a hack
- include/bits/alltypes.h is generated into the original repo
(include/bits is a symlink to the arch/bits dir)
[-- Attachment #2: make.diff --]
[-- Type: text/x-diff, Size: 4024 bytes --]
diff --git a/Makefile b/Makefile
index 0ab0bfd..fb9a83e 100644
--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,9 @@ includedir = $(prefix)/include
libdir = $(prefix)/lib
syslibdir = /lib
-SRCS = $(sort $(wildcard src/*/*.c arch/$(ARCH)/src/*.c))
-OBJS = $(SRCS:.c=.o)
+M = .
+SRCS = $(sort $(wildcard $(M)/src/*/*.c $(M)/arch/$(ARCH)/src/*.c))
+OBJS = $(SRCS:$(M)/%.c=%.o)
LOBJS = $(OBJS:.o=.lo)
GENH = include/bits/alltypes.h
GENH_INT = src/internal/version.h
@@ -30,17 +31,17 @@ CFLAGS = -Os -pipe
CFLAGS_C99FSE = -std=c99 -ffreestanding -nostdinc
CFLAGS_ALL = $(CFLAGS_C99FSE)
-CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I./arch/$(ARCH) -I./src/internal -I./include
+CFLAGS_ALL += -D_XOPEN_SOURCE=700 -I$(M)/arch/$(ARCH) -I./src/internal -I$(M)/src/internal -I./include -I$(M)/include
CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS)
CFLAGS_ALL_STATIC = $(CFLAGS_ALL)
CFLAGS_ALL_SHARED = $(CFLAGS_ALL) -fPIC -DSHARED
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
-INSTALL = ./tools/install.sh
+INSTALL = $(M)/tools/install.sh
-ARCH_INCLUDES = $(wildcard arch/$(ARCH)/bits/*.h)
-ALL_INCLUDES = $(sort $(wildcard include/*.h include/*/*.h) $(GENH) $(ARCH_INCLUDES:arch/$(ARCH)/%=include/%))
+ARCH_INCLUDES = $(wildcard $(M)/arch/$(ARCH)/bits/*.h)
+ALL_INCLUDES = $(sort $(wildcard $(M)/include/*.h $(M)/include/*/*.h) $(GENH) $(ARCH_INCLUDES:$(M)/arch/$(ARCH)/%=include/%))
EMPTY_LIB_NAMES = m rt pthread crypt util xnet resolv dl
EMPTY_LIBS = $(EMPTY_LIB_NAMES:%=lib/lib%.a)
@@ -55,7 +56,12 @@ LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1
-include config.mak
-all: $(ALL_LIBS) $(ALL_TOOLS)
+VPATH = $(M)
+
+all: dirhack $(ALL_LIBS) $(ALL_TOOLS)
+
+dirhack:
+ mkdir -p $(sort $(dir $(OBJS))) crt include lib tools
install: install-libs install-headers install-tools
@@ -73,26 +79,26 @@ distclean: clean
include/bits:
@test "$(ARCH)" || { echo "Please set ARCH in config.mak before running make." ; exit 1 ; }
- ln -sf ../arch/$(ARCH)/bits $@
+ ln -sf ../$(M)/arch/$(ARCH)/bits $@
include/bits/alltypes.h.in: include/bits
-include/bits/alltypes.h: include/bits/alltypes.h.in include/alltypes.h.in tools/mkalltypes.sed
- sed -f tools/mkalltypes.sed include/bits/alltypes.h.in include/alltypes.h.in > $@
+include/bits/alltypes.h: include/bits/alltypes.h.in $(M)/include/alltypes.h.in $(M)/tools/mkalltypes.sed
+ sed -f $(M)/tools/mkalltypes.sed include/bits/alltypes.h.in $(M)/include/alltypes.h.in > $@
-src/internal/version.h: $(wildcard VERSION .git)
- printf '#define VERSION "%s"\n' "$$(sh tools/version.sh)" > $@
+src/internal/version.h: $(wildcard $(M)/VERSION $(M)/.git)
+ printf '#define VERSION "%s"\n' "$$(cd $(M); sh tools/version.sh)" > $@
src/internal/version.lo: src/internal/version.h
src/ldso/dynlink.lo: arch/$(ARCH)/reloc.h
-crt/crt1.o crt/Scrt1.o: $(wildcard arch/$(ARCH)/crt_arch.h)
+crt/crt1.o crt/Scrt1.o: $(wildcard $(M)/arch/$(ARCH)/crt_arch.h)
crt/Scrt1.o: CFLAGS += -fPIC
-OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=src/%))
-$(OPTIMIZE_SRCS:%.c=%.o) $(OPTIMIZE_SRCS:%.c=%.lo): CFLAGS += -O3
+OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=$(M)/src/%))
+$(OPTIMIZE_SRCS:$(M)/%.c=%.o) $(OPTIMIZE_SRCS:$(M)/%.c=%.lo): CFLAGS += -O3
MEMOPS_SRCS = src/string/memcpy.c src/string/memmove.c src/string/memcmp.c src/string/memset.c
$(MEMOPS_SRCS:%.c=%.o) $(MEMOPS_SRCS:%.c=%.lo): CFLAGS += $(CFLAGS_MEMOPS)
@@ -101,9 +107,9 @@ $(MEMOPS_SRCS:%.c=%.o) $(MEMOPS_SRCS:%.c=%.lo): CFLAGS += $(CFLAGS_MEMOPS)
# force the corresponding object file to be rebuilt, even if the implicit
# rule below goes indirectly through a .sub file.
define mkasmdep
-$(dir $(patsubst %/,%,$(dir $(1))))$(notdir $(1:.s=.o)): $(1)
+$(dir $(patsubst $(M)/%/,%,$(dir $(1))))$(notdir $(1:.s=.o)): $(1)
endef
-$(foreach s,$(wildcard src/*/$(ARCH)*/*.s),$(eval $(call mkasmdep,$(s))))
+$(foreach s,$(wildcard $(M)/src/*/$(ARCH)*/*.s),$(eval $(call mkasmdep,$(s))))
%.o: $(ARCH)$(ASMSUBARCH)/%.sub
$(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $(dir $<)$(shell cat $<)
next prev parent reply other threads:[~2014-02-07 1:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-06 17:15 Oliver Schneider
2014-02-06 17:39 ` Szabolcs Nagy
2014-02-06 18:25 ` Oliver Schneider
2014-02-06 19:04 ` Rich Felker
2014-02-06 23:27 ` Szabolcs Nagy
2014-02-06 23:31 ` Szabolcs Nagy
2014-02-07 1:01 ` Szabolcs Nagy [this message]
2014-02-07 1:07 ` Rich Felker
2014-02-08 2:49 ` Szabolcs Nagy
2014-02-26 22:56 ` Szabolcs Nagy
2014-02-27 13:29 ` Szabolcs Nagy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140207010135.GE1685@port70.net \
--to=nsz@port70.net \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).