* 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
* Re: cluts makefiles
2011-08-09 11:30 cluts makefiles Vasiliy Kulikov
@ 2011-08-09 15:48 ` Luka Marčetić
2011-08-09 16:11 ` Vasiliy Kulikov
0 siblings, 1 reply; 7+ messages in thread
From: Luka Marčetić @ 2011-08-09 15:48 UTC (permalink / raw)
To: musl
On 08/09/2011 01:30 PM, Vasiliy Kulikov wrote:
> 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.
Do others free compilers support nr 2?
> Unrelated things:
>
> include "sequence.c" is weird :) It's better to use .h with
> declarations and .c files which build into .o.
It's an ad-hoc dir structure, therefore suboptimal. I'll add prototypes
and other declarations into .h some day.
> With glibc:
>
> a) _SVID_SOURCE is needed for alphasort.
Maybe older glibc needed it (I get no warnings). I'm not sure it
warrants an inclusion (it's SUSv4).
> b) SA_NODEFER is undefined in all .c.
It should be defined in signal.h. Alexander had problems with this.
Trying to apply the patch that you wrote told me you're missing an
_XOPEN_SOURCE flag I've relatively recently added to the Make-file on
Rich's incentive, so perhaps you could should try that. If it's an old
kernel version instead, necessary modifications would be more extensive,
involving unblocking when entering the handler (sigprocmask?), removing
SA_NODEFERs, using sig*jmp, and perhaps more in some cases.
> diff --git a/Makefile b/Makefile
Having made dirs a and b (both from the same repo dir), I tried `patch
-p0 < yourpatch`, and got:
Hunk #1 FAILED at 7.
1 out of 1 hunk FAILED -- saving rejects to file a/Makefile.rej
patching file b/defines.mk
patching file b/tests/Makefile
I tried to replace the offending line with:
-CFLAGS = -std=c99 -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -Wall
-Wextra -O2
but somehow the error message persists. Is there something I'm missing?
Thanks,
Luka
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: cluts makefiles
2011-08-09 15:48 ` Luka Marčetić
@ 2011-08-09 16:11 ` Vasiliy Kulikov
2011-08-09 20:20 ` Luka Marčetić
0 siblings, 1 reply; 7+ messages in thread
From: Vasiliy Kulikov @ 2011-08-09 16:11 UTC (permalink / raw)
To: musl
On Tue, Aug 09, 2011 at 17:48 +0200, Luka Marčetić wrote:
> On 08/09/2011 01:30 PM, Vasiliy Kulikov wrote:
> >2) Used gcc's ability to identify dependencies.
>
> Do others free compilers support nr 2?
Hmm, not sure. I think it is gcc specific thing. Then you could use it
if there is gcc installed (just installed, CC can be arbitrary
compiler) and leave deps.mk blank as a fallback and change target line
from
%.o:
to
%.o: %.c
Or you could precompile these files with gcc and distribute them as is
without gcc dependency.
> >b) SA_NODEFER is undefined in all .c.
>
> It should be defined in signal.h. Alexander had problems with this.
The target system is Ubuntu 10.04, glibc-2.10-1, gcc 4.4.3-4ubuntu5.
> >diff --git a/Makefile b/Makefile
>
> Having made dirs a and b (both from the same repo dir), I tried
> `patch -p0 < yourpatch`, and got:
>
> Hunk #1 FAILED at 7.
> 1 out of 1 hunk FAILED -- saving rejects to file a/Makefile.rej
> patching file b/defines.mk
> patching file b/tests/Makefile
You should use "-p1". With -p0 patch doesn't remove any prefix
directories and tries to change files b/defines.mk and similar.
--
Vasiliy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: cluts makefiles
2011-08-09 16:11 ` Vasiliy Kulikov
@ 2011-08-09 20:20 ` Luka Marčetić
2011-08-10 3:06 ` Solar Designer
0 siblings, 1 reply; 7+ messages in thread
From: Luka Marčetić @ 2011-08-09 20:20 UTC (permalink / raw)
To: musl
On 08/09/2011 06:11 PM, Vasiliy Kulikov wrote:
>> Hunk #1 FAILED at 7.
>> 1 out of 1 hunk FAILED -- saving rejects to file a/Makefile.rej
> You should use "-p1". With -p0 patch doesn't remove any prefix
> directories and tries to change files b/defines.mk and similar.
Where should this be run? I tried root where a/ and b/ are, and also in
the b/ itself. In both cases, the same thing happens. Maybe it is me who
messed up line 7 now, I don't know. :-/
>>> 2) Used gcc's ability to identify dependencies.
>> Do others free compilers support nr 2?
> Hmm, not sure. I think it is gcc specific thing.
Ideally, I'd use the standard make, but I'm a make noob, so I use the
GNU one. However, I would deprecate a dependency on gcc - I want my C99
code to be compilable with any C99-compliant compiler. If you manage to
remove the dependency on gcc (and instruct me how to apply the patch),
I'll certainly prefer the right(tm) way to build things.
>>> b) SA_NODEFER is undefined in all .c.
>> It should be defined in signal.h. Alexander had problems with this.
> The target system is Ubuntu 10.04, glibc-2.10-1, gcc 4.4.3-4ubuntu5.
Granted, I use kinda beta software (Debian Sid here), but I don't think
that's it. Did you try the POSIX flag?
Thanks again.
Luka
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: cluts makefiles
2011-08-09 20:20 ` Luka Marčetić
@ 2011-08-10 3:06 ` Solar Designer
2011-08-10 11:29 ` Luka Marčetić
0 siblings, 1 reply; 7+ messages in thread
From: Solar Designer @ 2011-08-10 3:06 UTC (permalink / raw)
To: musl
Luka -
On Tue, Aug 09, 2011 at 10:20:24PM +0200, Luka Mar??eti?? wrote:
> On 08/09/2011 06:11 PM, Vasiliy Kulikov wrote:
> >>Hunk #1 FAILED at 7.
> >>1 out of 1 hunk FAILED -- saving rejects to file a/Makefile.rej
> >You should use "-p1". With -p0 patch doesn't remove any prefix
> >directories and tries to change files b/defines.mk and similar.
>
> Where should this be run? I tried root where a/ and b/ are, and also in
> the b/ itself. In both cases, the same thing happens. Maybe it is me who
> messed up line 7 now, I don't know. :-/
To apply a patch, you do not need two trees, and you do not need to
match the top-level directory names to those seen in the patch file.
Rather, you may do something like:
cp -a cluts cluts-to-patch
cd cluts-to-patch
patch -p1 < ../patch-file
or just:
cd cluts
patch -p1 < ../patch-file
but the first approach may be preferable if you haven't yet made the
determination to fully apply the patch to your tree (so you want to
experiment on a copy first).
Here are some instructions/examples on how to generate patches and how
to apply them:
http://openwall.info/wiki/how-to-make-patches
http://openwall.info/wiki/john/how-to-extract-tarballs-and-apply-patches
You may want to experiment with this for your own changes to cluts -
just so that you know how it works - before you apply a patch provided
to you by someone else.
Alexander
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: cluts makefiles
2011-08-10 3:06 ` Solar Designer
@ 2011-08-10 11:29 ` Luka Marčetić
2011-08-10 11:49 ` Solar Designer
0 siblings, 1 reply; 7+ messages in thread
From: Luka Marčetić @ 2011-08-10 11:29 UTC (permalink / raw)
To: musl
On 08/10/2011 05:06 AM, Solar Designer wrote:
> To apply a patch, you do not need two trees, and you do not need to
> match the top-level directory names to those seen in the patch file.
> Rather, you may do something like:
>
> cp -a cluts cluts-to-patch
> cd cluts-to-patch
> patch -p1< ../patch-file
Hmm, I did try`patch -p1 < ../patch-file` *shrugs*
Still, thanks you for the instructions anyway. At least I can be sure
what I'm doing.
Luka
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: cluts makefiles
2011-08-10 11:29 ` Luka Marčetić
@ 2011-08-10 11:49 ` Solar Designer
0 siblings, 0 replies; 7+ messages in thread
From: Solar Designer @ 2011-08-10 11:49 UTC (permalink / raw)
To: musl
On Wed, Aug 10, 2011 at 01:29:31PM +0200, Luka Mar??eti?? wrote:
> On 08/10/2011 05:06 AM, Solar Designer wrote:
> >To apply a patch, you do not need two trees, and you do not need to
> >match the top-level directory names to those seen in the patch file.
> >Rather, you may do something like:
> >
> >cp -a cluts cluts-to-patch
> >cd cluts-to-patch
> >patch -p1< ../patch-file
>
> Hmm, I did try`patch -p1 < ../patch-file` *shrugs*
> Still, thanks you for the instructions anyway. At least I can be sure
> what I'm doing.
Well, it sounds like your source tree was in fact changed from the
revision that Vasiliy's patch was for, then. Such things happen.
Alexander
^ 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).