From 008185cf06750c2d3858d707dba480305e51a70c Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周日, 19 4月 2015 05:20:37 +0800 Subject: [PATCH] Remove generationg .so and update makefiles --- examples/Makefile | 8 +++- examples/test-tcp-srq/Makefile | 5 +- libscpi/Makefile | 26 ++----------- examples/test-interactive/Makefile | 5 +- examples/test-parser/Makefile | 5 +- examples/test-parser/main.c | 2 examples/test-tcp/Makefile | 5 +- Makefile | 4 ++ examples/test-tcp/main.c | 2 examples/test-interactive/main.c | 6 ++- examples/test-tcp-srq/main.c | 2 examples/common/scpi-def.c | 2 12 files changed, 34 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 1f6ee32..9b011c7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +.PHONY: clean all test all: $(MAKE) -C libscpi @@ -6,3 +7,6 @@ clean: $(MAKE) clean -C libscpi $(MAKE) clean -C examples + +test: + $(MAKE) test -C libscpi \ No newline at end of file diff --git a/examples/Makefile b/examples/Makefile index 7ba0bdb..462e256 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,10 +1,14 @@ +.PHONY: clean all cli tcp -all: +all: cli tcp + +cli: $(MAKE) -C test-interactive $(MAKE) -C test-parser + +tcp: $(MAKE) -C test-tcp $(MAKE) -C test-tcp-srq - clean: $(MAKE) clean -C test-interactive diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c index 9e3cc5d..8b1c803 100644 --- a/examples/common/scpi-def.c +++ b/examples/common/scpi-def.c @@ -147,7 +147,7 @@ return SCPI_RES_ERR; } - fprintf(stderr, "\tP1=%s (%d)\r\n", trigger_source[param], param); + fprintf(stderr, "\tP1=%s (%ld)\r\n", trigger_source[param], (long int)param); SCPI_ResultInt(context, param); diff --git a/examples/test-interactive/Makefile b/examples/test-interactive/Makefile index 1d225a9..3338b7b 100644 --- a/examples/test-interactive/Makefile +++ b/examples/test-interactive/Makefile @@ -3,8 +3,9 @@ SRCS = main.c ../common/scpi-def.c CFLAGS += -Wextra -I ../../libscpi/inc/ -LDFLAGS += ../../libscpi/dist/libscpi.a +LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed +.PHONY: clean all all: $(PROG) @@ -14,7 +15,7 @@ $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< $(PROG): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) + $(CC) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS) clean: $(RM) $(PROG) $(OBJS) diff --git a/examples/test-interactive/main.c b/examples/test-interactive/main.c index b149558..2aabd1a 100644 --- a/examples/test-interactive/main.c +++ b/examples/test-interactive/main.c @@ -52,7 +52,7 @@ int SCPI_Error(scpi_t * context, int_fast16_t err) { (void) context; - fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err)); + fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err)); return 0; } @@ -92,7 +92,9 @@ printf("SCPI Interactive demo\r\n"); char smbuffer[10]; while (1) { - fgets(smbuffer, 10, stdin); + if (NULL == fgets(smbuffer, 10, stdin)) { + break; + } SCPI_Input(&scpi_context, smbuffer, strlen(smbuffer)); } diff --git a/examples/test-parser/Makefile b/examples/test-parser/Makefile index 1d225a9..3338b7b 100644 --- a/examples/test-parser/Makefile +++ b/examples/test-parser/Makefile @@ -3,8 +3,9 @@ SRCS = main.c ../common/scpi-def.c CFLAGS += -Wextra -I ../../libscpi/inc/ -LDFLAGS += ../../libscpi/dist/libscpi.a +LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed +.PHONY: clean all all: $(PROG) @@ -14,7 +15,7 @@ $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< $(PROG): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) + $(CC) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS) clean: $(RM) $(PROG) $(OBJS) diff --git a/examples/test-parser/main.c b/examples/test-parser/main.c index 0ab2b2a..35f8341 100644 --- a/examples/test-parser/main.c +++ b/examples/test-parser/main.c @@ -52,7 +52,7 @@ int SCPI_Error(scpi_t * context, int_fast16_t err) { (void) context; - fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err)); + fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err)); return 0; } diff --git a/examples/test-tcp-srq/Makefile b/examples/test-tcp-srq/Makefile index 1d225a9..3338b7b 100644 --- a/examples/test-tcp-srq/Makefile +++ b/examples/test-tcp-srq/Makefile @@ -3,8 +3,9 @@ SRCS = main.c ../common/scpi-def.c CFLAGS += -Wextra -I ../../libscpi/inc/ -LDFLAGS += ../../libscpi/dist/libscpi.a +LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed +.PHONY: clean all all: $(PROG) @@ -14,7 +15,7 @@ $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< $(PROG): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) + $(CC) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS) clean: $(RM) $(PROG) $(OBJS) diff --git a/examples/test-tcp-srq/main.c b/examples/test-tcp-srq/main.c index 0837e95..8a62f58 100644 --- a/examples/test-tcp-srq/main.c +++ b/examples/test-tcp-srq/main.c @@ -84,7 +84,7 @@ int SCPI_Error(scpi_t * context, int_fast16_t err) { (void) context; // BEEP - fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err)); + fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err)); return 0; } diff --git a/examples/test-tcp/Makefile b/examples/test-tcp/Makefile index 1d225a9..3338b7b 100644 --- a/examples/test-tcp/Makefile +++ b/examples/test-tcp/Makefile @@ -3,8 +3,9 @@ SRCS = main.c ../common/scpi-def.c CFLAGS += -Wextra -I ../../libscpi/inc/ -LDFLAGS += ../../libscpi/dist/libscpi.a +LDFLAGS += ../../libscpi/dist/libscpi.a -Wl,--as-needed +.PHONY: clean all all: $(PROG) @@ -14,7 +15,7 @@ $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< $(PROG): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) + $(CC) -o $@ $(OBJS) $(CFLAGS) $(LDFLAGS) clean: $(RM) $(PROG) $(OBJS) diff --git a/examples/test-tcp/main.c b/examples/test-tcp/main.c index 2336165..fcd339e 100644 --- a/examples/test-tcp/main.c +++ b/examples/test-tcp/main.c @@ -63,7 +63,7 @@ int SCPI_Error(scpi_t * context, int_fast16_t err) { (void) context; // BEEP - fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int32_t) err, SCPI_ErrorTranslate(err)); + fprintf(stderr, "**ERROR: %d, \"%s\"\r\n", (int16_t) err, SCPI_ErrorTranslate(err)); return 0; } diff --git a/libscpi/Makefile b/libscpi/Makefile index c256198..4a79b9a 100644 --- a/libscpi/Makefile +++ b/libscpi/Makefile @@ -1,24 +1,16 @@ - -VERSION = 0.3.0 LIBNAME = scpi - -CFLAGS += -Wextra -O1 -g -fPIC -Iinc +CFLAGS += -Wextra -g -Iinc LDFLAGS += -Wl,--as-needed -TESTFLAGS += -lcunit +TESTFLAGS += -lcunit $(CFLAGS) OBJDIR=obj DISTDIR=dist TESTDIR=test STATICLIBFLAGS = rcs -SHAREDLIBFLAGS = $(LDFLAGS) -shared -Wl,-soname - STATICLIB = lib$(LIBNAME).a -SHAREDLIB = lib$(LIBNAME).so - -SHAREDLIBVER = $(SHAREDLIB).$(VERSION) SRCS = $(addprefix src/, \ debug.c error.c fifo.c ieee488.c \ @@ -41,9 +33,9 @@ TESTS_OBJS = $(TESTS:.c=.o) TESTS_BINS = $(TESTS_OBJS:.o=.test) -.PHONY: all clean static shared test +.PHONY: all clean static test -all: static shared +all: static $(OBJDIR): @@ -58,17 +50,7 @@ $(DISTDIR)/$(STATICLIB): $(OBJS) $(AR) $(STATICLIBFLAGS) $(DISTDIR)/$(STATICLIB) $(OBJS) -$(DISTDIR)/$(SHAREDLIBVER): $(OBJS) - $(CC) $(SHAREDLIBFLAGS),$(SHAREDLIB) -o $(DISTDIR)/$(SHAREDLIBVER) $(OBJS) - -$(DISTDIR)/$(SHAREDLIB): $(DISTDIR)/$(SHAREDLIBVER) - $(RM) $(DISTDIR)/$(SHAREDLIB) - ln -s $(SHAREDLIBVER) $(DISTDIR)/$(SHAREDLIB) - static: $(DISTDIR)/$(STATICLIB) - -shared: $(DISTDIR)/$(SHAREDLIB) - $(OBJS): $(HDRS) $(DISTDIR) $(OBJDIR) -- Gitblit v1.9.1