From 6e73d8531ba409e513c2d491d473a7b593614733 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周日, 19 4月 2015 05:31:39 +0800 Subject: [PATCH] Remove generationg .so and update makefiles --- examples/Makefile | 8 +++- examples/test-tcp-srq/Makefile | 5 +- libscpi/Makefile | 29 +++----------- 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, 35 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index ec20bb2..9b011c7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: clean all test + all: $(MAKE) -C libscpi $(MAKE) -C examples @@ -6,5 +8,5 @@ $(MAKE) clean -C libscpi $(MAKE) clean -C examples -build-tests: +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 359fdc4..699a803 100644 --- a/examples/common/scpi-def.c +++ b/examples/common/scpi-def.c @@ -149,7 +149,7 @@ } SCPI_ChoiceToName(trigger_source, param, &name); - fprintf(stderr, "\tP1=%s (%d)\r\n", name, param); + fprintf(stderr, "\tP1=%s (%ld)\r\n", name, (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 22ec0af..1742bb8 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; } @@ -87,7 +87,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 5fc8e29..a19aa6a 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 0a993d3..af6cc61 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 3251286..e4d9c41 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 62b20b5..3b90cf4 100644 --- a/libscpi/Makefile +++ b/libscpi/Makefile @@ -1,23 +1,16 @@ - -VERSION = 2.0.0 LIBNAME = scpi - -CFLAGS += -Wextra -g -fPIC -Iinc +CFLAGS += -Wextra -g -Iinc LDFLAGS += -Wl,--as-needed -TESTFLAGS += -lcunit +TESTFLAGS += -lcunit $(CFLAGS) OBJDIR=obj DISTDIR=dist TESTDIR=test -STATICLIB = lib$(LIBNAME).a -SHAREDLIB = lib$(LIBNAME).so - -SHAREDLIBVER = $(SHAREDLIB).$(VERSION) - STATICLIBFLAGS = rcs -SHAREDLIBFLAGS = $(LDFLAGS) -shared -Wl,-soname,$(SHAREDLIB) + +STATICLIB = lib$(LIBNAME).a SRCS = $(addprefix src/, \ debug.c error.c fifo.c ieee488.c \ @@ -44,9 +37,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): @@ -61,17 +54,7 @@ $(DISTDIR)/$(STATICLIB): $(OBJS) $(AR) $(STATICLIBFLAGS) $(DISTDIR)/$(STATICLIB) $(OBJS) -$(DISTDIR)/$(SHAREDLIBVER): $(OBJS) - $(CC) $(SHAREDLIBFLAGS) -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