[go: up one dir, main page]

File: common.mk

package info (click to toggle)
dwww 1.11.8
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 820 kB
  • sloc: perl: 3,178; ansic: 1,805; sh: 161; makefile: 120
file content (264 lines) | stat: -rw-r--r-- 9,661 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# vim:ts=2:et
# common includes for dwww
#

getCurrentMakefileName := $(CURDIR)/$(lastword $(MAKEFILE_LIST))
override TOPDIR   := $(dir $(call getCurrentMakefileName))

override PACKAGE  := dwww

PATH            := /usr/bin:/usr/sbin:/bin:/sbin:$(PATH)

# build abstraction
install_file    := install -p -o root -g root -m 644
install_script  := install -p -o root -g root -m 755
install_dir     := install -d -o root -g root -m 755
install_link    := ln -sf
compress        := gzip -9f

prefix          := /usr
etcdir          := /etc/$(PACKAGE)
bindir          := $(prefix)/bin
sbindir         := $(prefix)/sbin
mandir          := $(prefix)/share/man
sharedir        := $(prefix)/share
pkgsharedir     := $(prefix)/share/$(PACKAGE)
perllibdir      := $(prefix)/share/perl5
docdir          := $(prefix)/share/doc/$(PACKAGE)
libdir          := /var/lib/$(PACKAGE)
nlsdir          := $(prefix)/share/locale
cachedir 	      := /var/cache/$(PACKAGE)
webdocrootdir 	:= /var/www
webcgidir	      := $(prefix)/lib/cgi-bin
applicationsdir := $(prefix)/share/applications

PERL            := /usr/bin/perl
CC              := gcc
CFLAGS           = -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Werror -g -DVERSION='"$(VERSION)"'
LDFLAGS         :=
LIBS            := -lpub

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O0
else
  CFLAGS += -O2
endif


# determine our version number
ifndef VERSION
  CHANGELOGFILE     := $(TOPDIR)/debian/changelog
  VERSION           := $(shell LC_ALL=C dpkg-parsechangelog -l$(CHANGELOGFILE) \
                        | sed -ne 's/^Version: *//p')
###  DATE              := $(shell LC_ALL=C dpkg-parsechangelog -l$(CHANGELOGFILE) \
###                        | sed -n 's/^Date: *//p')
###  # pretty-print the date; I wish this was dynamic like the top-level makefile but oh well
###  DATE_EN           := $(shell LC_ALL=C date --date="$(DATE)" '+%d %B, %Y')
  export VERSION DATE DATE_EN

  ifndef DISTIBUTOR
    ifneq (,$(findstring ubuntu,$(VERSION)))
      DISTRIBUTOR     := Ubuntu
    else
      DISTRIBUTOR     := `lsb_release -is`
    endif
  endif
  ifneq (Ubuntu,$(DISTRIBUTOR))
    DISTRIBUTOR   := Debian
  endif
  distributor     := $(shell echo $(DISTRIBUTOR) | tr "[:upper:]" "[:lower:]")

  export DISTRIBUTOR distributor
  unexport CDPATH

  ifdef DESTDIR
    ifneq ($(DESTDIR),$(abspath $(DESTDIR)))
      $(error DESTDIR "$(DESTDIR)" is not an absolute path)
    endif
    override ddirshort  :=  DESTDIR
    export ddirshort
  endif
endif

sdir            := $(CURDIR)
ifndef bdir
  ifneq (,$(ALL_TARGET))
    bdir        := _build
  else
    bdir        :=
  endif
endif

ifndef DIR
  DIR           := .
endif

XGETTEXT_COMMON_OPTIONS   := --msgid-bugs-address $(PACKAGE)@packages.debian.org  \
                            --package-name $(PACKAGE)                             \
                            --package-version $(VERSION)                          \
                            --copyright-holder='Robert Luberda <robert@debian.org>'



ifndef MAKE_VERBOSE
  override MAKEFLAGS      += --silent --no-print-directory
  define msg
    if [ -n "$2" ] ; then                                       \
      echo "$(msgprefix) $2 $1 ...";                            \
    else case "$1" in                                           \
      ""|all|all-local|build-local)                             \
        ;;                                                      \
      install|install-local)                                    \
        echo "$(msgprefix) Installing files from $(DIR) ..." ;  \
        [ -z "$(DESTDIR)" ] ||                                  \
          echo "$(msgprefix)   (DESTDIR=$(DESTDIR))";           \
        ;;                                                      \
      clean|clean-local)                                        \
        echo "$(msgprefix) Cleaning $(DIR) ..."                 \
        ;;                                                      \
      *)                                                        \
        echo "$(msgprefix) Making $(DIR)/$(1) ..."              \
        ;;                                                      \
    esac; fi
  endef
else
  msg := :
endif

msgprefix         := *$(subst * ,*,$(wordlist 1,$(MAKELEVEL),* * * * * * * * * * * * * * * * * *))
emptyprefix       := $(subst *, ,$(msgprefix))


