:: Re: [DNG] Pointer error in the back…
Forside
Slet denne besked
Besvar denne besked
Skribent: Rainer Weikusat
Dato:  
Til: dng
Emne: Re: [DNG] Pointer error in the backend of Netman
Edward Bartolo <edbarx@???> writes:
> Hi Rainer,
>
> This is Makefile from netman:
>
> ---------------------------------------------------
> all: backend netman
>
> backend:
>         make -C backend_src
>         cp backend_src/bin/backend .

>
> netman: netman.lpr
>         lazbuild -B netman.lpr | awk '/./{print $$0}'

>
> clean:
>         make -C backend_src clean
>         rm -f lib/*/*.*
>         rm -f backend netman

>
> .PHONY: all clean
> ---------------------------------
>
> Please tell me what I should change.


The issues are with the backend_src Makefile which looks like this:

----------------
# Makefile for cli_backend

CC=gcc

OBJECTS=\
        obj/backend.o \
        obj/caller.o \
        obj/core_functions.o \
        obj/file_functions.o \
        obj/essid_encoder.o


CFLAGS += -Wall -Wextra -Iinclude -g -O2
#CFLAGS += -Wall -Wextra -Iinclude -ggdb

all: $(OBJECTS) bin/backend

clean:
        rm -f $(OBJECTS) bin/backend


bin/backend: $(OBJECTS)
        $(CC) -o $@ $(OBJECTS)


obj/%.o : src/%.c
        $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<


-----------------

Problems with this: OBJECTS doesn't contain automated_scanner.o, leading
to a link failure and the linker command (bin/backend target) is missing
a -lm in order to link with the math library (for the pow
function). Further, the obj and bin directories don't exist.

Below is a git-created patch addressing all this (using Timo Burmester's
idea of creating the directories via Makefile as that's less manual
work):

-----------------
diff --git a/backend_src/Makefile b/backend_src/Makefile
index 0b48a1d..ffcaa52 100644
--- a/backend_src/Makefile
+++ b/backend_src/Makefile
@@ -7,7 +7,8 @@ OBJECTS=\
     obj/caller.o \
     obj/core_functions.o \
     obj/file_functions.o \
-    obj/essid_encoder.o
+    obj/essid_encoder.o \
+    obj/automated_scanner.o


 CFLAGS += -Wall -Wextra -Iinclude -g -O2
 #CFLAGS += -Wall -Wextra -Iinclude -ggdb
@@ -17,9 +18,11 @@ all: $(OBJECTS) bin/backend
 clean:
     rm -f $(OBJECTS) bin/backend


-bin/backend: $(OBJECTS)
-    $(CC) -o $@ $(OBJECTS)
+bin/backend: $(OBJECTS) bin
+    $(CC) -o $@ $(OBJECTS) -lm


-obj/%.o : src/%.c
+obj/%.o : src/%.c obj
     $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<


+bin obj:
+    mkdir $@
-------------------


In order to apply this, save it to a file, say, /tmp/nm.diff. Go to the
top-level netman directory and run

patch -p1 </tmp/nm.diff

And check the modified backen_src/Makefile into git with some commit
message of your liking.

NB: The patch is a bit overkill here but as the procedure is pretty much
standard for communicating changes to some source tree, I thought you'd
be interested in it.