diff options
author | alejandro-colomar <colomar.6.4.3@gmail.com> | 2019-08-09 22:50:25 +0200 |
---|---|---|
committer | alejandro-colomar <colomar.6.4.3@gmail.com> | 2019-08-09 22:50:25 +0200 |
commit | 4083555f0a0e95643784548cad65ae81c06fcc26 (patch) | |
tree | 03e48fa4c9104b6c0e6ebc458cef6df850bb7120 | |
parent | b257c6b36786b203354c536a416f7f034c9ac935 (diff) |
Use libalx as shared library
-rwxr-xr-x | .gitmodules | 3 | ||||
-rwxr-xr-x | Makefile | 36 | ||||
-rwxr-xr-x | bin/Makefile | 13 | ||||
m--------- | libalx | 0 | ||||
-rwxr-xr-x | src/menu/clui.c | 22 | ||||
-rwxr-xr-x | tmp/Makefile | 1 | ||||
-rwxr-xr-x | tmp/about/Makefile | 4 | ||||
-rwxr-xr-x | tmp/player/Makefile | 2 | ||||
-rwxr-xr-x | tmp/save/Makefile | 5 |
9 files changed, 22 insertions, 64 deletions
diff --git a/.gitmodules b/.gitmodules index 8b3a783..e69de29 100755 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "libalx"] - path = libalx - url = https://github.com/alejandro-colomar/libalx/ @@ -1,7 +1,7 @@ #! /usr/bin/make -f VERSION = 5 -PATCHLEVEL = ~a1 +PATCHLEVEL = ~a2 SUBLEVEL = EXTRAVERSION = NAME = @@ -75,19 +75,12 @@ export PROGRAMVERSION MAIN_DIR = $(CURDIR) -LIBALX_DIR = $(CURDIR)/libalx/ -LIBALX_INC_DIR = $(LIBALX_DIR)/inc/ -LIBALX_LIB_DIR = $(LIBALX_DIR)/lib/libalx/ - BIN_DIR = $(CURDIR)/bin/ INC_DIR = $(CURDIR)/inc/ SRC_DIR = $(CURDIR)/src/ TMP_DIR = $(CURDIR)/tmp/ export MAIN_DIR -export LIBALX_DIR -export LIBALX_INC_DIR -export LIBALX_LIB_DIR export BIN_DIR export INC_DIR export SRC_DIR @@ -95,11 +88,8 @@ export TMP_DIR # FIXME: Set local or not local when building a package INSTALL_BIN_DIR = /usr/local/bin/ -#INSTALL_BIN_DIR = /usr/bin/ INSTALL_SHARE_DIR = /usr/local/share/ -#INSTALL_SHARE_DIR = /usr/share/ INSTALL_VAR_DIR = /var/local/ -#INSTALL_VAR_DIR = /var/lib/ ################################################################################ # Make variables (CC, etc...) @@ -127,14 +117,12 @@ CFLAGS_W = -Wall CFLAGS_W += -Wextra CFLAGS_W += -Wstrict-prototypes CFLAGS_W += -Werror -#CFLAGS_W += -Wno-error=format-truncation CFLAGS_PKG = `pkg-config --cflags ncurses` -CFLAGS_PKG += -I $(LIBALX_INC_DIR) +CFLAGS_PKG += `pkg-config --cflags libalx-ncurses` +CFLAGS_PKG += `pkg-config --cflags libalx-base` -CFLAGS_D = -D _GNU_SOURCE -CFLAGS_D += -D _POSIX_C_SOURCE=200809L -CFLAGS_D += -D PROG_VERSION=\"$(PROGRAMVERSION)\" +CFLAGS_D = -D PROG_VERSION=\"$(PROGRAMVERSION)\" CFLAGS_D += -D INSTALL_SHARE_DIR=\"$(INSTALL_SHARE_DIR)\" CFLAGS_D += -D INSTALL_VAR_DIR=\"$(INSTALL_VAR_DIR)\" @@ -151,17 +139,16 @@ export CFLAGS ################################################################################ # libs -LIBS_STD = -l m - LIBS_OPT = -O3 LIBS_OPT += -march=native LIBS_OPT += -flto LIBS_OPT += -fuse-linker-plugin LIBS_PKG = `pkg-config --libs ncurses` +LIBS_PKG += `pkg-config --libs libalx-ncurses` +LIBS_PKG += `pkg-config --libs libalx-base` -LIBS = $(LIBS_STD) -LIBS += $(LIBS_OPT) +LIBS = $(LIBS_OPT) LIBS += $(LIBS_PKG) export LIBS @@ -182,13 +169,6 @@ PHONY := all all: bin -PHONY += libalx -libalx: - @echo " MAKE $@" - $(Q)$(MAKE) base -C $(LIBALX_DIR) - $(Q)$(MAKE) ncurses -C $(LIBALX_DIR) - @echo - PHONY += tmp tmp: @echo " MAKE $@" @@ -196,7 +176,7 @@ tmp: @echo PHONY += bin -bin: tmp libalx +bin: tmp @echo " MAKE $@" $(Q)$(MAKE) -C $(BIN_DIR) @echo diff --git a/bin/Makefile b/bin/Makefile index ef72a44..419b8db 100755 --- a/bin/Makefile +++ b/bin/Makefile @@ -20,18 +20,9 @@ OBJS = \ $(TMP_DIR)/save/save.o \ $(TMP_DIR)/save/score.o \ $(TMP_DIR)/xyzzy/xyzzy.o -DEPS_LIBS = \ - $(LIBALX_LIB_DIR)/libalx-ncurses.a \ - $(LIBALX_LIB_DIR)/libalx-base.a ALL = $(BIN_NAME) size -# static libs - -STATIC_LIBS = -L $(LIBALX_LIB_DIR) \ - -l alx-ncurses \ - -l alx-base - # target: dependencies # action @@ -40,9 +31,9 @@ PHONY := all all: $(ALL) -$(BIN_NAME): $(OBJS) $(DEPS_LIBS) +$(BIN_NAME): $(OBJS) @echo " CC $@" - $(Q)$(CC) $(OBJS) -o $@ $(STATIC_LIBS) $(LIBS) + $(Q)$(CC) $(OBJS) -o $@ $(LIBS) size: $(BIN_NAME) @echo " SZ $(BIN_NAME)" diff --git a/libalx b/libalx deleted file mode 160000 -Subproject 5fc44bd185add8b28351e83441141983dbf6384 diff --git a/src/menu/clui.c b/src/menu/clui.c index d4f9118..3a6539b 100755 --- a/src/menu/clui.c +++ b/src/menu/clui.c @@ -10,8 +10,10 @@ #include <limits.h> #include <math.h> +#include <stdio.h> #include <stdlib.h> +#include "libalx/base/compiler/size.h" #include "libalx/base/stdio/get.h" #include "mine-sweeper/about/about.h" @@ -33,8 +35,6 @@ #error "cols max (clui)" #endif -#define BUFF_SIZE (1024) - /****************************************************************************** ******* static functions ***************************************************** @@ -50,12 +50,12 @@ static void menu_clui_start (void); ******************************************************************************/ void menu_clui (void) { - char buff [BUFF_SIZE]; + char buff [BUFSIZ]; char c; c = 'n'; printf("Read 'Disclaimer of warranty'? (yes/NO): "); - if (!fgets(buff, BUFF_SIZE, stdin)) + if (!fgets(buff, ARRAY_SIZE(buff), stdin)) goto err_fgets; if (sscanf(buff, " %c", &c) != 1) goto err_sscanf; @@ -68,7 +68,7 @@ void menu_clui (void) c = 'n'; printf("Read 'License'? (yes/NO): "); - if (!fgets(buff, BUFF_SIZE, stdin)) + if (!fgets(buff, ARRAY_SIZE(buff), stdin)) goto err_fgets; if (sscanf(buff, " %c", &c) != 1) goto err_sscanf; @@ -91,7 +91,7 @@ void menu_clui (void) #endif c = 'n'; printf("New game or load game? (NEW/load): "); - if (!fgets(buff, BUFF_SIZE, stdin)) + if (!fgets(buff, ARRAY_SIZE(buff), stdin)) goto err_fgets; if (sscanf(buff, " %c", &c) != 1) goto err_sscanf; @@ -121,7 +121,7 @@ err_sscanf: static void menu_clui_rand (void) { unsigned seed; - char buff [BUFF_SIZE]; + char buff [BUFSIZ]; char c; /* Random */ @@ -129,7 +129,7 @@ static void menu_clui_rand (void) c = 'n'; printf("Set seed for random generator? (yes/NO): "); - if (!fgets(buff, BUFF_SIZE, stdin)) + if (!fgets(buff, ARRAY_SIZE(buff), stdin)) goto err_fgets; if (sscanf(buff, " %c", &c) != 1) goto err_sscanf; @@ -143,7 +143,7 @@ static void menu_clui_rand (void) c = 'b'; printf("Level? (BEGINNER/intermediate/(expert)/custom): "); - if (!fgets(buff, BUFF_SIZE, stdin)) + if (!fgets(buff, ARRAY_SIZE(buff), stdin)) goto err_fgets; if (sscanf(buff, " %c", &c) != 1) goto err_sscanf; @@ -204,7 +204,7 @@ static void menu_clui_load (void) static void menu_clui_start (void) { - char buff [BUFF_SIZE]; + char buff [BUFSIZ]; char c; printf(" >>START:\n"); @@ -212,7 +212,7 @@ static void menu_clui_start (void) c = 'm'; printf("Play again? (MENU/play/exit): "); - if (!fgets(buff, BUFF_SIZE, stdin)) + if (!fgets(buff, ARRAY_SIZE(buff), stdin)) goto err_fgets; if (sscanf(buff, " %c", &c) != 1) goto err_sscanf; diff --git a/tmp/Makefile b/tmp/Makefile index 4fb766e..ad488ee 100755 --- a/tmp/Makefile +++ b/tmp/Makefile @@ -16,7 +16,6 @@ OBJ = \ main.o MAIN_INC = \ - $(LIBALX_INC_DIR)/libalx/extra/ncurses/common.h \ $(INC_DIR)/mine-sweeper/about/about.h \ $(INC_DIR)/mine-sweeper/ctrl/start.h \ $(INC_DIR)/mine-sweeper/game/core.h \ diff --git a/tmp/about/Makefile b/tmp/about/Makefile index 151cf9a..9b3c9a3 100755 --- a/tmp/about/Makefile +++ b/tmp/about/Makefile @@ -16,9 +16,7 @@ OBJ = \ about.o ABOUT_INC = \ - $(INC_DIR)/mine-sweeper/about/about.h \ - $(LIBALX_INC_DIR)/libalx/base/compiler/size.h \ - $(LIBALX_INC_DIR)/libalx/base/errno/error.h + $(INC_DIR)/mine-sweeper/about/about.h ABOUT_SRC = \ $(SRC_DIR)/about/about.c diff --git a/tmp/player/Makefile b/tmp/player/Makefile index b99d03a..8bffd9e 100755 --- a/tmp/player/Makefile +++ b/tmp/player/Makefile @@ -26,8 +26,6 @@ CLUI_SRC = \ TUI_INC = \ $(INC_DIR)/mine-sweeper/player/tui.h \ - $(LIBALX_INC_DIR)/libalx/extra/ncurses/common.h \ - $(LIBALX_INC_DIR)/libalx/extra/ncurses/get.h \ $(INC_DIR)/mine-sweeper/game/iface.h \ $(INC_DIR)/mine-sweeper/player/iface.h TUI_SRC = \ diff --git a/tmp/save/Makefile b/tmp/save/Makefile index 54f595f..3a61420 100755 --- a/tmp/save/Makefile +++ b/tmp/save/Makefile @@ -18,8 +18,6 @@ OBJ = \ SAVE_INC = \ $(INC_DIR)/mine-sweeper/save/save.h \ - $(LIBALX_INC_DIR)/libalx/base/errno/error.h \ - $(LIBALX_INC_DIR)/libalx/base/stdio/seekc.h \ $(INC_DIR)/mine-sweeper/game/core.h \ $(INC_DIR)/mine-sweeper/player/iface.h SAVE_SRC = \ @@ -27,9 +25,6 @@ SAVE_SRC = \ SCORE_INC = \ $(INC_DIR)/mine-sweeper/save/score.h \ - $(LIBALX_INC_DIR)/libalx/base/compiler/size.h \ - $(LIBALX_INC_DIR)/libalx/base/errno/error.h \ - $(LIBALX_INC_DIR)/libalx/base/stdio/seekc.h \ $(INC_DIR)/mine-sweeper/game/core.h \ $(INC_DIR)/mine-sweeper/game/iface.h \ $(INC_DIR)/mine-sweeper/player/iface.h |