From: Vasiliy Kulikov <segoon@openwall.com>
To: musl@lists.openwall.com
Subject: cluts makefiles
Date: Tue, 9 Aug 2011 15:30:47 +0400 [thread overview]
Message-ID: <20110809113045.GA12614@albatros> (raw)
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
---
next reply other threads:[~2011-08-09 11:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-09 11:30 Vasiliy Kulikov [this message]
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
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=20110809113045.GA12614@albatros \
--to=segoon@openwall.com \
--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).