Skip to content

Instantly share code, notes, and snippets.

@hattya
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hattya/97df7df875d72d8030bb to your computer and use it in GitHub Desktop.
Save hattya/97df7df875d72d8030bb to your computer and use it in GitHub Desktop.
--- a/tool/mlclient/Makefile.in
+++ b/tool/mlclient/Makefile.in
@@ -6,9 +6,13 @@
VPATH = ${top_srcdir}/tool/mlclient
+LKIK = @LKIK@
+LKIK_DEB = -lkik_deb
+
CC = @CC@
+LIBTOOL = @LIBTOOL@
CFLAGS = @KIK_CFLAGS@ @CFLAGS@ @CPPFLAGS@ @GUI_CFLAGS@
-LIBS = @SOCK_LIBS@
+LIBS = $(LKIK) @SOCK_LIBS@
INSTALL = @INSTALL@
BINDIR = $(DESTDIR)$(bindir)
@@ -17,16 +21,20 @@
PROG = mlclient
+LIBTOOL_CC = $(LIBTOOL) --mode=compile $(CC) $(CFLAGS)
+LIBTOOL_LINK = $(LIBTOOL) --mode=link $(CC) @LDFLAGS@
+LIBTOOL_INSTALL = $(LIBTOOL) --mode=install $(INSTALL)
+
all: $(PROG)
$(PROG): $(OBJ)
- $(CC) -o $(PROG) $(OBJ) $(LIBS) @LDFLAGS@
- cp $(PROG) $(PROG)x
+ $(LIBTOOL_LINK) -o $(PROG) $(OBJ:.o=.lo) $(LIBS)
+ $(LIBTOOL_LINK) -o $(PROG)x $(OBJ:.o=.lo) $(LIBS)
.SUFFIXES: .c.o
.c.o:
- $(CC) $(CFLAGS) -c $<
+ $(LIBTOOL_CC) $(CFLAGS) -c $<
clean:
rm -f $(OBJ) $(PROG) $(PROG).exe $(PROG)x $(PROG)x.exe *core
@@ -38,7 +46,7 @@
mkdir -p $(BINDIR)
install: $(BINDIR)
- $(INSTALL) -m 755 $(PROG) $(PROG)x $(BINDIR)
+ $(LIBTOOL_INSTALL) -m 755 $(PROG) $(PROG)x $(BINDIR)
uninstall:
rm -f $(BINDIR)/$(PROG) $(BINDIR)/$(PROG)x
--- a/tool/mlclient/main.c
+++ b/tool/mlclient/main.c
@@ -73,20 +73,21 @@
struct sockaddr_un * addr
)
{
- const char name[] = "/.mlterm/socket" ;
- const char * dir ;
+ char * path ;
- if( ( dir = getenv( "HOME")) == NULL || '/' != dir[0] )
+ if( ( path = kik_get_user_rc_path( "mlterm/socket")) == NULL)
{
return 0 ;
}
- if( strlen( dir) + sizeof(name) > sizeof( addr->sun_path))
+ if( strlen( path) >= sizeof( addr->sun_path))
{
+ free( path) ;
return 0 ;
}
- sprintf( addr->sun_path , "%s%s" , dir , name) ;
+ strcpy( addr->sun_path , path) ;
+ free( path) ;
return 1 ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment