avrdude: Standalone binary

This commit is contained in:
Vojtech Kral 2018-06-27 15:02:32 +02:00 committed by bubnikv
parent 6b801f250a
commit 3c2170acf8
3 changed files with 124 additions and 53 deletions

View file

@ -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 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 set(AVRDUDE_SOURCES
${LIBDIR}/avrdude/arduino.c arduino.c
${LIBDIR}/avrdude/avr.c avr.c
# ${LIBDIR}/avrdude/avrftdi.c # avrftdi.c
# ${LIBDIR}/avrdude/avrftdi_tpi.c # avrftdi_tpi.c
${LIBDIR}/avrdude/avrpart.c avrpart.c
${LIBDIR}/avrdude/avr910.c avr910.c
${LIBDIR}/avrdude/bitbang.c bitbang.c
${LIBDIR}/avrdude/buspirate.c buspirate.c
${LIBDIR}/avrdude/butterfly.c butterfly.c
${LIBDIR}/avrdude/config.c config.c
${LIBDIR}/avrdude/config_gram.c config_gram.c
# ${LIBDIR}/avrdude/confwin.c # confwin.c
${LIBDIR}/avrdude/crc16.c crc16.c
# ${LIBDIR}/avrdude/dfu.c # dfu.c
${LIBDIR}/avrdude/fileio.c fileio.c
# ${LIBDIR}/avrdude/flip1.c # flip1.c
# ${LIBDIR}/avrdude/flip2.c # flip2.c
# ${LIBDIR}/avrdude/ft245r.c # ft245r.c
# ${LIBDIR}/avrdude/jtagmkI.c # jtagmkI.c
# ${LIBDIR}/avrdude/jtagmkII.c # jtagmkII.c
# ${LIBDIR}/avrdude/jtag3.c # jtag3.c
${LIBDIR}/avrdude/lexer.c lexer.c
${LIBDIR}/avrdude/linuxgpio.c linuxgpio.c
${LIBDIR}/avrdude/lists.c lists.c
# ${LIBDIR}/avrdude/par.c # par.c
${LIBDIR}/avrdude/pgm.c pgm.c
${LIBDIR}/avrdude/pgm_type.c pgm_type.c
${LIBDIR}/avrdude/pickit2.c pickit2.c
${LIBDIR}/avrdude/pindefs.c pindefs.c
# ${LIBDIR}/avrdude/ppi.c # ppi.c
# ${LIBDIR}/avrdude/ppiwin.c # ppiwin.c
${LIBDIR}/avrdude/safemode.c safemode.c
${LIBDIR}/avrdude/ser_avrdoper.c ser_avrdoper.c
${LIBDIR}/avrdude/serbb_posix.c serbb_posix.c
${LIBDIR}/avrdude/serbb_win32.c serbb_win32.c
${LIBDIR}/avrdude/ser_posix.c ser_posix.c
${LIBDIR}/avrdude/ser_win32.c ser_win32.c
${LIBDIR}/avrdude/stk500.c stk500.c
${LIBDIR}/avrdude/stk500generic.c stk500generic.c
${LIBDIR}/avrdude/stk500v2.c stk500v2.c
${LIBDIR}/avrdude/term.c term.c
${LIBDIR}/avrdude/update.c update.c
# ${LIBDIR}/avrdude/usbasp.c # usbasp.c
# ${LIBDIR}/avrdude/usb_hidapi.c # usb_hidapi.c
# ${LIBDIR}/avrdude/usb_libusb.c # usb_libusb.c
# ${LIBDIR}/avrdude/usbtiny.c # usbtiny.c
${LIBDIR}/avrdude/wiring.c wiring.c
${LIBDIR}/avrdude/main.c main.c
${LIBDIR}/avrdude/avrdude-slic3r.hpp avrdude-slic3r.hpp
${LIBDIR}/avrdude/avrdude-slic3r.cpp avrdude-slic3r.cpp
) )
if (WIN32) if (WIN32)
set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES} set(AVRDUDE_SOURCES ${AVRDUDE_SOURCES}
${LIBDIR}/avrdude/windows/unistd.cpp windows/unistd.cpp
${LIBDIR}/avrdude/windows/getopt.c windows/getopt.c
) )
endif() endif()
add_library(avrdude STATIC ${AVRDUDE_SOURCES}) 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) if (WIN32)
target_compile_definitions(avrdude PRIVATE WIN32NATIVE=1) 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() endif()

View file

@ -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)

View file

@ -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);
}