mailing list of musl libc
 help / color / mirror / code / Atom feed
* cluts makefiles
@ 2011-08-09 11:30 Vasiliy Kulikov
  2011-08-09 15:48 ` Luka Marčetić
  0 siblings, 1 reply; 7+ messages in thread
From: Vasiliy Kulikov @ 2011-08-09 11:30 UTC (permalink / raw)
  To: musl

Hi,

This is a patch to enhance musl building things.

1) Divided a single Makefile to the cluts, tests/, compile flags.

2) Used gcc's ability to identify dependencies.


Unrelated things:

include "sequence.c" is weird :)  It's better to use .h with
declarations and .c files which build into .o.

With glibc:

a) _SVID_SOURCE is needed for alphasort.

b) SA_NODEFER is undefined in all .c.


diff --git a/Makefile b/Makefile
index 07377a8..e77ca3a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,18 +7,27 @@
 # There's ABSOLUTELY NO WARRANTY, express or implied.
 #
 
-CFLAGS = -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wextra -O2
-LIBS = -lpthread -lrt -lm
-SRC = $(wildcard tests/*.c) $(wildcard *.c)
-BIN = $(SRC:.c=)
+include defines.mk
 
-%:%.c
+SRC = cluts.c
+BIN = cluts
+
+all: TESTS $(BIN)
+	@:
+
+%.o: %.c
+	$(CC) $(CFLAGS) $(LIBS) -c $<
+
+%: %.o
 	$(CC) $(CFLAGS) $(LIBS) -o $@ $<
-all: $(BIN)
+
+TESTS:
+	cd tests && make
 
 %.run:%
 	./$<
 test: all $(SRC:.c=.run)
 	
 clean:
-	rm -f $(BIN)
+	rm -f $(BIN) *.o
+	cd tests && make clean
diff --git a/defines.mk b/defines.mk
new file mode 100644
index 0000000..220db82
--- /dev/null
+++ b/defines.mk
@@ -0,0 +1,2 @@
+CFLAGS = -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wextra -O2
+LIBS = -lpthread -lrt -lm
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..c6c3b5e
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,25 @@
+include ../include.mk
+
+SRC = $(wildcard *.c)
+BIN = $(SRC:.c=)
+
+all: COMMON $(BIN)
+	@:
+COMMON:
+	@:
+
+%.o:
+	$(CC) $(CFLAGS) $(LIBS) -c $<
+
+%: %.o
+	$(CC) $(CFLAGS) $(LIBS) -o $@ $<
+
+deps.mk: $(SRC)
+	$(CC) -MM $^ > $@
+
+ifneq ($(MAKECMDGOALS),clean)
+-include deps.mk
+endif
+
+clean:
+	rm -rf $(BIN) *.o
---


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-10 11:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-09 11:30 cluts makefiles Vasiliy Kulikov
2011-08-09 15:48 ` Luka Marčetić
2011-08-09 16:11   ` Vasiliy Kulikov
2011-08-09 20:20     ` Luka Marčetić
2011-08-10  3:06       ` Solar Designer
2011-08-10 11:29         ` Luka Marčetić
2011-08-10 11:49           ` Solar Designer

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).