Compile own driver. How to Makefile?
- AndrewHsasku
- Offline
- Junior Member
Less
More
- Posts: 23
- Thank you received: 0
04 Dec 2017 23:23 - 04 Dec 2017 23:24 #102682
by AndrewHsasku
Compile own driver. How to Makefile? was created by AndrewHsasku
I am trying to prepare own driver for canopen.
I have no idea how (where) to compile my files.
My makefile, based on EtherCAT HAL makefile, looks like below:
Of course, resulting in error in first line of my code where I import hal.h. File is not found.
Please attach example makefile.
I have no idea how (where) to compile my files.
My makefile, based on EtherCAT HAL makefile, looks like below:
.PHONY: install clean
EXTRA_CFLAGS := $(filter-out -Wframe-larger-than=%,$(EXTRA_CFLAGS))
install: canopen_driver
echo "DESTDIR = $(DESTDIR)"
echo "EMC2_HOME = $(EMC2_HOME)"
mkdir -p $(DESTDIR)$(EMC2_HOME)/bin
cp canopen_driver $(DESTDIR)$(EMC2_HOME)/bin/
canopen_driver: canopen_driver.o
$(CC) -o $@ $< -Wl,-rpath,$(LIBDIR) -L$(LIBDIR) -llinuxcnchal -lexpat
%.o: %.c
$(CC) -o $@ $(EXTRA_CFLAGS) -URTAPI -U__MODULE__ -DULAPI -Os -c $<
clean:
rm -f *.so *.ko *.o
rm -f *.mod.c .*.cmd
rm -f modules.order Module.symvers
rm -rf .tmp_versions
rm -f canopen_driver
Of course, resulting in error in first line of my code where I import hal.h. File is not found.
Please attach example makefile.
Last edit: 04 Dec 2017 23:24 by AndrewHsasku.
Please Log in or Create an account to join the conversation.
06 Dec 2017 17:31 #102727
by andypugh
Replied by andypugh on topic Compile own driver. How to Makefile?
You could try compiling with halcompile, that might work.
Otherwise I have always tended to accept adding the new driver to the source tree and then adding it to the main LinuxCNC Makefiles. If you intend to add the driver to LinuxCNC then this is probably the best way to be sure that it is compatible anyway.
Otherwise I have always tended to accept adding the new driver to the source tree and then adding it to the main LinuxCNC Makefiles. If you intend to add the driver to LinuxCNC then this is probably the best way to be sure that it is compatible anyway.
Please Log in or Create an account to join the conversation.
Time to create page: 0.054 seconds