# /* vim: set filetype=make : */ -*- make -*- ################################################################# # # _ _ _ _ _ (( # |=|=|=|=|=|.------------------. _))_ # |-|-|-|-|-|| all your 'needz' | ___\__/)_ # |_|_|_|_|_|'------------------. |_|_~~_|_| # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2. # # 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. ################################################################# DESTDIR = $(HOME)/opt/ App = a Parts = $(shell m4 -P needz.m4 $(App)) $(App) ################################### Dollar := $$ $(Dollar) := $$ Bin = $(DESTDIR)bin Var = $(DESTDIR)var Tmp = $(DESTDIR)tmp Lib = $(DESTDIR)lib Libs = list math misc os string trees Run = $(shell which gawk) Debug = "pgawk --profile=$(Tmp)/$(App)/awkprof.out --dump-variables=$(Tmp)/$(App)/awkvars.out --lint" Dirs = $(DESTDIR) $(Bin) $(Var) $(DESTDIR)/tmp $(DESTDIR)/tmp/$(App) Dirp = if [ ! -d $(dir) ]; then mkdir $(dir); fi; VPATH = ./:$(AWKPATH):$(M4PATH) ################################## all : installdirs $(Bin)/$(App) paths : make paths1 >> /tmp/aa paths1 : @$(foreach l, $(Libs), echo 'AWKPATH="$(Lib)/$l:$(Dollar)AWKPATH"';) @echo 'M4PATH=$(Dollar)M4PATH' parts : @$(foreach p, $(Parts), echo $p; ) installdirs : @$(foreach dir, $(Dirs), $(Dirp) ) debug : $(MAKE) Run=$(Debug) # generate one call to gawk with lots of "-f" commands call : $(Tmp)/$(App)_call $(Tmp)/$(App)_call : $(Parts) @echo $(Run) "\\" > $@ @$(foreach f, $^, echo " -f $f \\" >> $@; ) @echo -n " $(Dollar)" >> $@ @echo "*" >> $@ @chmod +x $@ @echo $@ # generate one she bang file with it all $(Bin)/$(App) : $(Parts) echo "#!$(Run) -f " > $@ @(cat $^ | m4 -P) >> $@ chmod +x $@