diff --git a/xs/src/avrdude/CMakeLists.txt b/xs/src/avrdude/CMakeLists.txt index 043f8fb7b..d88563368 100644 --- a/xs/src/avrdude/CMakeLists.txt +++ b/xs/src/avrdude/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.0) add_definitions(-D_BSD_SOURCE -D_DEFAULT_SOURCE) # To enable various useful macros and functions on Unices @@ -13,67 +14,74 @@ endif() set(AVRDUDE_SOURCES - ${LIBDIR}/avrdude/arduino.c - ${LIBDIR}/avrdude/avr.c - # ${LIBDIR}/avrdude/avrftdi.c - # ${LIBDIR}/avrdude/avrftdi_tpi.c - ${LIBDIR}/avrdude/avrpart.c - ${LIBDIR}/avrdude/avr910.c - ${LIBDIR}/avrdude/bitbang.c - ${LIBDIR}/avrdude/buspirate.c - ${LIBDIR}/avrdude/butterfly.c - ${LIBDIR}/avrdude/config.c - ${LIBDIR}/avrdude/config_gram.c - # ${LIBDIR}/avrdude/confwin.c - ${LIBDIR}/avrdude/crc16.c - # ${LIBDIR}/avrdude/dfu.c - ${LIBDIR}/avrdude/fileio.c - # ${LIBDIR}/avrdude/flip1.c - # ${LIBDIR}/avrdude/flip2.c - # ${LIBDIR}/avrdude/ft245r.c - # ${LIBDIR}/avrdude/jtagmkI.c - # ${LIBDIR}/avrdude/jtagmkII.c - # ${LIBDIR}/avrdude/jtag3.c - ${LIBDIR}/avrdude/lexer.c - ${LIBDIR}/avrdude/linuxgpio.c - ${LIBDIR}/avrdude/lists.c - # ${LIBDIR}/avrdude/par.c - ${LIBDIR}/avrdude/pgm.c - ${LIBDIR}/avrdude/pgm_type.c - ${LIBDIR}/avrdude/pickit2.c - ${LIBDIR}/avrdude/pindefs.c - # ${LIBDIR}/avrdude/ppi.c - # ${LIBDIR}/avrdude/ppiwin.c - ${LIBDIR}/avrdude/safemode.c - ${LIBDIR}/avrdude/ser_avrdoper.c - ${LIBDIR}/avrdude/serbb_posix.c - ${LIBDIR}/avrdude/serbb_win32.c - ${LIBDIR}/avrdude/ser_posix.c - ${LIBDIR}/avrdude/ser_win32.c - ${LIBDIR}/avrdude/stk500.c - ${LIBDIR}/avrdude/stk500generic.c - ${LIBDIR}/avrdude/stk500v2.c - ${LIBDIR}/avrdude/term.c - ${LIBDIR}/avrdude/update.c - # ${LIBDIR}/avrdude/usbasp.c - # ${LIBDIR}/avrdude/usb_hidapi.c - # ${LIBDIR}/avrdude/usb_libusb.c - # ${LIBDIR}/avrdude/usbtiny.c - ${LIBDIR}/avrdude/wiring.c + arduino.c + avr.c + # avrftdi.c + # avrftdi_tpi.c + avrpart.c + avr910.c + bitbang.c + buspirate.c + butterfly.c + config.c + config_gram.c + # confwin.c + crc16.c + # dfu.c + fileio.c + # flip1.c + # flip2.c + # ft245r.c + # jtagmkI.c + # jtagmkII.c + # jtag3.c + lexer.c + linuxgpio.c + lists.c + # par.c + pgm.c + pgm_type.c + pickit2.c + pindefs.c + # ppi.c + # ppiwin.c + safemode.c + ser_avrdoper.c + serbb_posix.c + serbb_win32.c + ser_posix.c + ser_win32.c + stk500.c + stk500generic.c + stk500v2.c + term.c + update.c + # usbasp.c + # usb_hidapi.c + # usb_libusb.c + # usbtiny.c + wiring.c - ${LIBDIR}/avrdude/main.c - ${LIBDIR}/avrdude/avrdude-slic3r.hpp - ${LIBDIR}/avrdude/avrdude-slic3r.cpp + main.c + avrdude-slic3r.hpp + avrdude-slic3r.cpp ) if (WIN32) set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES} - ${LIBDIR}/avrdude/windows/unistd.cpp - ${LIBDIR}/avrdude/windows/getopt.c + windows/unistd.cpp + windows/getopt.c ) endif() add_library(avrdude STATIC ${AVRDUDE_SOURCES}) +set(STANDALONE_SOURCES + main-standalone.c +) +add_executable(avrdude-slic3r ${STANDALONE_SOURCES}) +target_link_libraries(avrdude-slic3r avrdude) +set_target_properties(avrdude-slic3r PROPERTIES EXCLUDE_FROM_ALL TRUE) + if (WIN32) target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1) - target_include_directories(avrdude SYSTEM PRIVATE ${LIBDIR}/avrdude/windows) # So that sources find the getopt.h windows drop-in + target_include_directories(avrdude SYSTEM PRIVATE windows) # So that sources find the getopt.h windows drop-in endif() diff --git a/xs/src/avrdude/Makefile.standalone b/xs/src/avrdude/Makefile.standalone new file mode 100644 index 000000000..d9a773771 --- /dev/null +++ b/xs/src/avrdude/Makefile.standalone @@ -0,0 +1,54 @@ + +TARGET = avrdude-slic3r + +SOURCES = \ + arduino.c \ + avr.c \ + avrpart.c \ + avr910.c \ + bitbang.c \ + buspirate.c \ + butterfly.c \ + config.c \ + config_gram.c \ + crc16.c \ + fileio.c \ + lexer.c \ + linuxgpio.c \ + lists.c \ + pgm.c \ + pgm_type.c \ + pickit2.c \ + pindefs.c \ + safemode.c \ + ser_avrdoper.c \ + serbb_posix.c \ + serbb_win32.c \ + ser_posix.c \ + ser_win32.c \ + stk500.c \ + stk500generic.c \ + stk500v2.c \ + term.c \ + update.c \ + wiring.c \ + main.c \ + main-standalone.c + +OBJECTS = $(SOURCES:.c=.o) +CFLAGS = -std=c99 -Wall -D_BSD_SOURCE -D_DEFAULT_SOURCE -O3 -DNDEBUG -fPIC +LDFLAGS = -lm + +CC = gcc +RM = rm + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) -o ./$@ $(OBJECTS) $(LDFLAGS) + +$(OBJECTS): %.o: %.c + $(CC) $(CFLAGS) -o $@ -c $< + +clean: + $(RM) -f $(OBJECTS) $(TARGET) diff --git a/xs/src/avrdude/main-standalone.c b/xs/src/avrdude/main-standalone.c new file mode 100644 index 000000000..359a055ca --- /dev/null +++ b/xs/src/avrdude/main-standalone.c @@ -0,0 +1,9 @@ +#include "avrdude.h" + + +static const char* SYS_CONFIG = "/etc/avrdude-slic3r.conf"; + +int main(int argc, char *argv[]) +{ + return avrdude_main(argc, argv, SYS_CONFIG); +}