Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native build fails to build because of pnet module #793

Closed
miri64 opened this issue Feb 26, 2014 · 3 comments · Fixed by #804
Closed

Native build fails to build because of pnet module #793

miri64 opened this issue Feb 26, 2014 · 3 comments · Fixed by #804
Assignees
Labels
Platform: native Platform: This PR/issue effects the native platform Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@miri64
Copy link
Member

miri64 commented Feb 26, 2014

Since pnet redefines unistd.h native fails to build on some machines.
An example is trying to build the 6LoWPAN plugtests from des-testbed/RIOT-projects#97:

make -B clean all
[…]
make[1]: Betrete Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT/boards/native'
make[2]: Betrete Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT/boards/native/drivers'
native-uart0.c: In function ‘uart0_puts’:
native-uart0.c:60:17: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
                 (nwritten = write(
                 ^
native-uart0.c: In function ‘init_unix_socket’:
native-uart0.c:151:5: warning: implicit declaration of function ‘getpid’ [-Wimplicit-function-declaration]
     snprintf(sa.sun_path, sizeof(sa.sun_path), "/tmp/riot.tty.%d", getpid());
     ^
native-uart0.c:152:5: warning: implicit declaration of function ‘unlink’ [-Wimplicit-function-declaration]
     unlink(sa.sun_path); /* remove stale socket */
     ^
native-uart0.c: In function ‘handle_uart_in’:
native-uart0.c:171:5: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
     nread = read(STDIN_FILENO, buf, sizeof(buf));
     ^
native-uart0.c:179:17: warning: implicit declaration of function ‘dup2’ [-Wimplicit-function-declaration]
                 if (dup2(_native_null_out_file, STDOUT_FILENO) == -1) {
                 ^
make[2]: Verlasse Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT/boards/native/drivers'
make[1]: Verlasse Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT/boards/native'
"make" -C /home/martin/Repositories/RIOT-OS/RIOT
make[1]: Betrete Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT'
mkdir -p /home/martin/Repositories/RIOT-OS/projects/6lpplugtest/bin/native/
make[2]: Betrete Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT/cpu/native'
irq_cpu.c: In function ‘native_interrupt_init’:
irq_cpu.c:507:5: warning: implicit declaration of function ‘pipe’ [-Wimplicit-function-declaration]
     if (pipe(_sig_pipefd) == -1) {
     ^
native_cpu.c: In function ‘reboot’:
native_cpu.c:69:5: warning: implicit declaration of function ‘execve’ [-Wimplicit-function-declaration]
     if (execve(_native_argv[0], _native_argv, NULL) == -1) {
     ^
startup.c: In function ‘_native_null_in’:
startup.c:54:5: warning: implicit declaration of function ‘pipe’ [-Wimplicit-function-declaration]
     if (pipe(_native_null_in_pipe) == -1) {
     ^
startup.c:62:5: warning: implicit declaration of function ‘dup2’ [-Wimplicit-function-declaration]
     if (dup2(_native_null_in_pipe[0], STDIN_FILENO) == -1) {
     ^
startup.c: In function ‘_native_log_stdout’:
startup.c:88:9: warning: implicit declaration of function ‘getpid’ [-Wimplicit-function-declaration]
         snprintf(stdout_logname, sizeof(stdout_logname), "/tmp/riot.stdout.%d", getpid());
         ^
startup.c: In function ‘daemonize’:
startup.c:141:5: warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration]
     if ((pid = fork()) == -1) {
     ^
[…]
tap.c: In function ‘send_buf’:
tap.c:222:5: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
     if ((nsent = write(_native_tap_fd, buf, to_send)) == -1) {;
     ^
tap.c: In function ‘tap_init’:
tap.c:308:5: warning: implicit declaration of function ‘getpid’ [-Wimplicit-function-declaration]
     if (fcntl(_native_tap_fd, F_SETOWN, getpid()) == -1) {
     ^
make[3]: *** [/home/martin/Repositories/RIOT-OS/projects/6lpplugtest/bin/native/tap.o] Fehler 1
make[3]: Verlasse Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT/cpu/native/net'
make[2]: *** [all] Fehler 2
make[2]: Verlasse Verzeichnis '/home/martin/Repositories/RIOT-OS/RIOT/cpu/native'
[…]
@LudwigKnuepfer
Copy link
Member

diff --git a/6lpplugtest/Makefile b/6lpplugtest/Makefile
index 2da4c71..27f2a80 100644
--- a/6lpplugtest/Makefile
+++ b/6lpplugtest/Makefile
@@ -165,9 +165,6 @@ else ifeq ($(BOARD),native)
        USEMODULE += nativenet
 endif

-export INCLUDES = -I$(RIOTBASE)/sys/net/include \
-                                 -I$(RIOTBASE)/sys/posix/pnet/include
-
 include $(RIOTBASE)/Makefile.include
diff --git a/cpu/native/net/Makefile b/cpu/native/net/Makefile
index 16c11ee..9b744bc 100644
--- a/cpu/native/net/Makefile
+++ b/cpu/native/net/Makefile
@@ -1,10 +1,11 @@
-EXCLUDES := -I$(RIOTBASE)/sys/posix/%
-
 MODULE = nativenet

 include $(MAKEBASE)/Makefile.base

+NATIVEINCLUDES = $(filter-out -I$(RIOTBASE)/sys/posix% -I$(RIOTBASE)/sys/pkg% -I$(RIOTBASE)/sys/net% , 
+
 $(BINDIR)%.o: %.c
-       $(AD)$(CC) $(CFLAGS) $(filter-out $(EXCLUDES),$(INCLUDES)) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(C
-       @$(CC) $(CFLAGS) $(INCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -MM $*.c > $(BINDIR
+       $(AD)$(CC) $(CFLAGS) $(NATIVEINCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -c $*.c -
+       $(AD)$(CC) $(CFLAGS) $(NATIVEINCLUDES) $(BOARDINCLUDE) $(PROJECTINCLUDE) $(CPUINCLUDE) -MM $*.c 
        @printf "$(BINDIR)" | cat - $(BINDIR)$*.d > /tmp/riot_out && mv /tmp/riot_out $(BINDIR)$*.d
+
diff --git a/pkg/libcoap/Makefile.include b/pkg/libcoap/Makefile.include
index 9e4881d..a6fb43a 100644
--- a/pkg/libcoap/Makefile.include
+++ b/pkg/libcoap/Makefile.include
@@ -1,4 +1,4 @@
-INCLUDES += -I $(RIOTBASE)/pkg/libcoap/libcoap \
-                       -I $(RIOTBASE)/sys/posix/include \
-                       -I $(RIOTBASE)/sys/posix/pnet/include \
-                       -I $(RIOTBASE)/sys/net/include
+INCLUDES += -I$(RIOTBASE)/pkg/libcoap/libcoap \
+                       -I$(RIOTBASE)/sys/posix/include \
+                       -I$(RIOTBASE)/sys/posix/pnet/include \
+                       -I$(RIOTBASE)/sys/net/include

@LudwigKnuepfer
Copy link
Member

#804 fixes this kind of error once and for all.

@OlegHahm OlegHahm added this to the POSIX compliance milestone Feb 28, 2014
@miri64
Copy link
Member Author

miri64 commented Feb 28, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: native Platform: This PR/issue effects the native platform Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants