* [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions
@ 2012-10-17 19:55 Sven Eckelmann
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V Sven Eckelmann
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Sven Eckelmann @ 2012-10-17 19:55 UTC (permalink / raw)
To: b.a.t.m.a.n
Distributions must be able to easily set CPPFLAGS, CFLAGS and LDFLAGS to have
full control about optimization or security related flags. It is also necessary
to be able to install all files.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
Makefile | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 80 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
index 92299ac..9796528 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,81 @@
-LDFLAGS=-ggdb -static
-CFLAGS=-O2 -Wall -ggdb
-BIN=alfred
-OBJS=main.o server.o client.o netsock.o send.o recv.o hash.o unix_sock.o util.o
-default: all
-all: $(BIN)
-$(BIN): $(OBJS)
- gcc $(LDFLAGS) $(OBJS) -o $(BIN)
-.c.o:
- gcc $(CFLAGS) -o $@ -c $<
+#!/usr/bin/make -f
+# -*- makefile -*-
+#
+# Copyright (C) 2012 B.A.T.M.A.N. contributors
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public
+# License as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA
+#
+
+# alfred build
+BINARY_NAME = alfred
+OBJ = main.o server.o client.o netsock.o send.o recv.o hash.o unix_sock.o util.o
+
+# alfred flags and options
+CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD
+LDLIBS +=
+
+# disable verbose output
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+ Q_CC = @echo ' ' CC $@;
+ Q_LD = @echo ' ' LD $@;
+ export Q_CC
+ export Q_LD
+endif
+endif
+
+# standard build tools
+CC ?= gcc
+RM ?= rm -f
+INSTALL ?= install
+MKDIR ?= mkdir -p
+COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
+LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
+
+# standard install paths
+PREFIX = /usr/local
+SBINDIR = $(PREFIX)/sbin
+
+# try to generate revision
+REVISION= $(shell if [ -d .git ]; then \
+ echo $$(git describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \
+ fi)
+ifneq ($(REVISION),)
+CPPFLAGS += -DSOURCE_VERSION=\"$(REVISION)\"
+endif
+
+# default target
+all: $(BINARY_NAME)
+
+# standard build rules
+.SUFFIXES: .o .c
+.c.o:
+ $(COMPILE.c) -o $@ $<
+
+$(BINARY_NAME): $(OBJ)
+ $(LINK.o) $^ $(LDLIBS) -o $@
+
clean:
- rm -f $(BIN) $(OBJS)
+ $(RM) $(BINARY_NAME) $(OBJ) $(DEP)
+
+install: $(BINARY_NAME)
+ $(MKDIR) $(DESTDIR)$(SBINDIR)
+ $(INSTALL) -m 0755 $(BINARY_NAME) $(DESTDIR)$(SBINDIR)
+
+# load dependencies
+DEP = $(OBJ:.o=.d)
+-include $(DEP)
+
+.PHONY: all clean install
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V
2012-10-17 19:55 [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Sven Eckelmann
@ 2012-10-17 19:55 ` Sven Eckelmann
2012-10-17 20:17 ` Simon Wunderlich
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 3/4] alfred: Test for failed global memory allocation Sven Eckelmann
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Sven Eckelmann @ 2012-10-17 19:55 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/main.c b/main.c
index 0315fe3..96e401a 100644
--- a/main.c
+++ b/main.c
@@ -78,7 +78,7 @@ struct globals *alfred_init(int argc, char *argv[])
globals->best_server = NULL;
globals->clientmode_version = 0;
- while ((opt = getopt_long(argc, argv, "ms:r:hi:", long_options,
+ while ((opt = getopt_long(argc, argv, "ms:r:hi:vV:", long_options,
&opt_ind)) != -1) {
switch (opt) {
case 'r':
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [B.A.T.M.A.N.] [PATCH 3/4] alfred: Test for failed global memory allocation
2012-10-17 19:55 [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Sven Eckelmann
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V Sven Eckelmann
@ 2012-10-17 19:55 ` Sven Eckelmann
2012-10-17 20:17 ` Simon Wunderlich
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 4/4] alfred: Fix test for failed sendbuf allocation Sven Eckelmann
2012-10-17 20:16 ` [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Simon Wunderlich
3 siblings, 1 reply; 8+ messages in thread
From: Sven Eckelmann @ 2012-10-17 19:55 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
index 96e401a..ccb72cd 100644
--- a/main.c
+++ b/main.c
@@ -67,11 +67,11 @@ struct globals *alfred_init(int argc, char *argv[])
};
globals = malloc(sizeof(*globals));
- memset(globals, 0, sizeof(*globals));
-
if (!globals)
return NULL;
+ memset(globals, 0, sizeof(*globals));
+
globals->opmode = OPMODE_SLAVE;
globals->clientmode = CLIENT_NONE;
globals->interface = NULL;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [B.A.T.M.A.N.] [PATCH 4/4] alfred: Fix test for failed sendbuf allocation
2012-10-17 19:55 [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Sven Eckelmann
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V Sven Eckelmann
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 3/4] alfred: Test for failed global memory allocation Sven Eckelmann
@ 2012-10-17 19:55 ` Sven Eckelmann
2012-10-17 20:18 ` Simon Wunderlich
2012-10-17 20:16 ` [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Simon Wunderlich
3 siblings, 1 reply; 8+ messages in thread
From: Sven Eckelmann @ 2012-10-17 19:55 UTC (permalink / raw)
To: b.a.t.m.a.n
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
recv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/recv.c b/recv.c
index dce7e50..8ddf7ab 100644
--- a/recv.c
+++ b/recv.c
@@ -217,7 +217,7 @@ int send_alfred_packet(struct globals *globals, uint8_t *dest, void *buf,
char *sendbuf;
sendbuf = malloc(sizeof(*ethhdr) + length);
- if (!buf)
+ if (!sendbuf)
return -1;
ethhdr = (struct ethhdr *)sendbuf;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions
2012-10-17 19:55 [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Sven Eckelmann
` (2 preceding siblings ...)
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 4/4] alfred: Fix test for failed sendbuf allocation Sven Eckelmann
@ 2012-10-17 20:16 ` Simon Wunderlich
3 siblings, 0 replies; 8+ messages in thread
From: Simon Wunderlich @ 2012-10-17 20:16 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
[-- Attachment #1: Type: text/plain, Size: 3355 bytes --]
Applied in revision fd9df5a.
Thanks,
Simon
On Wed, Oct 17, 2012 at 09:55:55PM +0200, Sven Eckelmann wrote:
> Distributions must be able to easily set CPPFLAGS, CFLAGS and LDFLAGS to have
> full control about optimization or security related flags. It is also necessary
> to be able to install all files.
>
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> Makefile | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 80 insertions(+), 11 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 92299ac..9796528 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1,12 +1,81 @@
> -LDFLAGS=-ggdb -static
> -CFLAGS=-O2 -Wall -ggdb
> -BIN=alfred
> -OBJS=main.o server.o client.o netsock.o send.o recv.o hash.o unix_sock.o util.o
> -default: all
> -all: $(BIN)
> -$(BIN): $(OBJS)
> - gcc $(LDFLAGS) $(OBJS) -o $(BIN)
> -.c.o:
> - gcc $(CFLAGS) -o $@ -c $<
> +#!/usr/bin/make -f
> +# -*- makefile -*-
> +#
> +# Copyright (C) 2012 B.A.T.M.A.N. contributors
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of version 2 of the GNU General Public
> +# License as published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +# General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +# 02110-1301, USA
> +#
> +
> +# alfred build
> +BINARY_NAME = alfred
> +OBJ = main.o server.o client.o netsock.o send.o recv.o hash.o unix_sock.o util.o
> +
> +# alfred flags and options
> +CFLAGS += -pedantic -Wall -W -std=gnu99 -fno-strict-aliasing -MD
> +LDLIBS +=
> +
> +# disable verbose output
> +ifneq ($(findstring $(MAKEFLAGS),s),s)
> +ifndef V
> + Q_CC = @echo ' ' CC $@;
> + Q_LD = @echo ' ' LD $@;
> + export Q_CC
> + export Q_LD
> +endif
> +endif
> +
> +# standard build tools
> +CC ?= gcc
> +RM ?= rm -f
> +INSTALL ?= install
> +MKDIR ?= mkdir -p
> +COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
> +LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
> +
> +# standard install paths
> +PREFIX = /usr/local
> +SBINDIR = $(PREFIX)/sbin
> +
> +# try to generate revision
> +REVISION= $(shell if [ -d .git ]; then \
> + echo $$(git describe --always --dirty --match "v*" |sed 's/^v//' 2> /dev/null || echo "[unknown]"); \
> + fi)
> +ifneq ($(REVISION),)
> +CPPFLAGS += -DSOURCE_VERSION=\"$(REVISION)\"
> +endif
> +
> +# default target
> +all: $(BINARY_NAME)
> +
> +# standard build rules
> +.SUFFIXES: .o .c
> +.c.o:
> + $(COMPILE.c) -o $@ $<
> +
> +$(BINARY_NAME): $(OBJ)
> + $(LINK.o) $^ $(LDLIBS) -o $@
> +
> clean:
> - rm -f $(BIN) $(OBJS)
> + $(RM) $(BINARY_NAME) $(OBJ) $(DEP)
> +
> +install: $(BINARY_NAME)
> + $(MKDIR) $(DESTDIR)$(SBINDIR)
> + $(INSTALL) -m 0755 $(BINARY_NAME) $(DESTDIR)$(SBINDIR)
> +
> +# load dependencies
> +DEP = $(OBJ:.o=.d)
> +-include $(DEP)
> +
> +.PHONY: all clean install
> --
> 1.7.10.4
>
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V Sven Eckelmann
@ 2012-10-17 20:17 ` Simon Wunderlich
0 siblings, 0 replies; 8+ messages in thread
From: Simon Wunderlich @ 2012-10-17 20:17 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
[-- Attachment #1: Type: text/plain, Size: 734 bytes --]
Applied in revision 3c2de69.
Thanks,
Simon
On Wed, Oct 17, 2012 at 09:55:56PM +0200, Sven Eckelmann wrote:
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/main.c b/main.c
> index 0315fe3..96e401a 100644
> --- a/main.c
> +++ b/main.c
> @@ -78,7 +78,7 @@ struct globals *alfred_init(int argc, char *argv[])
> globals->best_server = NULL;
> globals->clientmode_version = 0;
>
> - while ((opt = getopt_long(argc, argv, "ms:r:hi:", long_options,
> + while ((opt = getopt_long(argc, argv, "ms:r:hi:vV:", long_options,
> &opt_ind)) != -1) {
> switch (opt) {
> case 'r':
> --
> 1.7.10.4
>
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH 3/4] alfred: Test for failed global memory allocation
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 3/4] alfred: Test for failed global memory allocation Sven Eckelmann
@ 2012-10-17 20:17 ` Simon Wunderlich
0 siblings, 0 replies; 8+ messages in thread
From: Simon Wunderlich @ 2012-10-17 20:17 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
[-- Attachment #1: Type: text/plain, Size: 757 bytes --]
Applied in revision 09c40ac.
Thanks,
Simon
On Wed, Oct 17, 2012 at 09:55:57PM +0200, Sven Eckelmann wrote:
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> main.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/main.c b/main.c
> index 96e401a..ccb72cd 100644
> --- a/main.c
> +++ b/main.c
> @@ -67,11 +67,11 @@ struct globals *alfred_init(int argc, char *argv[])
> };
>
> globals = malloc(sizeof(*globals));
> - memset(globals, 0, sizeof(*globals));
> -
> if (!globals)
> return NULL;
>
> + memset(globals, 0, sizeof(*globals));
> +
> globals->opmode = OPMODE_SLAVE;
> globals->clientmode = CLIENT_NONE;
> globals->interface = NULL;
> --
> 1.7.10.4
>
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH 4/4] alfred: Fix test for failed sendbuf allocation
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 4/4] alfred: Fix test for failed sendbuf allocation Sven Eckelmann
@ 2012-10-17 20:18 ` Simon Wunderlich
0 siblings, 0 replies; 8+ messages in thread
From: Simon Wunderlich @ 2012-10-17 20:18 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
Applied in revision 4f92363.
Thanks,
Simon
On Wed, Oct 17, 2012 at 09:55:58PM +0200, Sven Eckelmann wrote:
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> recv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/recv.c b/recv.c
> index dce7e50..8ddf7ab 100644
> --- a/recv.c
> +++ b/recv.c
> @@ -217,7 +217,7 @@ int send_alfred_packet(struct globals *globals, uint8_t *dest, void *buf,
> char *sendbuf;
>
> sendbuf = malloc(sizeof(*ethhdr) + length);
> - if (!buf)
> + if (!sendbuf)
> return -1;
>
> ethhdr = (struct ethhdr *)sendbuf;
> --
> 1.7.10.4
>
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-10-17 20:18 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 19:55 [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Sven Eckelmann
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 2/4] alfred: Fix parsing of short program parameter -v and -V Sven Eckelmann
2012-10-17 20:17 ` Simon Wunderlich
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 3/4] alfred: Test for failed global memory allocation Sven Eckelmann
2012-10-17 20:17 ` Simon Wunderlich
2012-10-17 19:55 ` [B.A.T.M.A.N.] [PATCH 4/4] alfred: Fix test for failed sendbuf allocation Sven Eckelmann
2012-10-17 20:18 ` Simon Wunderlich
2012-10-17 20:16 ` [B.A.T.M.A.N.] [PATCH 1/4] alfred: Prepare makefile for distibutions Simon Wunderlich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox