| 1 |
# |
| 2 |
# boxes - Command line filter to draw/remove ASCII boxes around text |
| 3 |
# Copyright (c) 1999-2024 Thomas Jensen and the boxes contributors |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
| 6 |
# License, version 3, as published by the Free Software Foundation. |
| 7 |
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 8 |
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 9 |
# details. |
| 10 |
# You should have received a copy of the GNU General Public License along with this program. |
| 11 |
# If not, see <https://www.gnu.org/licenses/>. |
| 12 |
#____________________________________________________________________________________________________________________ |
| 13 |
#==================================================================================================================== |
| 14 |
|
| 15 |
|
| 16 |
CC = gcc |
| 17 |
|
| 18 |
OUT_DIR = ../out |
| 19 |
SRC_DIR = ../src |
| 20 |
VPATH = $(SRC_DIR):$(SRC_DIR)/misc |
| 21 |
|
| 22 |
GEN_HDR = parser.h boxes.h lex.yy.h |
| 23 |
GEN_SRC = parser.c lex.yy.c |
| 24 |
GEN_FILES = $(GEN_SRC) $(GEN_HDR) |
| 25 |
ORIG_HDRCL = boxes.in.h config.h |
| 26 |
ORIG_HDR = $(ORIG_HDRCL) bxstring.h cmdline.h detect.h discovery.h generate.h input.h list.h logging.h parsecode.h \ |
| 27 |
parsing.h query.h regulex.h remove.h shape.h tools.h unicode.h |
| 28 |
ORIG_GEN = lexer.l parser.y |
| 29 |
ORIG_NORM = boxes.c bxstring.c cmdline.c detect.c discovery.c generate.c input.c list.c logging.c parsecode.c \ |
| 30 |
parsing.c query.c regulex.c remove.c shape.c tools.c unicode.c |
| 31 |
ORIG_SRC = $(ORIG_GEN) $(ORIG_NORM) |
| 32 |
ORIG_FILES = $(ORIG_SRC) $(ORIG_HDR) |
| 33 |
|
| 34 |
|
| 35 |
.PHONY: boxes.static check_dir clean build cov debug package static flags_unix flags_static flags_win32 flags_ |
| 36 |
|
| 37 |
.NOTPARALLEL: |
| 38 |
|
| 39 |
check_dir: |
| 40 |
@if [ "$(shell pwd | sed -e 's/^.*\///')" != "out" ] ; then \ |
| 41 |
echo ERROR: Please call make from the top level directory. ; \ |
| 42 |
exit 1 ; \ |
| 43 |
fi |
| 44 |
|
| 45 |
$(OUT_DIR): |
| 46 |
mkdir $(OUT_DIR) |
| 47 |
|
| 48 |
build: flags_$(BOXES_PLATFORM) | $(OUT_DIR) |
| 49 |
$(MAKE) -C $(OUT_DIR) -f $(SRC_DIR)/Makefile BOXES_PLATFORM=$(BOXES_PLATFORM) ALL_OBJ="$(ALL_OBJ)" STRIP=true \ |
| 50 |
CFLAGS_ADDTL="-O $(CFLAGS_ADDTL)" flags_$(BOXES_PLATFORM) $(BOXES_EXECUTABLE_NAME) |
| 51 |
|
| 52 |
static: flags_$(BOXES_PLATFORM) | $(OUT_DIR) |
| 53 |
$(MAKE) -C $(OUT_DIR) -f $(SRC_DIR)/Makefile BOXES_PLATFORM=$(BOXES_PLATFORM) ALL_OBJ="$(ALL_OBJ)" STRIP=true \ |
| 54 |
CFLAGS_ADDTL="-O $(CFLAGS_ADDTL)" flags_$(BOXES_PLATFORM) boxes.static |
| 55 |
|
| 56 |
cov: flags_$(BOXES_PLATFORM) | $(OUT_DIR) |
| 57 |
$(MAKE) -C $(OUT_DIR) -f $(SRC_DIR)/Makefile BOXES_PLATFORM=$(BOXES_PLATFORM) ALL_OBJ="$(ALL_OBJ)" STRIP=false \ |
| 58 |
CFLAGS_ADDTL="--coverage $(CFLAGS_ADDTL)" \ |
| 59 |
LDFLAGS_ADDTL="--coverage $(LDFLAGS_ADDTL)" \ |
| 60 |
flags_$(BOXES_PLATFORM) $(BOXES_EXECUTABLE_NAME) |
| 61 |
|
| 62 |
debug: flags_$(BOXES_PLATFORM) | $(OUT_DIR) |
| 63 |
$(MAKE) -C $(OUT_DIR) -f $(SRC_DIR)/Makefile BOXES_PLATFORM=$(BOXES_PLATFORM) ALL_OBJ="$(ALL_OBJ)" STRIP=false \ |
| 64 |
CFLAGS_ADDTL="-ggdb3 $(CFLAGS_ADDTL)" flags_$(BOXES_PLATFORM) $(BOXES_EXECUTABLE_NAME) |
| 65 |
|
| 66 |
boxes: $(ALL_OBJ) | check_dir |
| 67 |
$(CC) $(LDFLAGS) $^ -o $@ -lunistring -lpcre2-32 -lncurses |
| 68 |
if [ "$(STRIP)" = "true" ] ; then strip $@ ; fi |
| 69 |
|
| 70 |
boxes.static: $(ALL_OBJ) | check_dir |
| 71 |
$(CC) $(LDFLAGS) $^ -o $(BOXES_EXECUTABLE_NAME) -l:libunistring.a -l:libpcre2-32.a -l:libncurses.a |
| 72 |
if [ "$(STRIP)" = "true" ] ; then strip $(BOXES_EXECUTABLE_NAME) ; fi |
| 73 |
|
| 74 |
boxes.exe: $(ALL_OBJ) | check_dir |
| 75 |
$(CC) $(LDFLAGS) $^ -o $@ -lkernel32 -l:libunistring.a -l:libpcre2-32.a -l:libiconv.a |
| 76 |
if [ "$(STRIP)" = "true" ] ; then strip $@ ; fi |
| 77 |
|
| 78 |
|
| 79 |
flags_unix: |
| 80 |
$(eval CFLAGS := -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) |
| 81 |
$(eval LDFLAGS := $(LDFLAGS) $(LDFLAGS_ADDTL)) |
| 82 |
$(eval BOXES_EXECUTABLE_NAME := boxes) |
| 83 |
$(eval ALL_OBJ := $(GEN_SRC:.c=.o) $(ORIG_NORM:.c=.o)) |
| 84 |
echo $(filter-out boxes.o,$(ALL_OBJ)) > $(OUT_DIR)/modules.txt |
| 85 |
|
| 86 |
flags_static: |
| 87 |
$(eval CFLAGS := -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) |
| 88 |
$(eval LDFLAGS := $(LDFLAGS) -L../$(LIBUNISTRING_DIR)/lib/.libs -L../$(PCRE2_DIR)/.libs -L../$(LIBNCURSES_DIR)/lib $(LDFLAGS_ADDTL)) |
| 89 |
$(eval BOXES_EXECUTABLE_NAME := boxes) |
| 90 |
$(eval ALL_OBJ := $(GEN_SRC:.c=.o) $(ORIG_NORM:.c=.o)) |
| 91 |
echo $(filter-out boxes.o,$(ALL_OBJ)) > $(OUT_DIR)/modules.txt |
| 92 |
|
| 93 |
flags_win32: |
| 94 |
$(eval CFLAGS := -Os -s -m32 -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) |
| 95 |
$(eval LDFLAGS := $(LDFLAGS) -s -m32 $(LDFLAGS_ADDTL)) |
| 96 |
$(eval BOXES_EXECUTABLE_NAME := boxes.exe) |
| 97 |
$(eval ALL_OBJ := $(GEN_SRC:.c=.o) $(ORIG_NORM:.c=.o)) |
| 98 |
echo $(filter-out boxes.o,$(ALL_OBJ)) > $(OUT_DIR)/modules.txt |
| 99 |
|
| 100 |
flags_: |
| 101 |
@echo Please call make from the top level directory. |
| 102 |
exit 1 |
| 103 |
|
| 104 |
parser.c parser.h: parser.y lex.yy.h | check_dir |
| 105 |
$(YACC) -Wall --verbose --defines=parser.h -o parser.c $< |
| 106 |
|
| 107 |
lex.yy.c lex.yy.h: lexer.l | check_dir |
| 108 |
$(LEX) --header-file=lex.yy.h $< |
| 109 |
|
| 110 |
boxes.o: boxes.c boxes.h cmdline.h discovery.h generate.h input.h list.h logging.h parsing.h query.h remove.h shape.h tools.h unicode.h config.h | check_dir |
| 111 |
bxstring.o: bxstring.c bxstring.h tools.h unicode.h config.h | check_dir |
| 112 |
cmdline.o: cmdline.c cmdline.h boxes.h discovery.h logging.h query.h tools.h config.h | check_dir |
| 113 |
detect.o: detect.c detect.h boxes.h bxstring.h logging.h shape.h tools.h config.h | check_dir |
| 114 |
discovery.o: discovery.c discovery.h boxes.h logging.h tools.h unicode.h config.h | check_dir |
| 115 |
generate.o: generate.c generate.h boxes.h logging.h shape.h tools.h unicode.h config.h | check_dir |
| 116 |
input.o: input.c boxes.h input.h logging.h regulex.h tools.h unicode.h config.h | check_dir |
| 117 |
lex.yy.o: lex.yy.c parser.h boxes.h logging.h parsing.h tools.h shape.h unicode.h config.h | check_dir |
| 118 |
list.o: list.c list.h boxes.h bxstring.h parsing.h query.h shape.h tools.h unicode.h config.h | check_dir |
| 119 |
logging.o: logging.c logging.h tools.h config.h | check_dir |
| 120 |
parsecode.o: parsecode.c parsecode.h discovery.h lex.yy.h logging.h parsing.h parser.h query.h regulex.h shape.h tools.h unicode.h config.h | check_dir |
| 121 |
parser.o: parser.c boxes.h bxstring.h lex.yy.h logging.h parsecode.h parser.h parsing.h shape.h tools.h unicode.h config.h | check_dir |
| 122 |
parsing.o: parsing.c parsing.h bxstring.h parser.h lex.yy.h boxes.h logging.h tools.h config.h | check_dir |
| 123 |
query.o: query.c query.h boxes.h list.h logging.h tools.h config.h | check_dir |
| 124 |
regulex.o: regulex.c regulex.h boxes.h logging.h tools.h unicode.h config.h | check_dir |
| 125 |
remove.o: remove.c remove.h boxes.h detect.h logging.h shape.h tools.h unicode.h config.h | check_dir |
| 126 |
shape.o: shape.c shape.h boxes.h bxstring.h logging.h tools.h config.h | check_dir |
| 127 |
tools.o: tools.c tools.h boxes.h logging.h regulex.h shape.h unicode.h config.h | check_dir |
| 128 |
unicode.o: unicode.c unicode.h boxes.h tools.h config.h | check_dir |
| 129 |
|
| 130 |
|
| 131 |
package: $(BOXES_EXECUTABLE_NAME) |
| 132 |
if [ -z "$(PKG_NAME)" ] ; then exit 1 ; fi |
| 133 |
cp -a $(BOXES_EXECUTABLE_NAME) $(PKG_NAME)/ |
| 134 |
|
| 135 |
|
| 136 |
clean: |
| 137 |
rm -rf $(OUT_DIR) |
| 138 |
rm -f core |