Skip to content

Commit

Permalink
Update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
hmgle committed Jul 31, 2018
1 parent 81b3870 commit 222679f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
67 changes: 64 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,71 @@
all: graftcp graftcp-local/graftcp-local
# "Makefile" for graftcp.
# Copyright (C) 2016, 2018 Hmgle <[email protected]>
#
# 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 <https://www.gnu.org/licenses/>.

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
3 changes: 2 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 222679f

Please sign in to comment.