diff --git a/Makefile b/Makefile index d7fb071766493c25758fb6aee850653fd6b9d73b..0141bef55d46fcdddaf46bf4885e0c1e16eec421 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ OBJS = chipset_enable.o board_enable.o udelay.o jedec.o stm50flw0x0x.o \ sst49lfxxxc.o sst_fwhub.o layout.o cbtable.o flashchips.o physmap.o \ flashrom.o w39v080fa.o sharplhf00l04.o w29ee011.o spi.o it87spi.o \ ichspi.o w39v040c.o sb600spi.o wbsio_spi.o m29f002.o internal.o \ - dummyflasher.o pcidev.o nic3com.o satasii.o ft2232_spi.o serprog.o \ + dummyflasher.o pcidev.o nic3com.o satasii.o ft2232_spi.o \ print.o all: pciutils features dep $(PROGRAM) @@ -64,14 +64,20 @@ VERSION := 0.9.0-r$(SVNVERSION) SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"' -$(PROGRAM): $(OBJS) - $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) $(FEATURE_LIBS) - -FEATURE_CFLAGS = $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'FT2232_SPI_SUPPORT=1'") # Always enable serprog for now. Needs to be disabled on Windows. +CONFIG_SERPROG = yes + +ifeq ($(CONFIG_SERPROG), yes) FEATURE_CFLAGS += -D'SERPROG_SUPPORT=1' +OBJS += serprog.o +endif -FEATURE_LIBS = $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-lftdi") +FEATURE_CFLAGS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-D'FT2232_SPI_SUPPORT=1'") + +FEATURE_LIBS += $(shell LC_ALL=C grep -q "FTDISUPPORT := yes" .features && printf "%s" "-lftdi") + +$(PROGRAM): $(OBJS) + $(CC) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS) $(FEATURE_LIBS) # TAROPTIONS reduces information leakage from the packager's system. # If other tar programs support command line arguments for setting uid/gid of diff --git a/flash.h b/flash.h index dc0daef51828fb8717b8c4c209760ae035e985e8..13564e18f51d69645df966ce06111dd4d8fbe476 100644 --- a/flash.h +++ b/flash.h @@ -87,7 +87,9 @@ enum programmer { PROGRAMMER_SATASII, PROGRAMMER_IT87SPI, PROGRAMMER_FT2232SPI, +#if SERPROG_SUPPORT == 1 PROGRAMMER_SERPROG, +#endif PROGRAMMER_INVALID /* This must always be the last entry. */ }; diff --git a/flashrom.c b/flashrom.c index 217701aedc51b24c3fd64207c3a50b85b896a2cf..7133145b8f21ac62794207b6798d05a2d3470bc1 100644 --- a/flashrom.c +++ b/flashrom.c @@ -139,6 +139,7 @@ const struct programmer_entry programmer_table[] = { .delay = internal_delay, }, +#if SERPROG_SUPPORT == 1 { .name = "serprog", .init = serprog_init, @@ -155,6 +156,7 @@ const struct programmer_entry programmer_table[] = { .chip_writen = fallback_chip_writen, .delay = serprog_delay, }, +#endif {}, /* This entry corresponds to PROGRAMMER_INVALID. */ }; diff --git a/serprog.c b/serprog.c index d76cbe5f5919c8e1b83c9d70623c4bb627c0cccd..23e1a0cc26c2730d23b32340e1e3ddfd05735fdd 100644 --- a/serprog.c +++ b/serprog.c @@ -23,9 +23,6 @@ #include <stdlib.h> #include <unistd.h> #include "flash.h" - -#if SERPROG_SUPPORT == 1 - #include <string.h> #include <ctype.h> #include <fcntl.h> @@ -774,42 +771,3 @@ void serprog_delay(int delay) sp_opbuf_usage += 5; sp_prev_was_write = 0; } - -#else - -int serprog_init(void) -{ - fprintf(stderr, "Serial programmer support was not compiled in\n"); - exit(1); -} - -int serprog_shutdown(void) -{ - fprintf(stderr, "Serial programmer support was not compiled in\n"); - exit(1); -} - -void serprog_chip_writeb(uint8_t val, chipaddr addr) -{ - fprintf(stderr, "Serial programmer support was not compiled in\n"); - exit(1); -} - -uint8_t serprog_chip_readb(const chipaddr addr) -{ - fprintf(stderr, "Serial programmer support was not compiled in\n"); - exit(1); -} - -void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len) -{ - fprintf(stderr, "Serial programmer support was not compiled in\n"); - exit(1); -} - -void serprog_delay(int delay) -{ - fprintf(stderr, "Serial programmer support was not compiled in\n"); - exit(1); -} -#endif