hewei há 6 anos atrás
pai
commit
903b18b379
3 ficheiros alterados com 30 adições e 26 exclusões
  1. 23 23
      Makefile
  2. 3 3
      Makefile.in
  3. 4 0
      Makefile.vars

+ 23 - 23
Makefile

@@ -4,54 +4,59 @@ MAKEF=$(MAKE) -f Makefile.in
 TMPDIR=tmp
 TMPDIR=tmp
 
 
 default: all
 default: all
-
-all: libhv test timer loop tcp udp nc nmap httpd curl consul_cli
+all: libhv examples
+examples: test timer loop tcp udp nc nmap httpd curl consul_cli
 
 
 clean:
 clean:
 	$(MAKEF) clean SRCDIRS=". base utils event http http/client http/server protocol examples $(TMPDIR)"
 	$(MAKEF) clean SRCDIRS=". base utils event http http/client http/server protocol examples $(TMPDIR)"
 
 
 prepare:
 prepare:
-	-mkdir -p $(TMPDIR) lib bin
-	-rm base/RAII.o
+	$(MKDIR) -p $(TMPDIR) lib bin
+	$(RM) base/RAII.o
 
 
 libhv: prepare
 libhv: prepare
 	$(MAKEF) TARGET=$@ TARGET_TYPE=SHARED SRCDIRS=". base utils event http http/client http/server protocol"
 	$(MAKEF) TARGET=$@ TARGET_TYPE=SHARED SRCDIRS=". base utils event http http/client http/server protocol"
 	$(MAKEF) TARGET=$@ TARGET_TYPE=STATIC SRCDIRS=". base utils event http http/client http/server protocol"
 	$(MAKEF) TARGET=$@ TARGET_TYPE=STATIC SRCDIRS=". base utils event http http/client http/server protocol"
