]> bicyclesonthemoon.info Git - ott/bsta/blob - makefile
ONG will use generic function
[ott/bsta] / makefile
1 # "makefile" is automatically generated from "makefile.1.mak"
2
3 # Copyright (C) 2016, 2017, 2023  Balthasar SzczepaƄski
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as
7 # published by the Free Software Foundation, either version 3 of the
8 # License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Affero General Public License for more details.
14 #
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 DEFAULT_TARGET = debug
19 ifndef TARGET
20 TARGET = debug
21 # when want to change target run this first:
22 # make -B TARGET=target_name makefile
23 endif
24 PERL = perl
25
26 CC   =/usr/bin/gcc
27 CF   =-g -Wall
28
29 CHMOD=/usr/bin/chmod
30 CP   =/usr/bin/cp
31 MKDIR=/usr/bin/mkdir
32 PERL =/usr/bin/perl
33 RM   =/usr/bin/rm
34 SUDO =/usr/bin/sudo
35
36 BIN_PATH  = /botm/bin/test-bsta
37 DATA_PATH = /botm/data/test-bsta
38 LIB_PATH  = /botm/lib/test-bsta
39 LOG_PATH  = /botm/log/test-bsta
40 TMP_PATH  = /botm/tmp/test-bsta
41 WWW_PATH  = /botm/www/1190/bstatest
42
43 CONF = /botm/etc/www/conf/1190/test-bsta.conf
44 CRON = /etc/cron.d/test-bsta
45
46 CONFIGFILE = settings-$(TARGET).txt settings.txt
47 DEFAULT_CONFIGFILE = settings-$(DEFAULT_TARGET).txt settings.txt
48
49 # The configuration tool
50 CONFIGURE_CMD = $(PERL) ./configure.pl $(CONFIGFILE)
51
52 # keep these 2 lists in the same order!:
53 GENERATE_FROM=\
54 2words.1.pl\
55 attach.1.pl\
56 bbcode.1.pl\
57 bsta.1.conf\
58 bsta.1.cron\
59 bsta_lib.1.pm\
60 chat.1.pl\
61 frame.1.pl\
62 goto.1.pl\
63 info.1.pl\
64 oldlogs.1.pl\
65 ong.1.pl\
66 reset.1.pl\
67 updlist.1.pl\
68 viewer.1.pl
69
70 TO_GENERATE=\
71 2words.pl\
72 attach.pl\
73 bbcode.pl\
74 bsta.conf\
75 bsta.cron\
76 bsta_lib.pm\
77 chat.pl\
78 frame.pl\
79 goto.pl\
80 info.pl\
81 oldlogs.pl\
82 ong.pl\
83 reset.pl\
84 updlist.pl\
85 viewer.pl
86
87 DIR=\
88 $(BIN_PATH)\
89 $(DATA_PATH)\
90 $(LIB_PATH)\
91 $(LOG_PATH)\
92 $(TMP_PATH)\
93 $(WWW_PATH)
94
95 HIDDEN_DIR=\
96 $(DATA_PATH)\
97 $(TMP_PATH)
98
99 SETUID=\
100 2words\
101 bbcode\
102 attach\
103 chat\
104 frame\
105 goto\
106 info\
107 viewer
108
109 EXEC=\
110 2words.pl\
111 attach.pl\
112 bbcode.pl\
113 chat.pl\
114 frame.pl\
115 goto.pl\
116 info.pl\
117 oldlogs.pl\
118 ong.pl\
119 reset.pl\
120 updlist.pl\
121 viewer.pl
122
123 PERL_WRAP_EXEC=\
124 2words\
125 attach\
126 bbcode\
127 chat\
128 frame\
129 goto\
130 info\
131 viewer
132
133 BIN=\
134 $(EXEC)\
135 $(PERL_WRAP_EXEC)
136
137 LIB=\
138 botm-common/botm_common.pm\
139 bsta_lib.pm
140
141 WWW=\
142 botmlogo.png\
143 bsta.css\
144 timer.js
145
146
147 all: $(BIN) setuid exec
148
149 makefile: makefile.1.mak $(CONFIGFILE) configure.pl
150         $(CONFIGURE_CMD) < makefile.1.mak > makefile
151
152 configure.pl: $(CONFIGFILE) config/configure.1.pl
153         $(PERL) config/configure.1.pl target=direct settings-$(TARGET).txt config/settings.txt --in config/configure.1.pl --out configure.pl
154
155 $(TO_GENERATE): $(GENERATE_FROM) $(CONFIGFILE) configure.pl
156         $(CONFIGURE_CMD) --in $(GENERATE_FROM) --out $(TO_GENERATE)
157
158 $(PERL_WRAP_EXEC): %: exec/exec.c exec/settings.txt configure.pl
159         $(PERL) configure.pl path=$(BIN_PATH) target=$*.pl io_path=$(LOG_PATH) stderr=$*-stderr.log exec/settings.txt --in exec/exec.c --out $*.c
160         $(CC) $(CF) -o $@ $*.c
161
162 exec: $(EXEC)
163         $(CHMOD) +x $(EXEC)
164
165 wrap_exec: 
166         
167 setuid: $(SETUID)
168         $(CHMOD) u+s,g+s $(SETUID)
169
170
171 mktree:
172         $(MKDIR) -p $(DIR)
173         $(CHMOD) g-r,g-w,g-x,o-r,o-w,o-x $(HIDDEN_DIR)
174
175 ifdef BIN_PATH
176 cp_bin: $(BIN) setuid exec | mktree
177         $(RM) -f $(BIN_PATH)/*
178         $(CP) -p $(BIN) $(BIN_PATH)
179 endif
180
181 ifdef LIB_PATH
182 cp_lib: $(LIB) | mktree
183         $(RM) -f $(LIB_PATH)/*
184         $(CP) -p $(LIB) $(LIB_PATH)
185 endif
186
187 cp_www:
188         $(CP) -p $(WWW) $(WWW_PATH)
189
190 cp_conf: bsta.conf
191         $(CP) bsta.conf $(CONF)
192
193 cp_cron: bsta.cron
194         $(SUDO) $(CP) bsta.cron $(CRON)
195
196 install: all cp_bin cp_lib cp_www cp_conf cp_cron
197
198 clean:
199         $(RM) -f configure.pl $(TO_GENERATE) $(PERL_WRAP_EXEC) $(PERL_WRAP_EXEC:=.c)
200         $(PERL) config/configure.1.pl $(DEFAULT_CONFIGFILE) < makefile.1.mak > makefile
201
202 PHONY: all clean install setuid exec mktree cp_bin cp_lib cp_www cp_conf cp_cron