From 222679f1f03c4958730f6f6392fd3fc58d599089 Mon Sep 17 00:00:00 2001 From: "mingang.he" Date: Tue, 31 Jul 2018 17:02:08 +0800 Subject: [PATCH] Update Makefile --- Makefile | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- main.c | 3 ++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 00a90d5..9b391fd 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,71 @@ -all: graftcp graftcp-local/graftcp-local +# "Makefile" for graftcp. +# Copyright (C) 2016, 2018 Hmgle +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +PREFIX = /usr/local +BINDIR = $(PREFIX)/bin + +INSTALL = install -c + +CFLAGS += -Wall + +SRC := $(wildcard *.c) + +TARGET = graftcp graftcp-local/graftcp-local + +all:: $(TARGET) graftcp: main.o util.o string-set.o - cc $^ -o $@ + $(CC) $^ -o $@ + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< graftcp-local/graftcp-local: graftcp-local/*.go cd graftcp-local && go build +install:: graftcp graftcp-local/graftcp-local + $(INSTALL) $< $(BINDIR); \ + cd graftcp-local && ./graftcp-local -service install && \ + ./graftcp-local -service start + +uninstall:: graftcp-local/graftcp-local + -rm -f $(BINDIR)/graftcp; \ + cd graftcp-local && ./graftcp-local -service uninstall + +install_graftcp:: graftcp + $(INSTALL) $< $(BINDIR) + +uninstall_graftcp:: + -rm -f $(BINDIR)/graftcp + +install_graftcp_local:: graftcp-local/graftcp-local + cd graftcp-local && ./graftcp-local -service install && \ + ./graftcp-local -service restart + +uninstall_graftcp_local:: graftcp-local/graftcp-local + cd graftcp-local && ./graftcp-local -service stop && \ + ./graftcp-local -service uninstall + +sinclude $(SRC:.c=.d) + +%.d: %.c + @set -e; rm -f $@; \ + $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \ + sed 's,\(.*\)\.o[:]*,\1.o $@:,' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + clean:: - rm -f *.o graftcp graftcp-local/graftcp-local + -rm -f *.o $(TARGET) *.d diff --git a/main.c b/main.c index b2cdef6..aa2576e 100644 --- a/main.c +++ b/main.c @@ -404,7 +404,8 @@ int main(int argc, char **argv) LOCAL_PIPE_FD = open(LOCAL_PIPE_PAHT, O_WRONLY); if (LOCAL_PIPE_FD < 0) { - perror("open"); + perror("open fifo"); + fprintf(stderr, "It seems that graftcp-local is not running, should start graftcp-local first.\n"); exit(errno); }