From 12e08849fda67a47b10023234bcbc747e62ae22f Mon Sep 17 00:00:00 2001 From: mrundle Date: Thu, 28 Apr 2016 04:51:47 +0000 Subject: [PATCH 1/3] minor Makefile cleanup and introduced gcc warnings --- .gitignore | 2 ++ Makefile | 32 ++++++++++++++++++++------------ bin/.gitignore | 2 -- obj/.gitignore | 2 -- src/.gitignore | 1 - src/nms.c | 1 - src/sneakers.c | 3 +-- 7 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 .gitignore delete mode 100644 bin/.gitignore delete mode 100644 obj/.gitignore delete mode 100644 src/.gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..49bc29c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/* +obj/* diff --git a/Makefile b/Makefile index e6c1dd1..2d1298b 100644 --- a/Makefile +++ b/Makefile @@ -3,23 +3,31 @@ OBJ=obj SRC=src CC = gcc +CFLAGS = -Wextra -Wall LDLIBS = -lncurses +NCURSES_H=/usr/include/ncurses.h -${BIN}/nms: ${OBJ}/nms.o ${OBJ}/main.o - $(CC) -o $@ $^ $(LDLIBS) +all: nms sneakers -sneakers: ${OBJ}/nms.o ${OBJ}/sneakers.o - $(CC) -o ${BIN}/$@ $^ $(LDLIBS) +nms: $(OBJ)/nms.o $(OBJ)/main.o | $(BIN) + $(CC) $(CFLAGS) -o $(BIN)/$@ $^ $(LDLIBS) -${OBJ}/main.o: ${SRC}/main.c ${SRC}/nms.h - $(CC) -o $@ -c ${SRC}/main.c +sneakers: $(OBJ)/nms.o $(OBJ)/sneakers.o | $(BIN) + $(CC) $(CFLAGS) -o $(BIN)/$@ $^ $(LDLIBS) -${OBJ}/sneakers.o: ${SRC}/sneakers.c ${SRC}/nms.h - $(CC) -o $@ -c ${SRC}/sneakers.c +$(OBJ)/%.o: $(SRC)/%.c | $(OBJ) + $(CC) $(CFLAGS) -o $@ -c $< -${OBJ}/nms.o: ${SRC}/nms.c ${SRC}/nms.h - $(CC) -o $@ -c ${SRC}/nms.c +$(BIN): + mkdir $(BIN) + +$(OBJ): + mkdir $(OBJ) + +$(NCURSES_H): + sudo apt-get update + sudo apt-get install ncurses-dev clean: - rm -f ${BIN}/* - rm -f $(OBJ)/* + rm -rf $(BIN) + rm -rf $(OBJ) diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/obj/.gitignore b/obj/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/obj/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index b70b6d7..0000000 --- a/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nms diff --git a/src/nms.c b/src/nms.c index bdce6ae..a413fa3 100644 --- a/src/nms.c +++ b/src/nms.c @@ -54,7 +54,6 @@ char nms_exec(NmsArgs *args) { int termSizeRows, termSizeCols; int c, n, x = 0, y = 0; int r_time, r_time_l, r_time_s; - int ms, ls; bool first = true; char ret = 0; diff --git a/src/sneakers.c b/src/sneakers.c index ed819e6..f02ab7f 100644 --- a/src/sneakers.c +++ b/src/sneakers.c @@ -5,7 +5,7 @@ #include "nms.h" int main(void) { - int l, termLines, termCols, spaces = 0; + int termCols, spaces = 0; char input; char display[2000]; char *head1Left = "DATANET PROC RECORD: 45-3456-W-3452"; @@ -27,7 +27,6 @@ int main(void) { // Get terminal dimentions (needed for centering) struct winsize w; ioctl(0, TIOCGWINSZ, &w); - termLines = w.ws_row; termCols = w.ws_col; // Start building the display string From 9f82b10b5c51defedadd1893d97c7c3bc16a242f Mon Sep 17 00:00:00 2001 From: mrundle Date: Thu, 28 Apr 2016 05:25:18 +0000 Subject: [PATCH 2/3] actually require ncurses --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2d1298b..eb76b57 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SRC=src CC = gcc CFLAGS = -Wextra -Wall LDLIBS = -lncurses -NCURSES_H=/usr/include/ncurses.h +NCURSES_H = /usr/include/ncurses.h all: nms sneakers @@ -15,7 +15,7 @@ nms: $(OBJ)/nms.o $(OBJ)/main.o | $(BIN) sneakers: $(OBJ)/nms.o $(OBJ)/sneakers.o | $(BIN) $(CC) $(CFLAGS) -o $(BIN)/$@ $^ $(LDLIBS) -$(OBJ)/%.o: $(SRC)/%.c | $(OBJ) +$(OBJ)/%.o: $(SRC)/%.c | $(OBJ) $(NCURSES_H) $(CC) $(CFLAGS) -o $@ -c $< $(BIN): From b771aa9663511fd60d4a01572a0c579e2edbbddc Mon Sep 17 00:00:00 2001 From: Maxwell Gerber Date: Thu, 28 Apr 2016 17:36:35 -0700 Subject: [PATCH 3/3] Modified makefile for different flavors of *nix --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Makefile b/Makefile index eb76b57..9964447 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ CC = gcc CFLAGS = -Wextra -Wall LDLIBS = -lncurses NCURSES_H = /usr/include/ncurses.h +UNAME = $(shell uname) all: nms sneakers @@ -25,8 +26,18 @@ $(OBJ): mkdir $(OBJ) $(NCURSES_H): +ifeq ($(UNAME), Linux) sudo apt-get update sudo apt-get install ncurses-dev +endif +ifeq ($(UNAME), CentOS) + sudo yum update + sudo yum install ncurses-dev +endif +ifeq ($(UNAME), Fedora) + sudo dnf update --refresh + sudo dnf install ncurses-dev +endif clean: rm -rf $(BIN)