Browse Source

restructured premake

svn path=/trunk/; revision=35116
paul 2 years ago
parent
commit
6a13e3b186
6 changed files with 103 additions and 129 deletions
  1. 66
    45
      Makefile
  2. 1
    1
      build/buildrun.sh
  3. 10
    2
      events/Makefile
  4. 26
    24
      news/Makefile
  5. 0
    32
      pdfreaders/Makefile
  6. 0
    25
      tools/Makefile

+ 66
- 45
Makefile View File

@@ -1,6 +1,6 @@
1
-.PHONY: all
2
-
3
-all: subdirs localmenus date_today SOURCEUPDATES
1
+.PHONY: all .FORCE
2
+.FORCE:
3
+all:
4 4
 
5 5
 # -----------------------------------------------------------------------------
6 6
 # Dive into subdirectories
@@ -8,61 +8,47 @@ all: subdirs localmenus date_today SOURCEUPDATES
8 8
 
9 9
 SUBDIRS := $(shell find */* -name "Makefile" | xargs dirname)
10 10
 
11
-.PHONY: subdirs $(SUBDIRS)
12
-
13
-subdirs: $(SUBDIRS)
11
+$(SUBDIRS): .FORCE
12
+	$(MAKE) -j -k -C $@ || true
14 13
 
15
-# run jobs for tools/ only after events/ and news/ have been completed
16
-tools: | events news
17
-
18
-$(SUBDIRS):
19
-	$(MAKE) -k -C $@ || true
14
+all: $(SUBDIRS)
20 15
 
21 16
 # -----------------------------------------------------------------------------
22 17
 # Handle local menus
23 18
 # -----------------------------------------------------------------------------
24 19
 
25
-HELPERFILE := menuhelper
26
-SELECT := '<localmenu.*</localmenu>'
27
-STYLESHEET := ./tools/buildmenu.xsl 
28
-
29
-FIND := ./\(.*/\)*\(.*\)\.\([a-z][a-z]\)\.xhtml:[ \t]*\(.*\)
30
-REPLACE := <menuitem language="\3"><dir>/\1</dir><link>\2.html</link>\4</menuitem>
20
+MENUSOURCES := $(shell find -name '*.xhtml' |xargs grep -l '<localmenu.*</localmenu>' )
31 21
 
32
-sources := $(shell grep -l -R --include='*.xhtml' $(SELECT) . )
22
+localmenuinfo.en.xml: ./tools/buildmenu.xsl $(MENUSOURCES)
23
+	{ printf '<localmenuset>'; \
24
+	  grep -E '<localmenu.*</localmenu>' $^ \
25
+          | sed -r 's;(.*/)?(.+)\.([a-z][a-z])\.xhtml:(.+);\
26
+                    <menuitem language="\3"><dir>/\1</dir><link>\2.html</link>\4</menuitem>;'; \
27
+	  printf '</localmenuset>'; \
28
+	} | xsltproc -o $@ $< -
33 29
 
34
-.PHONY: localmenus
30
+all: localmenuinfo.en.xml
35 31
 
36
-localmenus: localmenuinfo.en.xml
37
-
38
-localmenuinfo.en.xml: $(sources) $(STYLESHEET)
39
-	echo \<localmenuset\> > $(HELPERFILE)
40
-	grep -R --include='*.xhtml' $(SELECT) .| sed -e 's,$(FIND),$(REPLACE),' >> $(HELPERFILE)
41
-	echo \</localmenuset\> >> $(HELPERFILE)
42
-	xsltproc -o $@ $(STYLESHEET) $(HELPERFILE) 
43
-	rm $(HELPERFILE)
32
+# -----------------------------------------------------------------------------
33
+# Timestamp files for regular jobs and XML inclusion in various places
34
+# -----------------------------------------------------------------------------
44 35
 
45
-YEAR := <?xml version="1.0" encoding="utf-8"?><dateset><date year="$(shell date +%Y)" /></dateset> 
36
+YEAR  := <?xml version="1.0" encoding="utf-8"?><dateset><date year="$(shell date +%Y)" /></dateset> 
46 37
 MONTH := <?xml version="1.0" encoding="utf-8"?><dateset><date month="$(shell date +%Y-%m)" /></dateset> 
47
-DAY := <?xml version="1.0" encoding="utf-8"?><dateset><date day="$(shell date +%Y-%m-%d)" /></dateset> 
38
+DAY   := <?xml version="1.0" encoding="utf-8"?><dateset><date day="$(shell date +%Y-%m-%d)" /></dateset>
48 39
 
49
-.PHONY: date_today d_day.en.xml
50
-date_today: d_year.en.xml d_month.en.xml d_day.en.xml
40
+d_day.en.xml: $(if $(findstring   $(DAY),$(shell cat d_day.en.xml)),,.FORCE)
41
+	printf %s\\n   '$(DAY)' >$@
42
+d_month.en.xml: $(if $(findstring $(MONTH),$(shell cat d_month.en.xml)),,.FORCE)
43
+	printf %s\\n '$(MONTH)' >$@
44
+d_year.en.xml: $(if $(findstring  $(YEAR),$(shell cat d_year.en.xml)),,.FORCE)
45
+	printf %s\\n  '$(YEAR)' >$@
51 46
 
52
-d_day.en.xml:
53
-	grep -q '$(DAY)' $@ || echo '$(DAY)' >$@
54
-d_month.en.xml: d_day.en.xml
55
-	grep -q '$(MONTH)' $@ || echo '$(MONTH)' >$@
56
-d_year.en.xml: d_month.en.xml
57
-	grep -q '$(YEAR)' $@ || echo '$(YEAR)' >$@
47
+all: d_year.en.xml d_month.en.xml d_day.en.xml
58 48
 
59
-.PHONY: SOURCEUPDATES
60
-
61
-# finish jobs in subdirs before updating .sources
62
-SOURCEUPDATES: | subdirs
63
-
64
-SOURCEUPDATES: $(shell find ./ -name '*.sources')
65
-SOURCEREQS = $(shell ./build/source_globber.sh sourceglobs $@ |sed -r 's;$$;.??.xml;g')
49
+# -----------------------------------------------------------------------------
50
+# Update .sources files
51
+# -----------------------------------------------------------------------------
66 52
 
67 53
 # use shell globbing to work around faulty globbing in gnu make