#SHELL:=/bin/echo
# install(dir,files,mode=compress|script|notdir)
define install
  set -e;                                                           \
  tgt="$1"; dir="$1"; files="$2";  prg="$(install_file)";           \
  doCompress=0;  bfile=""; what="file  ";                           \
  set -- $3;                                                        \
  while [ "$$1" ] ; do                                              \
    if [ "$$1" = "notdir" ] ; then                                  \
      dir="`dirname "$$dir"`";                                      \
      bfile="`basename "$$tgt"`";                                   \
    elif [ "$$1" = "compress" ] ; then                              \
      doCompress=1;                                                 \
    elif [ "$$1" = "script" ] ; then                                \
      prg="$(install_script)";                                      \
      what="script";                                                \
    fi;                                                             \
    shift;                                                          \
  done;                                                             \
  [ -n "$$files" ] ||                                               \
    echo "$(emptyprefix) installing dir    $(ddirshort)$$dir";      \
  $(install_dir) "$(DESTDIR)/$$dir";                                \
  for file in $$files; do                                           \
      [ -n "$$bfile" ] && tgt="$$dir/$$bfile"  ||                   \
        tgt="$$dir/`basename "$$file"`";                            \
      echo "$(emptyprefix) installing $$what $(ddirshort)$$tgt";    \
      $$prg "$$file" "$(DESTDIR)/$$tgt";                            \
      if [ "$$doCompress" -eq 1 ] ; then                            \
        echo "$(emptyprefix) compressing file  $(ddirshort)$$tgt";  \
        $(compress) "$(DESTDIR)/$$tgt";                             \
      fi;                                                           \
  done;
endef

# install(link_target,files)
define install_links
  set -e;                                                          \
  for file in $2; do                                               \
    echo "$(emptyprefix) installing link   $(ddirshort)$$file";    \
    $(install_dir) $(DESTDIR)/`dirname "$$file"`;                  \
    rm -f "$(DESTDIR)/$$file";                                     \
    $(install_link) "$1" "$(DESTDIR)/$$file";                      \
  done;
endef


define pochanged
  set -e;                                                                       \
  [ ! -e $(1) ] && rename=1 || rename=0 ;                                       \
  if [ $$rename = 0 ] ; then                                                    \
    diff -q  -I'POT-Creation-Date:' -I'PO-Revision-Date:' $(1) $(2) >/dev/null  \
      ||  rename=1;                                                             \
  fi;                                                                           \
  [ $$rename = 1 ] && mv -f $(2) $(1) || rm -f $(2);                            \
  touch $(1)
endef

define recurse
  set -e;                                                                 \
  for dir in $(SUBDIRS); do                                               \
    $(MAKE) -C "$$dir" DIR="$(DIR)/$$dir" $(1);                               \
  done
endef

define podtoman
    set -e;                                                     \
    find $(1) -type f -name '*.pod' -path '*/man*'                \
    | while read file; do                                       \
      sed -ne '1i=encoding utf8\n' -e '/^=head1/,$$p'  < $$file \
      | pod2man --utf8 --section=8 --center="Debian"            \
        --release="$(PACKAGE) v$(VERSION)"                      \
        --date="$(DATE_EN)"                                     \
        --name="INSTALL-DOCS"                                   \
      > `dirname $$file`/`basename $$file .pod`;                \
  done
endef


all: $(ALL_TARGET) | $(bdir)
	$(call recurse,$@)

clean-local:

install-local: $(ALL_TARGET)

clean: clean-local
	test -z "$(bdir)" || $(call msg,$@)
	test -z "$(bdir)" || rm -rf $(bdir)
	$(call recurse,$@)

install: install-local
	$(call recurse,$@)
	$(AFTER_INSTALL)

$(bdir):
	$(call msg,$@)
	test -z "$(bdir)" || mkdir -p $(bdir)

$(bdir)/%: %.in | $(bdir) $(MAKEFILE_LIST)
	$(call msg,$@)
	# try to be compatible with the both sarge and sid versions of make
	PERL5LIB="$(TOPDIR)/perl" $(PERL)  -e \
	'exec ("'$(PERL)'", "-e", join("",@ARGV)) if $$#ARGV >-1; '\
	'	$$|=1;					'\
	'	use Debian::Dwww::ConfigFile; 		'\
	'	$$d=ReadConfigFile("/dev/null");			'\
	'	$$v="";					'\
	'	foreach $$k (sort keys %{$$d}) {	'\
	'		$$v.="\t$$k=\"$$d->{$$k}->{defval}\"\n"	'\
	'			if $$k !~ /(TITLE)$$/;	'\
	'	}					'\
	'	while (<>) {				'\
	'		s/#VERSION#/$(VERSION)/g;  	'\
	'		s/#DISTRIBUTOR#/$(DISTRIBUTOR)/g; 	'\
	'		s/#distributor#/$(distributor)/g; 	'\
	'		s/^.*#DWWWVARS#.*$$/$$v/g;	'\
	'		print;				'\
	'	}					'\
	  < $< > $@
	touch -r $< $@

# debug
print-%:
	 @echo "$* is >>$($*)<<"

ifdef SHOW_DEPS
OLD_SHELL := $(SHELL)
SHELL = $(warning [$@ ($^)  \
 ($?)])$(OLD_SHELL)
endif

.PHONY: all clean install $(ALL_TARGET) clean-local install-local
.DEFAULT: all