Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The developer says: http://comments.gmane.org/gmane.linux.real-time.rtnet.user/2546

Now how can I tell the Makefile to look for headers in /usr/local/rtnet/include respectively how could I set my CFLAGS?

EXTRA_CFLAGS := -I ...

Sorry for that not really RTnet dependent question, but I couldn't find a Makefile-howto covering this question.

Maybe this helps, though it a bit more complicated due to serving 2.4 and 2.6 kernels:

So, I took the makefile from here: http://svn.gna.org/viewcvs/xenomai/trunk/examples/rtdm/driver-api/ and added -I /usr/local/rtnet/include corresponding to **EXTRA_CFLAGS**

###### CONFIGURATION ######
### List of applications to be build
APPLICATIONS = hello

### Note: to override the search path for the xeno-config script, use "make XENO=..."


### List of modules to be build
MODULES = hello

### Note: to override the kernel source path, use "make KSRC=..."



###### USER SPACE BUILD (no change required normally) ######
ifeq ($(KERNELRELEASE),)
ifneq ($(APPLICATIONS),)

### Default Xenomai installation path
XENO ?= /usr/xenomai

XENOCONFIG=$(shell PATH=$(XENO):$(XENO)/bin:$(PATH) which xeno-config 2>/dev/null)

### Sanity check
ifeq ($(XENOCONFIG),)
all::
@echo ">>> Invoke make like this: \"make XENO=/path/to/xeno-config\" <<<"
@echo
endif


CC=$(shell $(XENOCONFIG) --cc)

CFLAGS=$(shell $(XENOCONFIG) --skin=native --cflags) $(MY_CFLAGS)

LDFLAGS=$(shell $(XENOCONFIG) --xeno-ldflags) $(MY_LDFLAGS) -lnative -lrtdm

# This includes the library path of given Xenomai into the binary to make live
# easier for beginners if Xenomai's libs are not in any default search path.
LDFLAGS+=-Xlinker -rpath -Xlinker $(shell $(XENOCONFIG) --libdir)

all:: $(APPLICATIONS)

clean::
    $(RM) $(APPLICATIONS) *.o

endif
endif



###### KERNEL MODULE BUILD (no change required normally) ######
ifneq ($(MODULES),)

### Default to sources of currently running kernel
KSRC ?= /lib/modules/$(shell uname -r)/build

OBJS := ${patsubst %, %.o, $(MODULES)}
CLEANMOD := ${patsubst %, .%*, $(MODULES)}
PWD := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)

### Kernel 2.6
ifeq ($(findstring 2.6,$(KSRC)),2.6)

obj-m := $(OBJS)
EXTRA_CFLAGS := -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/posix $(ADD_CFLAGS) \
-I /usr/local/rtnet/include 

all::
    $(MAKE) -C $(KSRC) SUBDIRS=$(PWD) modules

### Kernel 2.4
else

ARCH ?= $(shell uname -i)
INCLUDE := -I$(KSRC)/include/xenomai -I$(KSRC)/include/xenomai/compat -I$(KSRC)/include/xenomai/posix
CFLAGS += $(shell $(MAKE) -s -C $(KSRC) CC=$(CC) ARCH=$(ARCH) SUBDIRS=$(PWD) modules) $(INCLUDE)

all:: $(OBJS)

endif

## Target for capturing 2.4 module CFLAGS
modules:
    @echo "$(CFLAGS)"

clean::
    $(RM) $(CLEANMOD) *.o *.ko *.mod.c Module*.symvers Module.markers modules.order
    $(RM) -R .tmp*

endif

Now, when I do make, I get the error: error: implicit declaration of function ‘rt_dev_socket’ for the following hello.c.

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/timer.h>

#include  <rtdk.h>

RT_TASK demo_task;

void demo(void *arg)
{
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;

  printf("Hello World!\n");

  curtask=rt_task_self();
  rt_task_inquire(curtask,&curtaskinfo);

  printf("Task name : %s \n", curtaskinfo.name);

  ********int sockfd = rt_dev_socket(AF_INET, SOCK_DGRAM, 0);********
}

int main(int argc, char* argv[])
{
  char  str[10] ;

  rt_print_auto_init(1);

  mlockall(MCL_CURRENT|MCL_FUTURE);

  printf("start task\n");

  sprintf(str,"hello");

  rt_task_create(&demo_task, str, 0, 50, 0);

  rt_task_start(&demo_task, &demo, 0);

}
share|improve this question
    
anisha@linux-2gbt:~> ls -R /usr/local/rtnet/include/ /usr/local/rtnet/include/: rtmac.h rtnet.h –  TheIndependentAquarius Jun 25 '12 at 6:23
    
Can you post a self-answer? The existing answer got deleted for just being a link –  Michael Mrozek Jun 26 '12 at 0:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.