68 54
 SOURCEDIRS = $(shell sed -rn 's;^(.*/)[^/]*:(\[\]|global)$$;\1;gp' $@ \
@@ -70,6 +56,41 @@ SOURCEDIRS = $(shell sed -rn 's;^(.*/)[^/]*:(\[\]|global)$$;\1;gp' $@ \
70 56
                  printf '%s\n' $$glob; \
71 57
                done \
72 58
               )
59
+SOURCEREQS = $(shell ./build/source_globber.sh sourceglobs $@ |sed -r 's;$$;.??.xml;g')
60
+
61
+all: $(shell find ./ -name '*.sources')
62
+
63
+# -----------------------------------------------------------------------------
64
+# generate tag maps
65
+# -----------------------------------------------------------------------------
66
+
67
+TAGMAP := $(shell find $(PWD) -name '*.xml' \
68
+             | xargs ./build/source_globber.sh map_tags \
69
+            )
70
+
71
+TAGNAMES := $(shell printf %s '$(TAGMAP)' \
72
+              | cut -d" " -f2- \
73
+              | tr ' ' '\n' \
74
+              | grep -vE '[\$%/:()]' \
75
+              | sort -u \
76
+              | xargs printf 'tools/tagmaps/%s.map ' \
77
+             )
78
+
79
+MAPREQS = $(shell printf %s '$(TAGMAP)' \
80
+            | sed -r 's;[^ ]+\...\.xml;\n&;g' \
81
+            | grep ' $*' \
82
+            | cut -d' ' -f1 \
83
+           )
84
+
85
+all: $(TAGNAMES)
86
+
87
+# -----------------------------------------------------------------------------
88
+# Second Expansion rules
89
+# -----------------------------------------------------------------------------
73 90
 .SECONDEXPANSION:
74
-%.sources: $$(SOURCEDIRS) $$(SOURCEREQS)
91
+
92
+%.sources: $$(SOURCEDIRS) $$(SOURCEREQS) | $(TAGNAMES)
75 93
 	touch $@
94
+
95
+tools/tagmaps/%.map: $$(MAPREQS) | $(SUBDIRS)
96
+	printf '%s\n' $^ > $@

+ 1
- 1
build/buildrun.sh View File

@@ -17,7 +17,7 @@ build_into(){
17 17
 
18 18
   validate_caches
19 19
 
20
-  make -j $ncpu -C "$basedir" \
20
+  make -C "$basedir" \
21 21
   | t_logstatus premake
22 22
 
23 23
   dir_maker "$basedir" "$stagedir"

+ 10
- 2
events/Makefile View File

@@ -1,7 +1,15 @@
1
-.PHONY: generated_xml/wikievents.en.xml
1
+.PHONY: all .FORCE
2
+.FORCE:
3
+all:
2 4
 
3
-generated_xml/wikievents.en.xml:
5
+# -----------------------------------------------------------------------------
6
+# Fetch event calendar from Wiki
7
+# -----------------------------------------------------------------------------
8
+
9
+generated_xml/wikievents.en.xml: .FORCE
4 10
 	wget --user-agent="" -qO- "https://wiki.fsfe.org/Events/Published?action=refresh" \
5 11
 	| xsltproc --html ../tools/wikicalendars.xsl - 2>&- \
6 12
 	| xmllint --format - >$@.cache
7 13
 	diff -q $@.cache $@ || mv $@.cache $@
14
+
15
+all: generated_xml/wikievents.en.xml

+ 26
- 24
news/Makefile View File

@@ -1,32 +1,34 @@
1
-XSL_STYLESHEET := xhtml2xml.xsl
1
+.PHONY: all .FORCE
2
+.FORCE:
3
+all:
2 4
 
3
-# For a correct generation of the link, use full path from this directory
4
-FILES := ../news/*/*.xhtml ../projects/*/*.xhtml
5
+# -----------------------------------------------------------------------------
6
+# remove xml files where original xhtml does not exist anymore
7
+# -----------------------------------------------------------------------------
8
+# note the reversal of target <-> prerequisite relationship
9
+# make will execute thew command for all xhtml files (targets) that
10
+# do not exist, in doing so it will not make the target, but rather
11
+# remove the xml file that generated it
5 12
 
6
-# Trying to keep things readable
7
-ACTUAL_PREREQUISITE = ../$$(echo $* | sed -e 's,___,/,g').xhtml
8
-FIND_XHTML = ../$$(echo $$FILE | sed -e 's,___,/,g').xhtml
9
-TRANSFORM = xsltproc  --stringparam link $$(echo $$FILE | sed -e 's,\.\.,,' | sed -e 's,..\.xhtml,html,') $(XSL_STYLESHEET) $$FILE > $@
13
+REMOVALS := $(subst ___,/,$(patsubst ./generated_xml/%.xml,../%.xhtml,$(wildcard ./generated_xml/*.xml)))
14
+../%.xhtml:
15
+	rm generated_xml/$(subst /,___,$*).xml
10 16
 
11
-# Select files
12
-sources := $(shell grep -l "<html newsdate" $(FILES))
13
-all_xmls := $(notdir $(basename $(wildcard ./generated_xml/*.xml)))
17
+all: $(REMOVALS)
14 18
 
15
-# Create targets 
16
-first_step = $(subst /,___, $(subst ../,, $(sources)))
17
-too_xml := $(addprefix ./generated_xml/, $(first_step:.xhtml=.xml))
19
+# -----------------------------------------------------------------------------
20
+# build includable xml files from all xhtml files that contain news
21
+# -----------------------------------------------------------------------------
22
+XMLNAMES := $(shell find ../ -name '*.xhtml' \
23
+              | xargs grep -l "<html newsdate" \
24
+              | sed -r 's;/;___;g; s;^\.\.___(.+)\.xhtml$$;./generated_xml/\1.xml;;' \
25
+             )
18 26
 
27
+XMLSOURCE = ../$(subst ___,/,$*).xhtml
19 28
 
20
-.PHONY: all
21
-all: $(too_xml) remove_artifacts
22
-
23
-generated_xml/%.xml: $(sources)
24
-	FILE="$(ACTUAL_PREREQUISITE)"; if printf "%s" "$?" |grep -qF "$$FILE"; then $(TRANSFORM); fi
25
-
26
-# Remove xml files for files thas are no longer in CVS
27
-.PHONY: remove_artifacts
28
-remove_artifacts:
29
-	for FILE in $(all_xmls); do if [ ! -f $(FIND_XHTML) ]; then rm generated_xml/$$FILE.xml ; fi ; done
30
-
29
+all: $(XMLNAMES)
31 30
 
31
+.SECONDEXPANSION:
32 32
 
33
+generated_xml/%.xml: $$(XMLSOURCE) #xhtml2xml.xsl
34
+	xsltproc --stringparam link /$(subst ___,/,$(basename $*)).html xhtml2xml.xsl $< > $@

+ 0
- 32
pdfreaders/Makefile View File

@@ -1,32 +0,0 @@
1
-XSL_STYLESHEET := xhtml2xml.xsl
2
-
3
-# For a correct generation of the link, use full path from this directory
4
-FILES := ../pdfreaders/*/*.xhtml ../projects/*/*.xhtml
5
-
6
-# Trying to keep things readable
7
-ACTUAL_PREREQUISITE = ../$$(echo $* | sed -e 's,___,/,g').xhtml
8
-FIND_XHTML = ../$$(echo $$FILE | sed -e 's,___,/,g').xhtml
9
-TRANSFORM = xsltproc  --stringparam link $$(echo $$FILE | sed -e 's,\.\.,,' | sed -e 's,..\.xhtml,html,') $(XSL_STYLESHEET) $$FILE > $@
10
-
11
-# Select files
12
-sources := $(shell grep -l "<html newsdate" $(FILES))
13
-all_xmls := $(notdir $(basename $(wildcard ./generated_xml/*.xml)))
14
-
15
-# Create targets 
16
-first_step = $(subst /,___, $(subst ../,, $(sources)))
17
-too_xml := $(addprefix ./generated_xml/, $(first_step:.xhtml=.xml))
18
-
19
-
20
-.PHONY: all
21
-all: $(too_xml) remove_artifacts
22
-
23
-generated_xml/%.xml: $(sources)
24
-	for FILE in $?; do if [ "$$FILE" = "$(ACTUAL_PREREQUISITE)" ]; then $(TRANSFORM); else touch $@ ;  fi; done
25
-
26
-# Remove xml files for files thas are no longer in CVS
27
-.PHONY: remove_artifacts
28
-remove_artifacts:
29
-	for FILE in $(all_xmls); do if [ ! -f $(FIND_XHTML) ]; then rm generated_xml/$$FILE.xml ; fi ; done
30
-
31
-
32
-

+ 0
- 25
tools/Makefile View File

@@ -1,25 +0,0 @@
1
-
2
-BASEDIR := $(shell dirname $(PWD))
3
-TAGMAP := $(shell find $(BASEDIR) -name '*.xml' \
4
-             | xargs ../build/source_globber.sh map_tags \
5
-            )
6
-
7
-TAGNAMES = $(shell printf %s '$(TAGMAP)' \
8
-             | cut -d" " -f2- \
9
-             | tr ' ' '\n' \
10
-             | egrep -v '[\$%/:()]' \
11
-             | sort -u \
12
-             | xargs printf 'tagmaps/%s.map ' \
13
-            )
14
-
15
-all: $(TAGNAMES)
16
-
17
-MAPREQS = $(shell printf %s '$(TAGMAP)' \
18
-            | sed -r 's;[^ ]+\...\.xml;\n&;g' \
19
-            | grep ' $*' \
20
-            | cut -d' ' -f1 \
21
-           )
22
-
23
-.SECONDEXPANSION:
24
-tagmaps/%.map: $$(MAPREQS)
25
-	printf '%s\n' $^ > $@

Loading…
Cancel
Save