From 6e73d8531ba409e513c2d491d473a7b593614733 Mon Sep 17 00:00:00 2001 From: Jan Breuer Date: Sat, 18 Apr 2015 23:20:37 +0200 Subject: [PATCH] Remove generationg .so and update makefiles Update makefiles and resolve some gcc warnings on different targets Conflicts: Makefile examples/common/scpi-def.c libscpi/Makefile --- Makefile | 4 +++- examples/Makefile | 8 ++++++-- examples/common/scpi-def.c | 2 +- examples/test-interactive/Makefile | 5 +++-- examples/test-interactive/main.c | 6 ++++-- examples/test-parser/Makefile | 5 +++-- examples/test-parser/main.c | 2 +- examples/test-tcp-srq/Makefile | 5 +++-- examples/test-tcp-srq/main.c | 2 +- examples/test-tcp/Makefile | 5 +++-- examples/test-tcp/main.c | 2 +- libscpi/Makefile | 29 ++++++----------------------- 12 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index ec20bb29..9b011c79 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: clean all test + all: $(MAKE) -C libscpi $(MAKE) -C examples @@ -6,5 +8,5 @@ clean: $(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 7ba0bdb4..462e2563 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,11 +1,15 @@ +.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 $(MAKE) clean -C test-parser diff --git a/examples/common/scpi-def.c b/examples/common/scpi-def.c index 359fdc47..699a803c 100644 --- a/examples/common/scpi-def.c +++ b/examples/common/scpi-def.c @@ -149,7 +149,7 @@ scpi_result_t TEST_ChoiceQ(scpi_t * context) { } 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 1d225a92..3338b7bb 100644 --- a/examples/test-interactive/Makefile +++ b/examples/test-interactive/Makefile @@ -3,8 +3,9 @@ PROG = test 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 @@ OBJS = $(SRCS:.c=.o) $(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 22ec0af4..1742bb8b 100644 --- a/examples/test-interactive/main.c +++ b/examples/test-interactive/main.c @@ -52,7 +52,7 @@ scpi_result_t SCPI_Flush(scpi_t * context) { 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 @@ int main(int argc, char** argv) { 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 1d225a92..3338b7bb 100644 --- a/examples/test-parser/Makefile +++ b/examples/test-parser/Makefile @@ -3,8 +3,9 @@ PROG = test 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 @@ OBJS = $(SRCS:.c=.o) $(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 5fc8e292..a19aa6a2 100644 --- a/examples/test-parser/main.c +++ b/examples/test-parser/main.c @@ -52,7 +52,7 @@ scpi_result_t SCPI_Flush(scpi_t * context) { 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 1d225a92..3338b7bb 100644 --- a/examples/test-tcp-srq/Makefile +++ b/examples/test-tcp-srq/Makefile @@ -3,8 +3,9 @@ PROG = test 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 @@ OBJS = $(SRCS:.c=.o) $(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 0a993d3a..af6cc618 100644 --- a/examples/test-tcp-srq/main.c +++ b/examples/test-tcp-srq/main.c @@ -84,7 +84,7 @@ scpi_result_t SCPI_Flush(scpi_t * context) { 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 1d225a92..3338b7bb 100644 --- a/examples/test-tcp/Makefile +++ b/examples/test-tcp/Makefile @@ -3,8 +3,9 @@ PROG = test 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 @@ OBJS = $(SRCS:.c=.o) $(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 3251286d..e4d9c415 100644 --- a/examples/test-tcp/main.c +++ b/examples/test-tcp/main.c @@ -63,7 +63,7 @@ scpi_result_t SCPI_Flush(scpi_t * context) { 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 62b20b56..3b90cf4e 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 = $(addprefix test/, \ 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,18 +54,8 @@ $(OBJDIR)/%.o: src/%.c $(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) clean: