]> bicyclesonthemoon.info Git - ott/bsta/blobdiff - makefile
Adapted for new config tool.
[ott/bsta] / makefile
index ad0f7d25c2db44cc33ca77530f099c825bd8b95e..5a25a9e8fd42200f9d7cd97d60f5e7afcc188c62 100644 (file)
--- a/makefile
+++ b/makefile
-# makefile is generated from makefile.1.mak.
-#  2.07.2017
+# "makefile" is automatically generated from "makefile.1.mak"
+# 
+# Copyright (C) 2016, 2017, 2023  Balthasar Szczepański
 #
-# This is the makefile
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
 #
-#    Copyright (C) 2016 - 2017  Balthasar Szczepañski
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
 #
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-CC=/usr/bin/gcc
-CF=-g -Wall
-PL=/usr/bin/perl
-CP=/bin/cp
-MV=/bin/mv
-RM=/bin/rm
-CM=/bin/chmod
-OD=/eizm/bin/bsta/
-LD=/eizm/lib/bsta/
-WD=/eizm/www/time/bsta/
-
-all: moveout copyoutwww moveoutlib remove config.txt
-
-moveout: viewer viewer.pl frame frame.pl 2words 2words.pl chat chat.pl ong.pl updlist.pl oldlogs.pl attach attach.pl info info.pl goto goto.pl bbcode bbcode.pl   setuid exec
-       $(MV) viewer viewer.pl frame frame.pl 2words 2words.pl chat chat.pl ong.pl updlist.pl oldlogs.pl attach attach.pl info info.pl goto goto.pl bbcode bbcode.pl $(OD)
-
-copyout:   setuid exec
-#      $(CP) access.pl $(OD)
-
-copyoutwww: timer.js bsta.css   setuid exec
-       $(CP) timer.js bsta.css $(WD)
-
-
-moveoutlib: bsta_lib.pm   setuid exec
-       $(MV) bsta_lib.pm $(LD)
-
-setuid: viewer frame 2words attach chat info goto bbcode
-       $(CM) u+s viewer frame 2words attach chat info goto bbcode
-
-exec: viewer.pl frame.pl 2words.pl ong.pl updlist.pl oldlogs.pl attach.pl chat.pl info.pl goto.pl bbcode.pl
-       $(CM) +x viewer.pl frame.pl 2words.pl ong.pl updlist.pl oldlogs.pl attach.pl chat.pl info.pl goto.pl bbcode.pl
-
-remove: viewer.c frame.c 2words.c chat.c attach.c info.c goto.c bbcode.c   copyout moveout setuid exec 
-       $(RM) viewer.c frame.c 2words.c chat.c attach.c info.c goto.c bbcode.c
-
-
-bsta_lib.pm: bsta_lib.1.pm configure.pl settings
-       $(PL) configure.pl settings <bsta_lib.1.pm >bsta_lib.pm
-
-
-viewer: viewer.c
-       $(CC) $(CF) -o viewer viewer.c
-
-viewer.c: viewer.1.c configure.pl settings
-       $(PL) configure.pl settings <viewer.1.c >viewer.c
-
-viewer.pl: viewer.1.pl configure.pl settings
-       $(PL) configure.pl settings <viewer.1.pl >viewer.pl
-
-
-frame: frame.c
-       $(CC) $(CF) -o frame frame.c
-
-frame.c: frame.1.c configure.pl settings
-       $(PL) configure.pl settings <frame.1.c >frame.c
-
-frame.pl: frame.1.pl configure.pl settings
-       $(PL) configure.pl settings <frame.1.pl >frame.pl
-
-
-2words: 2words.c
-       $(CC) $(CF) -o 2words 2words.c
-
-2words.c: 2words.1.c configure.pl settings
-       $(PL) configure.pl settings <2words.1.c >2words.c
-
-2words.pl: 2words.1.pl configure.pl settings
-       $(PL) configure.pl settings <2words.1.pl >2words.pl
-
-
-attach: attach.c
-       $(CC) $(CF) -o attach attach.c
-
-attach.c: attach.1.c configure.pl settings
-       $(PL) configure.pl settings <attach.1.c >attach.c
-
-attach.pl: attach.1.pl configure.pl settings
-       $(PL) configure.pl settings <attach.1.pl >attach.pl
-
-
-chat: chat.c
-       $(CC) $(CF) -o chat chat.c
-
-chat.c: chat.1.c configure.pl settings
-       $(PL) configure.pl settings <chat.1.c >chat.c
-
-chat.pl: chat.1.pl configure.pl settings
-       $(PL) configure.pl settings <chat.1.pl >chat.pl
-
-
-info: info.c
-       $(CC) $(CF) -o info info.c
-
-info.c: info.1.c configure.pl settings
-       $(PL) configure.pl settings <info.1.c >info.c
-
-info.pl: info.1.pl configure.pl settings
-       $(PL) configure.pl settings <info.1.pl >info.pl
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+DEFAULT_TARGET = debug
+ifndef TARGET
+TARGET = debug
+# when want to change target run this first:
+# make -B TARGET=target_name makefile
+endif
+PERL = perl
+
+CC   =/usr/bin/gcc
+CF   =-g -Wall
+
+CHMOD=/usr/bin/chmod
+CP   =/usr/bin/cp
+MKDIR=/usr/bin/mkdir
+PERL =/usr/bin/perl
+RM   =/usr/bin/rm
+SUDO =/usr/bin/sudo
+
+BIN_PATH  = /botm/bin/test-bsta
+DATA_PATH = /botm/data/test-bsta
+LIB_PATH  = /botm/lib/test-bsta
+LOG_PATH  = /botm/log/test-bsta
+TMP_PATH  = /botm/tmp/test-bsta
+WWW_PATH  = /botm/www/1190/bstatest
+
+CONF = /botm/etc/www/conf/1190/test-bsta.conf
+CRON = /etc/cron.d/test-bsta
+
+CONFIGFILE = settings-$(TARGET).txt settings.txt
+DEFAULT_CONFIGFILE = settings-$(DEFAULT_TARGET).txt settings.txt
+
+# The configuration tool
+CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE)
+
+# keep these 2 lists in the same order!:
+GENERATE_FROM=\
+2words.1.pl\
+attach.1.pl\
+bbcode.1.pl\
+bsta.1.conf\
+bsta.1.cron\
+bsta_lib.1.pm\
+chat.1.pl\
+frame.1.pl\
+goto.1.pl\
+info.1.pl\
+oldlogs.1.pl\
+ong.1.pl\
+reset.1.pl\
+updlist.1.pl\
+viewer.1.pl
+
+TO_GENERATE=\
+2words.pl\
+attach.pl\
+bbcode.pl\
+bsta.conf\
+bsta.cron\
+bsta_lib.pm\
+chat.pl\
+frame.pl\
+goto.pl\
+info.pl\
+oldlogs.pl\
+ong.pl\
+reset.pl\
+updlist.pl\
+viewer.pl
+
+DIR=\
+$(BIN_PATH)\
+$(DATA_PATH)\
+$(LIB_PATH)\
+$(LOG_PATH)\
+$(TMP_PATH)\
+$(WWW_PATH)
+
+HIDDEN_DIR=\
+$(DATA_PATH)\
+$(TMP_PATH)
+
+SETUID=\
+2words\
+bbcode\
+attach\
+chat\
+frame\
+goto\
+info\
+viewer
+
+EXEC=\
+2words.pl\
+attach.pl\
+bbcode.pl\
+chat.pl\
+frame.pl\
+goto.pl\
+info.pl\
+oldlogs.pl\
+ong.pl\
+reset.pl\
+updlist.pl\
+viewer.pl
+
+PERL_WRAP_EXEC=\
+2words\
+attach\
+bbcode\
+chat\
+frame\
+goto\
+info\
+viewer
+
+BIN=\
+$(EXEC)\
+$(PERL_WRAP_EXEC)
+
+LIB=\
+bsta_lib.pm
+
+WWW=\
+botmlogo.png\
+bsta.css\
+timer.js
+
+
+all: $(BIN) setuid exec
+
+makefile: makefile.1.mak $(CONFIGFILE) configure.pl
+       $(CONFIGURE_CMD) < makefile.1.mak > makefile
+
+configure.pl: $(CONFIGFILE) config/configure.1.pl
+       $(PERL) config/configure.1.pl target=direct settings-$(TARGET).txt config/settings.txt --in config/configure.1.pl --out configure.pl
+
+$(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) configure.pl
+       $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE)
+
+$(PERL_WRAP_EXEC): %: exec/exec.c exec/settings.txt configure.pl
+       $(PERL) configure.pl path=$(BIN_PATH) target=$*.pl io_path=$(LOG_PATH) stderr=$*-stderr.log exec/settings.txt --in exec/exec.c --out $*.c
+       $(CC) $(CF) -o $@ $*.c
+
+exec: $(EXEC)
+       $(CHMOD) +x $(EXEC)
+
+wrap_exec: 
        
-goto: goto.c
-       $(CC) $(CF) -o goto goto.c
-
-goto.c: goto.1.c configure.pl settings
-       $(PL) configure.pl settings <goto.1.c >goto.c
-
-goto.pl: goto.1.pl configure.pl settings
-       $(PL) configure.pl settings <goto.1.pl >goto.pl
+setuid: $(SETUID)
+       $(CHMOD) u+s,g+s $(SETUID)
 
 
-bbcode: bbcode.c
-       $(CC) $(CF) -o bbcode bbcode.c
+mktree:
+       $(MKDIR) -p $(DIR)
+       $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR)
 
-bbcode.c: bbcode.1.c configure.pl settings
-       $(PL) configure.pl settings <bbcode.1.c >bbcode.c
+ifdef BIN_PATH
+cp_bin: $(BIN) setuid exec | mktree
+       $(RM) -f $(BIN_PATH)/*
+       $(CP) -p $(BIN) $(BIN_PATH)
+endif
 
-bbcode.pl: bbcode.1.pl configure.pl settings
-       $(PL) configure.pl settings <bbcode.1.pl >bbcode.pl
+ifdef LIB_PATH
+cp_lib: $(LIB) | mktree
+       $(RM) -f $(LIB_PATH)/*
+       $(CP) -p $(LIB) $(LIB_PATH)
+endif
 
+cp_www:
+       $(CP) -p $(WWW) $(WWW_PATH)
 
-ong.pl: ong.1.pl configure.pl settings
-       $(PL) configure.pl settings <ong.1.pl >ong.pl
+cp_conf: bsta.conf
+       $(CP) bsta.conf $(CONF)
 
-updlist.pl: updlist.1.pl configure.pl settings
-       $(PL) configure.pl settings <updlist.1.pl >updlist.pl
+cp_cron: bsta.cron
+       $(SUDO) $(CP) bsta.cron $(CRON)
 
-oldlogs.pl: oldlogs.1.pl configure.pl settings
-       $(PL) configure.pl settings <oldlogs.1.pl >oldlogs.pl
+install: all cp_bin cp_lib cp_www cp_conf cp_cron
 
+clean:
+       $(RM) -f configure.pl $(TO_GENERATE) $(PERL_WRAP_EXEC) $(PERL_WRAP_EXEC:=.c)
+       $(PERL) config/configure.1.pl $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile
 
-config.txt: config.1.txt configure.pl settings
-       $(PL) configure.pl settings <config.1.txt >config.txt
+PHONY: all clean install setuid exec mktree cp_bin cp_lib cp_www cp_conf cp_cron