Skip to content

Commit

Permalink
Windows makefile adjustment and info ip
Browse files Browse the repository at this point in the history
  • Loading branch information
a3f committed Aug 25, 2015
1 parent 128a373 commit 7153fb0
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 225 deletions.
2 changes: 1 addition & 1 deletion .ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def FlagsForFile( filename , **kwargs ):
'-DSYSTEM="Vim"',
'-DVERSION="0xa3f"',
'-isystem', '/usr/local/include',
'-isystem', './hidapi/hidapi',
'-isystem', '.',
'-isystem', '/usr/local/mingw/i686-w64-mingw32/include',
# for removing the warning about unsupported __stdcall (on non-win32 hosts)
#'-DWINAPI=/*__stdcall*/',
Expand Down
25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ CREATE_BUILD_DIR := $(shell mkdir build 2>&1)
ifeq ($(OS),Windows_NT)

## No rm?
ifeq (, $(shell where rm))
RM = del /Q
ifeq (, $(shell where rm 2>NUL))
RM = del /Q 2>NUL
# Powershell, cygwin and msys all provide rm(1)
endif

ifeq (, $(shell where $(CC) 2>NUL))
CC = gcc
endif

## Win32
ifneq ($(MAKECMDGOALS),cross)
FLAGS += -DCONFIGURATION='"HIDAPI/hid.dll"' -DSYSTEM='"Windows"'
Expand Down Expand Up @@ -81,20 +85,28 @@ endif
CROSS_PREFIX ?= arm-linux-gnueabi-g

OBJS = $(SRCS:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
DWS :=
DWS +=
DWS +=


.DEFAULT: all
all: $(BIN_NAME)

$(BIN_NAME): $(OBJS) $(OBJDIR)/hid.o
$(PREFIX)$(CC) $(OBJS) $(OBJDIR)/hid.o $(LDFLAGS) $(LIBS) -o $(BIN_NAME)
$(info $(DWS)CCLD$(DWS) $@)
@$(PREFIX)$(CC) $(OBJS) $(OBJDIR)/hid.o $(LDFLAGS) $(LIBS) -o $(BIN_NAME)

# static enables valgrind to act better -DDEBUG!
$(OBJS): $(OBJDIR)/%.o: $(SRCDIR)/%.c
$(PREFIX)$(CC) -c $< -MMD $(FLAGS) $(INC) -o $@
$(info $(DWS)CC$(DWS)$(DWS) $@)
@$(PREFIX)$(CC) -c $< -MMD $(FLAGS) $(INC) -o $@

-include $(OBJDIR)/*.d

$(OBJDIR)/hid.o: $(HIDSRC)
$(PREFIX)$(CC) -c $< -o $@ $(INC) $(HIDFLAGS)
$(info $(DWS)CC$(DWS)$(DWS) $@)
@$(PREFIX)$(CC) -c $< -o $@ $(INC) $(HIDFLAGS)


debug: FLAGS += -g
Expand All @@ -120,5 +132,6 @@ install: $(BIN_NAME) ev3-udev.rules udev.sh

.PHONY: clean
clean:
$(RM) $(BIN_NAME) && cd $(OBJDIR) && $(RM) *.o *.d
$(RM) $(BIN_NAME)
cd $(OBJDIR) && $(RM) *.o *.d

12 changes: 5 additions & 7 deletions src/bt-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ enum {READ=0, WRITE=1};
void *bt_open(const char *file, const char*file2)
{
int *fd = malloc(2*sizeof(int));
struct stat buf;
fd[0] = fd[1] = open(file ?: BT, O_RDWR);
if (*fd == -1) return NULL;
fstat(*fd, &buf);
if (S_ISFIFO(buf.st_mode))
if (file2)
{
close(*fd);
fd[READ] = open(file ?: BT, O_RDONLY);
fd[WRITE] = open(file ?: BT, O_WRONLY);
}
}else
fd[0] = fd[1] = open(file ?: BT, O_RDWR);

if (fd[WRITE] == -1 || fd[READ] == -1) return NULL;
return fd;
}

Expand Down
113 changes: 0 additions & 113 deletions src/getfilec.c

This file was deleted.

27 changes: 19 additions & 8 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include <stdlib.h>
#include <string.h>

#include <hidapi.h>
#include <hidapi/hidapi.h>
#include "tcp.h"
#include "ev3_io.h"

#include "defs.h"
Expand Down Expand Up @@ -37,15 +38,25 @@ int info(const char*arg)
wchar_t wstr[MAX_STR];
if (arg)
{
if ((void*)ev3_write != (void*)hid_write)
return ERR_ARG;
if (strcmp(arg, "serial") == 0)
if((void*)ev3_close == (void*)hid_close)
{
hid_get_serial_number_string(handle, wstr, MAX_STR);
fputws(wstr, stdout);
fputwc(L'\n', stdout);
return ERR_UNK;
if (strcmp(arg, "serial") == 0)
{
hid_get_serial_number_string(handle, wstr, MAX_STR);
fputws(wstr, stdout);
fputwc(L'\n', stdout);
return ERR_UNK;
}
}else if(ev3_close == tcp_close)
{
if (strcmp(arg, "ip") == 0)
{
puts(((struct tcp_handle*)handle)->ip);
return ERR_UNK;
}
}

return ERR_ARG;
}

int res;
Expand Down
2 changes: 1 addition & 1 deletion src/listen.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <stdio.h>
#include <hidapi.h>
#include <hidapi/hidapi.h>
#include <string.h>
#include "defs.h"
#include "ev3_io.h"
Expand Down
Loading

0 comments on commit 7153fb0

Please sign in to comment.