Skip to content

Commit

Permalink
Remove generationg .so and update makefiles
Browse files Browse the repository at this point in the history
Update makefiles and resolve some gcc warnings on different targets

Conflicts:
	Makefile
	examples/common/scpi-def.c
	libscpi/Makefile
  • Loading branch information
j123b567 committed Apr 18, 2015
1 parent 0cb7ce2 commit 6e73d85
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 40 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: clean all test

all:
$(MAKE) -C libscpi
$(MAKE) -C examples
Expand All @@ -6,5 +8,5 @@ clean:
$(MAKE) clean -C libscpi
$(MAKE) clean -C examples

build-tests:
test:
$(MAKE) test -C libscpi
8 changes: 6 additions & 2 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/common/scpi-def.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions examples/test-interactive/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
6 changes: 4 additions & 2 deletions examples/test-interactive/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

Expand Down
5 changes: 3 additions & 2 deletions examples/test-parser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
2 changes: 1 addition & 1 deletion examples/test-parser/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/test-tcp-srq/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
2 changes: 1 addition & 1 deletion examples/test-tcp-srq/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions examples/test-tcp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
2 changes: 1 addition & 1 deletion examples/test-tcp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
29 changes: 6 additions & 23 deletions libscpi/Makefile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit 6e73d85

Please sign in to comment.