1 |
# |
2 |
# Motor IDE functional Makefile template |
3 |
# for terminal program in C |
4 |
# |
5 |
# Written by Konstantin Klyagin <konst@konst.org.ua> |
6 |
# Distributed under the GNU Public License |
7 |
|
8 |
# Project settings and files |
9 |
|
10 |
SOURCES = src/hydra.c src/modules.c src/signals.c src/netlib.c src/xmlparser.c src/xmlconfig.c src/request.c src/utils.c src/threads/worker.c src/threads/acceptor.c src/runners/cgid/cgid.c src/runners/runners.c src/threads/threads.c src/common/unixfd.c src/threads/logger.c src/common/log.c src/response.c src/vhost.c src/common/poller.c |
11 |
HEADERS = src/hydra.h src/modules.h src/signals.h src/netlib.h src/xmlparser.h src/xmlconfig.h src/request.h src/utils.h src/sysdeps/sysdeps.h src/runners/cgid/cgid.h src/runners/runners.h src/threads/threads.h src/common/unixfd.h src/common/common.h src/common/log.h src/response.h src/vhost.h |
12 |
DOCS = doc/README |
13 |
MISCF = |
14 |
BUILDF = Makefile |
15 |
ALL_FILES := $(strip $(SOURCES) $(HEADERS) $(MISCF) $(DOCS)) |
16 |
ALL_DIRS := $(sort $(dir $(ALL_FILES))) |
17 |
PROJNAME = hydra-rewrite |
18 |
PROJVER = `if test -f .project.version; then cat .project.version; else echo "0.1"; fi` |
19 |
INCLDIRS = |
20 |
PROG = hydra-rewrite |
21 |
DIST_TARGZ := $(PROJNAME)-$(PROJVER).tar.gz |
22 |
LDFLAGS = |
23 |
LDADD = @LIBS@ |
24 |
CLNAMES = |
25 |
|
26 |
# Motor specific targets |
27 |
|
28 |
# Executed every time there is a need to compile the stuff |
29 |
|
30 |
build: ready |
31 |
CFLAGS="-O0 -g" CXXFLAGS="-O0 -g" $(MAKE) |
32 |
|
33 |
# Executed to make sure the build environment is ready |
34 |
|
35 |
ready: |
36 |
|
37 |
# Invoked for cleaning up |
38 |
|
39 |
clean: ready |
40 |
$(MAKE) clean |
41 |
|
42 |
# This one starts the debugger |
43 |
|
44 |
debug: |
45 |
@prg=`echo "$(PROG)" | sed 's/-/_/g'`; prg=`find . -name "$${prg}"`; \ |
46 |
exec gdb --fullname -silent -tty `cat .debugtty && rm -f .debugtty` $${prg} |
47 |
|
48 |
# Runs the program |
49 |
|
50 |
run: |
51 |
@prg=`echo "$(PROG)" | sed 's/-/_/g'`; \ |
52 |
CMD="`find . -name $$prg -type f`"; \ |
53 |
`echo $$CMD` |
54 |
|
55 |
# Executed on project creation |
56 |
|
57 |
start: makesure |
58 |
|
59 |
# Executed on project modification |
60 |
|
61 |
update: |
62 |
|
63 |
# |
64 |
# Add connected libs into the distribution package |
65 |
# |
66 |
|
67 |
distextra: |
68 |
sed 's|^EXTRA_DIST\(.*\)$$|EXTRA_DIST\1 $(addsuffix /*, $(CLNAMES))|g' Makefile.am >.makefile.am |
69 |
mv .makefile.am Makefile.am |
70 |
|
71 |
# |
72 |
# Modify the Makefile.am thus connected libraries are to compile |
73 |
# don't forget to replace dirs in -L and -I |
74 |
# |
75 |
|
76 |
linklibs: |
77 |
|
78 |
distlib: linklibs |
79 |
@echo; \ |
80 |
if test ! -z "$$rsed"; then \ |
81 |
for file in `find . -name Makefile.am`; do \ |
82 |
sed "$$rsed" $$file >.makefile.am; \ |
83 |
mv .makefile.am $$file; \ |
84 |
done; \ |
85 |
fi |
86 |
@echo -e "dist-hook:\n\tcd \$$(top_distdir); subs=\`egrep \"^[:space:]*SUBDIRS\" Makefile.am | sed 's/SUBDIRS[ =]\+//g'\`; \\" >.makefile.am |
87 |
@echo -e "\techo \"SUBDIRS = $(CLNAMES) \$$\$$subs\" >>.makefile.am; \\" >>.makefile.am |
88 |
@echo -e "\tegrep -v \"^[:space:]*SUBDIRS\" Makefile.am >>.makefile.am; \\" >>.makefile.am |
89 |
@echo -e "\tmv .makefile.am Makefile.am; autoconf && automake" >>.makefile.am |
90 |
@echo -e "\n# END OF MOTOR DIST TARGETS #" >>.makefile.am |
91 |
@cat Makefile.am >>.makefile.am |
92 |
@mv .makefile.am Makefile.am |
93 |
@cat configure.in | egrep -v "^[[:space:]]*AC_OUTPUT|^[[:space:]]*AC_CONFIG_SUBDIRS" >.configure.in; \ |
94 |
libdirs="$(CLNAMES)"; \ |
95 |
if test -n "$$libdirs"; then \ |
96 |
libdirs=`echo $$libdirs | sed 's/^\s+|\s+$$//g'`; \ |
97 |
echo "AC_CONFIG_SUBDIRS($$libdirs)" >>.configure.in; \ |
98 |
fi; \ |
99 |
cat configure.in | egrep "^[[:space:]]*AC_OUTPUT" >>.configure.in; \ |
100 |
mv .configure.in configure.in; \ |
101 |
|
102 |
dist: |
103 |
$(MAKE) dist |
104 |
$(MAKE) -f Makefile.func automake |
105 |
|
106 |
distcleanup: |
107 |
@if test -f Makefile.am; then \ |
108 |
cat Makefile.am | perl -e \ |
109 |
"while(<STDIN>) { \ |
110 |
chomp; push (@toshow, \$$_); \ |
111 |
@toshow = () if \$$_ eq '# END OF MOTOR DIST TARGETS #'; \ |
112 |
}; \ |
113 |
print map { \$$_, \"\n\" } @toshow;" \ |
114 |
>.makefile.am; \ |
115 |
mv .makefile.am Makefile.am; \ |
116 |
fi |
117 |
|
118 |
rpmspec: |
119 |
@if test ! -f hydra-rewrite.spec; then \ |
120 |
echo "hydra-rewrite.spec file not found!"; \ |
121 |
exit 1; \ |
122 |
fi |
123 |
@sed "s/^[[:space:]]*Version\: .*$$/Version: $(PROJVER)/g" <hydra-rewrite.spec >hydra-rewrite.spec.uver |
124 |
@if test -z "`egrep '^[[:space:]]*BuildRoot: ' hydra-rewrite.spec`"; then \ |
125 |
echo "BuildRoot: /var/tmp/%{name}-buildroot" >hydra-rewrite.spec; \ |
126 |
cat hydra-rewrite.spec.uver >>hydra-rewrite.spec; \ |
127 |
else \ |
128 |
mv hydra-rewrite.spec.uver hydra-rewrite.spec; \ |
129 |
fi |
130 |
@rm -f mv hydra-rewrite.spec.uver |
131 |
|
132 |
rpm: rpmspec dist |
133 |
@if test ! -f ~/.motor/rpmrc; then \ |
134 |
echo "macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/%{_target}/macros:/etc/rpm/macros.specspo:/etc/rpm/macros:/etc/rpm/%{_target}/macros:~/.rpmmacros:~/.motor/rpmmacros" >~/.motor/rpmrc; \ |
135 |
fi |
136 |
@if test ! -f ~/.motor/rpmmacros; then \ |
137 |
echo "%_topdir $${HOME}/.motor/rpm" >>~/.motor/rpmmacros; \ |
138 |
echo "%_builddir %{_topdir}/BUILD" >>~/.motor/rpmmacros; \ |
139 |
echo "%_rpmdir %{_topdir}/RPMS" >>~/.motor/rpmmacros; \ |
140 |
echo "%_sourcedir %{_topdir}/SOURCES" >>~/.motor/rpmmacros; \ |
141 |
echo "%_specdir %{_topdir}/SPECS" >>~/.motor/rpmmacros; \ |
142 |
echo "%_srcrpmdir %{_topdir}/SRPMS" >>~/.motor/rpmmacros; \ |
143 |
echo "%_tmppath %{_var}/tmp" >>~/.motor/rpmmacros; \ |
144 |
fi |
145 |
@-for i in SPECS BUILD RPMS SRPMS; do mkdir -p "$${HOME}/.motor/rpm/$$i"; done |
146 |
unset LINGUAS; rpm --rcfile ~/.motor/rpmrc -ta /$(DIST_TARGZ) |
147 |
find "${HOME}/.motor/rpm" -name "$(PROJNAME)-$(PROJVER)*rpm" -exec mv {} "" \; |
148 |
rm -rf "${HOME}/.motor/rpm" |
149 |
|
150 |
|
151 |
makesure: |
152 |
@for i in $(ALL_FILES) $(BUILDF); do \ |
153 |
if test ! -f $$i; then touch $$i; fi; \ |
154 |
done |
155 |
|
156 |
tags: |
157 |
@if test "$$MOTOR_TAGS" = "file"; then \ |
158 |
TFILES="$$MOTOR_CURRENTFILE"; \ |
159 |
elif test "$$MOTOR_TAGS" = "project"; then \ |
160 |
TFILES=" src/hydra.c src/modules.c src/signals.c src/netlib.c src/xmlparser.c src/xmlconfig.c src/request.c src/utils.c src/threads/worker.c src/threads/acceptor.c src/runners/cgid/cgid.c src/runners/runners.c src/threads/threads.c src/common/unixfd.c src/threads/logger.c src/common/log.c src/response.c src/vhost.c src/common/poller.c src/hydra.h src/modules.h src/signals.h src/netlib.h src/xmlparser.h src/xmlconfig.h src/request.h src/utils.h src/sysdeps/sysdeps.h src/runners/cgid/cgid.h src/runners/runners.h src/threads/threads.h src/common/unixfd.h src/common/common.h src/common/log.h src/response.h src/vhost.h"; \ |
161 |
elif test "$$MOTOR_TAGS" = "all"; then \ |
162 |
TFILES=" src/hydra.c src/modules.c src/signals.c src/netlib.c src/xmlparser.c src/xmlconfig.c src/request.c src/utils.c src/threads/worker.c src/threads/acceptor.c src/runners/cgid/cgid.c src/runners/runners.c src/threads/threads.c src/common/unixfd.c src/threads/logger.c src/common/log.c src/response.c src/vhost.c src/common/poller.c src/hydra.h src/modules.h src/signals.h src/netlib.h src/xmlparser.h src/xmlconfig.h src/request.h src/utils.h src/sysdeps/sysdeps.h src/runners/cgid/cgid.h src/runners/runners.h src/threads/threads.h src/common/unixfd.h src/common/common.h src/common/log.h src/response.h src/vhost.h"; \ |
163 |
fi; \ |
164 |
if test ! -z "$$TFILES"; then ctags --c++-types=cdefgmnpstuvx --excmd=number -f - $$TFILES; fi |
165 |
|
166 |
target: ready |
167 |
@CFLAGS="-O0 -g" CXXFLAGS="-O0 -g" $(MAKE) ${MOTOR_TARGET} |
168 |
|
169 |
gnudoc: |
170 |
touch INSTALL NEWS README COPYING AUTHORS ChangeLog |
171 |
|
172 |
getversion: |
173 |
@if test -f configure.in; then \ |
174 |
P_VER="`cat configure.in | \ |
175 |
egrep '^[[:space:]]*AM_INIT_AUTOMAKE' | \ |
176 |
sed 's/^AM_INIT_AUTOMAKE.*,//;s/)$$//;s/[[:space:]]//'`"; \ |
177 |
if test -n $$P_VER; then \ |
178 |
echo $$P_VER >.project.version; \ |
179 |
fi; \ |
180 |
fi |
181 |
|
182 |
.PHONY: build update debug automake dist rpm start makesure distextra \ |
183 |
distlib gettext target linklibs gnudoc getversion |