From 4c9d16d85f35597f7a94db02359deded294674d3 Mon Sep 17 00:00:00 2001 From: Akshay Praveen Nair Date: Tue, 18 Aug 2020 22:34:31 +0530 Subject: [PATCH 1/4] Makefile: Initialise Makefile This commit does - Initialise makefile and uses targets to be made - Separate variables for source files, directories and common compiler --- Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9fe0d7c --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +CC := gcc +CFLAGS := -g -o +ALL_CFLAGS := -I. $(CFLAGS) + + +LIBS := -lstdc++ -lavcodec -lavformat -lavutil -lswresample -lswscale -lglfw -lGL +TARGET_DIR := bin/ + +SRC_PLAYER := main_window.cpp decoder.cpp +SRC_TCP_PLAYER := tcp_main_window.cpp decoder.cpp tcp_client.c +SRC_TCP_SERVER := tcp_server.c +SRC_TRANSCODER := transcoder.c debug.c + +.PHONY: all + +all: dir player tcp_player tcp_server transcoder + +dir: + if [ ! -d "$(TARGET_DIR)" ]; then \ + mkdir -p $(TARGET_DIR); \ + fi + +player: dir + $(CC) $(SRC_PLAYER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ + +tcp_server: dir + $(CC) $(SRC_TCP_SERVER) $(CFLAGS) $(TARGET_DIR)$@ + +tcp_player: dir + $(CC) $(SRC_TCP_PLAYER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ + +transcoder: dir + $(CC) $(SRC_TRANSCODER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ \ No newline at end of file From b596de2c5a6644ff40f09e57447701ab2a0acee6 Mon Sep 17 00:00:00 2001 From: Akshay Praveen Nair Date: Tue, 18 Aug 2020 22:39:19 +0530 Subject: [PATCH 2/4] Makefile: Enable peek variable value This commit does: - When make print-VARIABLE - It returns the VARIABLE = the_value_of_the_variable --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9fe0d7c..d2eacd0 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,6 @@ tcp_player: dir $(CC) $(SRC_TCP_PLAYER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ transcoder: dir - $(CC) $(SRC_TRANSCODER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ \ No newline at end of file + $(CC) $(SRC_TRANSCODER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ + +print-% : ; @echo $* = $($*) From 3c88e864239912e91b485cbff454ac00b5da8911 Mon Sep 17 00:00:00 2001 From: Akshay Praveen Nair Date: Sat, 22 Aug 2020 06:11:05 +0530 Subject: [PATCH 3/4] Makefile: Add the shell command for output directory --- Makefile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d2eacd0..39a514e 100644 --- a/Makefile +++ b/Makefile @@ -11,25 +11,22 @@ SRC_TCP_PLAYER := tcp_main_window.cpp decoder.cpp tcp_client.c SRC_TCP_SERVER := tcp_server.c SRC_TRANSCODER := transcoder.c debug.c -.PHONY: all +$(shell mkdir -p $(TARGET_DIR)) -all: dir player tcp_player tcp_server transcoder +.PHONY: all -dir: - if [ ! -d "$(TARGET_DIR)" ]; then \ - mkdir -p $(TARGET_DIR); \ - fi +all: player tcp_player tcp_server transcoder -player: dir +player: $(CC) $(SRC_PLAYER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ -tcp_server: dir +tcp_server: $(CC) $(SRC_TCP_SERVER) $(CFLAGS) $(TARGET_DIR)$@ -tcp_player: dir +tcp_player: $(CC) $(SRC_TCP_PLAYER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ -transcoder: dir +transcoder: $(CC) $(SRC_TRANSCODER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ print-% : ; @echo $* = $($*) From 1f88510ace7b135bf502270425eed0d3da981326 Mon Sep 17 00:00:00 2001 From: Akshay Praveen Nair Date: Sat, 22 Aug 2020 06:17:26 +0530 Subject: [PATCH 4/4] Makefile: Add clean recipe This commit does - Adds a rule clean which will remove the output directory --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 39a514e..64e4f11 100644 --- a/Makefile +++ b/Makefile @@ -29,4 +29,7 @@ tcp_player: transcoder: $(CC) $(SRC_TRANSCODER) $(LIBS) $(ALL_CFLAGS) $(TARGET_DIR)$@ +clean: + @rm -rf $(TARGET_DIR) + print-% : ; @echo $* = $($*)