about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-02-17 15:15:03 -0500
committerRich Felker <dalias@aerifal.cx>2011-02-17 15:15:03 -0500
commita36164c4743df0a9112fb3641966b213694e25f7 (patch)
treeb7b7e730820bd5a0188348618902229e831f286d
parent187fe29d5b89644b68cade75a34257a1c32a75f6 (diff)
downloadmusl-a36164c4743df0a9112fb3641966b213694e25f7.tar.gz
musl-a36164c4743df0a9112fb3641966b213694e25f7.tar.xz
musl-a36164c4743df0a9112fb3641966b213694e25f7.zip
improve Makefile handling of git checkouts with missing lib/ and config.mak
-rw-r--r--Makefile12
1 files changed, 8 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 13a24e3c..c3d29d24 100644
--- a/Makefile
+++ b/Makefile
@@ -54,6 +54,7 @@ clean:
 	rm -f include/bits
 
 include/bits:
+	@test "$(ARCH)" || { echo "Please set ARCH in config.mak before running make." ; exit 1 ; }
 	ln -sf ../arch/$(ARCH)/bits $@
 
 include/bits/alltypes.h.sh: include/bits
@@ -73,19 +74,22 @@ include/bits/alltypes.h: include/bits/alltypes.h.sh
 %.lo: %.c $(GENH)
 	$(CC) $(CFLAGS) $(INC) $(PIC) -c -o $@ $<
 
-lib/libc.so: $(LOBJS)
+lib:
+	mkdir -p lib
+
+lib/libc.so: $(LOBJS) lib
 	$(CC) $(LDFLAGS) -o $@ $(LOBJS) -lgcc
 	$(OBJCOPY) --weaken $@
 
-lib/libc.a: $(OBJS)
+lib/libc.a: $(OBJS) lib
 	rm -f $@
 	$(AR) rc $@ $(OBJS)
 	$(RANLIB) $@
 
-$(EMPTY_LIBS):
+$(EMPTY_LIBS): lib
 	$(AR) rc $@
 
-lib/%.o: crt/%.o
+lib/%.o: crt/%.o lib
 	cp $< $@
 
 tools/musl-gcc: tools/gen-musl-gcc.sh config.mak