From 64a278ca99052aebfaa41fcd9f1b7722e41ab18a Mon Sep 17 00:00:00 2001 From: Murilo Pereira Date: Sun, 6 Feb 2011 21:28:11 -0200 Subject: [PATCH] Makefile refactoring and introducing the 'test' rule. * Moved the main source file to the lib directory * ttysolitaire rather than tty-solitaire --- Makefile | 61 +++++++++++++++-------- src/tty-solitaire.c => lib/ttysolitaire.c | 6 +-- 2 files changed, 42 insertions(+), 25 deletions(-) rename src/tty-solitaire.c => lib/ttysolitaire.c (88%) diff --git a/Makefile b/Makefile index 603ec19..8380cd0 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,43 @@ -CC = gcc -SRC_DIR = src -SRC = ${SRC_DIR}/tty-solitaire.c -CFLAGS = -W -Wall -pedantic -ansi -std=c99 -OUTPUT = bin/tty-solitaire -LIB_DIR = lib -DEBUG_DIR = debug -OBJECTS = ${LIB_DIR}/frame.o \ - ${LIB_DIR}/card.o \ - ${LIB_DIR}/stack.o \ - ${LIB_DIR}/deck.o \ - ${LIB_DIR}/util.o \ - ${LIB_DIR}/cursor.o \ - ${LIB_DIR}/keyboard.o \ - ${LIB_DIR}/display.o \ - ${LIB_DIR}/game.o \ - ${DEBUG_DIR}/card_debug.o \ - ${DEBUG_DIR}/stack_debug.o \ - ${DEBUG_DIR}/deck_debug.o +CC = gcc +CFLAGS = -W -Wall -pedantic -ansi -std=c99 LDFLAGS = -lncursesw -tty-solitaire: ${OBJECTS} - ${CC} ${CFLAGS} ${LDFLAGS} ${SRC} -o ${OUTPUT} ${OBJECTS} +EXECUTABLE = bin/ttysolitaire +LIB_DIR = lib +DEBUG_DIR = debug +SRC = ${LIB_DIR}/ttysolitaire.c +LIB_OBJECTS = ${LIB_DIR}/frame.o \ + ${LIB_DIR}/card.o \ + ${LIB_DIR}/stack.o \ + ${LIB_DIR}/deck.o \ + ${LIB_DIR}/util.o \ + ${LIB_DIR}/cursor.o \ + ${LIB_DIR}/keyboard.o \ + ${LIB_DIR}/display.o \ + ${LIB_DIR}/game.o \ + ${DEBUG_DIR}/card_debug.o \ + ${DEBUG_DIR}/stack_debug.o \ + ${DEBUG_DIR}/deck_debug.o \ + +TEST_EXECUTABLE = bin/ttysolitaire_test +TEST_DIR = test +TEST_SRC = ${TEST_DIR}/ttysolitaire_test.c +TEST_OBJECTS = ${TEST_DIR}/frame_test.o \ + ${TEST_DIR}/card_test.o \ + ${TEST_DIR}/stack_test.o \ + ${TEST_DIR}/deck_test.o \ + ${TEST_DIR}/util_test.o \ + ${TEST_DIR}/cursor_test.o \ + ${TEST_DIR}/keyboard_test.o \ + ${TEST_DIR}/display_test.o \ + ${TEST_DIR}/game_test.o \ + +ttysolitaire: ${LIB_OBJECTS} + ${CC} ${CFLAGS} ${LDFLAGS} ${SRC} -o ${EXECUTABLE} ${LIB_OBJECTS} + +test: ${TEST_OBJECTS} + ${CC} ${CFLAGS} ${LDFLAGS} ${TEST_SRC} -o ${TEST_EXECUTABLE} ${TEST_OBJECTS} + ${TEST_EXECUTABLE} clean: - rm -rf ${LIB_DIR}/*.o ${OUTPUT} + rm -rf {${LIB_DIR},${TEST_DIR}}/*.o ${EXECUTABLE} ${TEST_EXECUTABLE} diff --git a/src/tty-solitaire.c b/lib/ttysolitaire.c similarity index 88% rename from src/tty-solitaire.c rename to lib/ttysolitaire.c index 8247d8b..68e9c4d 100644 --- a/src/tty-solitaire.c +++ b/lib/ttysolitaire.c @@ -1,8 +1,8 @@ #include #include -#include "../lib/util.h" -#include "../lib/game.h" -#include "../lib/keyboard.h" +#include "util.h" +#include "game.h" +#include "keyboard.h" const char *program_name;