-	-mkdir include
-	-cp $(INSTALL_HEADERS) include/
+	$(MKDIR) include
+	$(CP) $(INSTALL_HEADERS) include/
+
+install:
+	$(MKDIR) -p $(INSTALL_INCDIR)
+	$(CP) include/* $(INSTALL_INCDIR)
+	$(CP) lib/libhv.a lib/libhv.so $(INSTALL_LIBDIR)
 
 
 test: prepare
 test: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp main.cpp.tmpl $(TMPDIR)/main.cpp
 	cp main.cpp.tmpl $(TMPDIR)/main.cpp
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils $(TMPDIR)"
 
 
 timer: prepare
 timer: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/timer.c $(TMPDIR)
 	cp examples/timer.c $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 
 
 loop: prepare
 loop: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/loop.c $(TMPDIR)
 	cp examples/loop.c $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 
 
 tcp: prepare
 tcp: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/tcp.c $(TMPDIR)
 	cp examples/tcp.c $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 
 
 udp: prepare
 udp: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/udp.c $(TMPDIR)
 	cp examples/udp.c $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 
 
 nc: prepare
 nc: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/nc.c $(TMPDIR)
 	cp examples/nc.c $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base event $(TMPDIR)"
 
 
 nmap: prepare
 nmap: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/nmap.cpp $(TMPDIR)
 	cp examples/nmap.cpp $(TMPDIR)
 ifeq ($(OS), Windows)
 ifeq ($(OS), Windows)
 	# for nmap on Windows platform, recommand EVENT_POLL, not EVENT_IOCP
 	# for nmap on Windows platform, recommand EVENT_POLL, not EVENT_IOCP
@@ -61,19 +66,19 @@ else
 endif
 endif
 
 
 httpd: prepare
 httpd: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/httpd.cpp examples/http_api_test.h $(TMPDIR)
 	cp examples/httpd.cpp examples/http_api_test.h $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/server $(TMPDIR)"
 
 
 curl: prepare
 curl: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
 	cp examples/curl.cpp $(TMPDIR)
 	cp examples/curl.cpp $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)"
 	$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)"
 	#$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)" DEFINES="$(DEFINES) WITH_CURL CURL_STATICLIB"
 	#$(MAKEF) TARGET=$@ SRCDIRS="$(CURL_SRCDIRS)" SRCDIRS=". base utils http http/client $(TMPDIR)" DEFINES="$(DEFINES) WITH_CURL CURL_STATICLIB"
 
 
 consul_cli: prepare
 consul_cli: prepare
-	-rm $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
-	cp examples/consul_cli.cpp examples/http_api_test.h $(TMPDIR)
+	$(RM) $(TMPDIR)/*.o $(TMPDIR)/*.h $(TMPDIR)/*.c $(TMPDIR)/*.cpp
+	cp examples/consul_cli.cpp $(TMPDIR)
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/client consul $(TMPDIR)" DEFINES="PRINT_DEBUG"
 	$(MAKEF) TARGET=$@ SRCDIRS=". base utils event http http/client consul $(TMPDIR)" DEFINES="PRINT_DEBUG"
 
 
 unittest: prepare
 unittest: prepare
@@ -90,11 +95,6 @@ unittest: prepare
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iprotocol -o bin/ftp        unittest/ftp_test.c           protocol/ftp.c  base/hsocket.c
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iprotocol -o bin/ftp        unittest/ftp_test.c           protocol/ftp.c  base/hsocket.c
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iutils -Iprotocol -o bin/sendmail  unittest/sendmail_test.c  protocol/smtp.c base/hsocket.c utils/base64.c
 	$(CC)  -g -Wall -std=c99   -I. -Ibase -Iutils -Iprotocol -o bin/sendmail  unittest/sendmail_test.c  protocol/smtp.c base/hsocket.c utils/base64.c
 
 
-install:
-	-mkdir -p $(INSTALL_INCDIR)
-	-cp include/* $(INSTALL_INCDIR)
-	-cp lib/libhv.a lib/libhv.so $(INSTALL_LIBDIR)
-
 # UNIX only
 # UNIX only
 webbench: prepare
 webbench: prepare
 	$(CC) -o bin/webbench unittest/webbench.c
 	$(CC) -o bin/webbench unittest/webbench.c
@@ -108,4 +108,4 @@ echo-servers:
 	$(CXX) -g -Wall -std=c++11 -o bin/poco_echo     echo-servers/poco_echo.cpp   -lPocoNet -lPocoUtil -lPocoFoundation
 	$(CXX) -g -Wall -std=c++11 -o bin/poco_echo     echo-servers/poco_echo.cpp   -lPocoNet -lPocoUtil -lPocoFoundation
 	$(CXX) -g -Wall -std=c++11 -o bin/muduo_echo    echo-servers/muduo_echo.cpp  -lmuduo_net -lmuduo_base -lpthread
 	$(CXX) -g -Wall -std=c++11 -o bin/muduo_echo    echo-servers/muduo_echo.cpp  -lmuduo_net -lmuduo_base -lpthread
 
 
-.PHONY: clean prepare libhv test timer loop tcp udp nc nmap httpd curl consul_cli unittest install webbench echo-servers
+.PHONY: clean prepare libhv install examples test timer loop tcp udp nc nmap httpd curl consul_cli unittest webbench echo-servers

+ 3 - 3
Makefile.in

@@ -37,9 +37,9 @@ OBJCOPY	= $(CROSS_COMPILE)objcopy
 OBJDUMP	= $(CROSS_COMPILE)objdump
 OBJDUMP	= $(CROSS_COMPILE)objdump
 endif
 endif
 
 
-MKDIR = -mkdir -p
-CP = -cp -r
-RM = -rm -r
+MKDIR = -mkdir -p 2>/dev/null
+CP = -cp -r 2>/dev/null
+RM = -rm -r 2>/dev/null
 
 
 # PLATFORM: OS, ARCH
 # PLATFORM: OS, ARCH
 CC_VERSION=$(shell $(CC) --version 2>&1 | head -n 1)
 CC_VERSION=$(shell $(CC) --version 2>&1 | head -n 1)

+ 4 - 0
Makefile.vars

@@ -1,3 +1,7 @@
+MKDIR = -mkdir -p 2>/dev/null
+CP = -cp -r 2>/dev/null
+RM = -rm -r 2>/dev/null
+
 INSTALL_INCDIR=/usr/local/include/hv
 INSTALL_INCDIR=/usr/local/include/hv
 INSTALL_LIBDIR=/usr/local/lib
 INSTALL_LIBDIR=/usr/local/lib