Makefile: Makefile instead shellscript

This commit is contained in:
Denis Knauf 2012-01-23 13:29:56 +01:00
parent b2941025f1
commit faa16696d2

176
Makefile
View file

@ -8,24 +8,24 @@ OTHER_FILES = \
MIT-LICENSE.txt \ MIT-LICENSE.txt \
GPL-LICENSE.txt GPL-LICENSE.txt
VER = $$(cat version.txt) VER = $(shell cat version.txt)
VER_SED = sed s/@VERSION/"${VER}"/ VER_SED = sed s/@VERSION/"$(VER)"/
DATE = $$(git log -1 --pretty=format:%ad) DATE = $(shell git log -1 --pretty=format:%ad)
DATE_SED = sed s/@DATE/"${DATE}"/ DATE_SED = sed s/@DATE/"$(DATE)"/
JQ = $$(sed -nE "s/.*JQUERY[ \t]*=[ \t]*[\"'](.*)[\"'].*/\1/p" "${SRC_DIR}/_loader.js") JQ = $(shell sed -ne "s/.*JQUERY[ \t]*=[ \t]*[\"']\(.*\)[\"'].*/\1/p" "$(SRC_DIR)/_loader.js")
JQUI = $$(sed -nE "s/.*JQUERY_UI[ \t]*=[ \t]*[\"'](.*)[\"'].*/\1/p" "${SRC_DIR}/_loader.js") JQUI = $(shell sed -ne "s/.*JQUERY_UI[ \t]*=[ \t]*[\"']\(.*\)[\"'].*/\1/p" "$(SRC_DIR)/_loader.js")
DEMO_FILES = $$(cd ${DEMOS_DIR}; find . -mindepth 1 -maxdepth 1 -type f) DEMO_FILES = $(shell cd $(DEMOS_DIR); find . -mindepth 1 -maxdepth 1 -type f)
DEMO_SUBDIRS = $$(cd ${DEMOS_DIR}; find . -mindepth 1 -maxdepth 1 -type d) DEMO_SUBDIRS = $(shell cd $(DEMOS_DIR); find . -mindepth 1 -maxdepth 1 -type d)
DEMO_RE = (<script[^>]*_loader\.js[^>]*><\/script>|<!--\[\[|\]\]-->)[^<]* DEMO_RE = (<script[^>]*_loader\.js[^>]*><\/script>|<!--\[\[|\]\]-->)[^<]*
DEMO_SED = sed -nE '1h;1!H;$${;g;s/${DEMO_RE}//g;p;}' DEMO_SED = sed -ne '1h;1!H;$${;g;s/$(DEMO_RE)//g;p;}'
JS_SED = sed -nE "s/[ \t]*js\([\"'](.*)[\"']\).*/\1/p" JS_SED = sed -ne "s/[ \t]*js([\"']\(.*\)[\"']).*/\1/p"
CSS_SED = sed -nE "s/[ \t]*css\([\"'](.*)[\"']\).*/\1/p" CSS_SED = sed -ne "s/[ \t]*css([\"']\(.*\)[\"']).*/\1/p"
concat_js = \ concat_js = \
files=$$(cat "$(1)/_loader.js" | ${JS_SED}); \ files=$$($(JS_SED) "$(1)/_loader.js"); \
if [ -f "$(1)/intro.js" ]; then \ if [ -f "$(1)/intro.js" ]; then \
files="intro.js $$files"; \ files="intro.js $$files"; \
fi; \ fi; \
@ -33,80 +33,110 @@ concat_js = \
files="$$files outro.js"; \ files="$$files outro.js"; \
fi; \ fi; \
old=$$PWD; \ old=$$PWD; \
(cd "$(1)"; cat $$files; cd "$$old") \ if ! [ X = "X$$files" ]; then \
| ${VER_SED} \ (cd "$(1)"; cat $$files; cd "$$old") \
| ${DATE_SED} \ | $(VER_SED) \
> "$(2)" | $(DATE_SED) \
> "$(2)" ; \
fi
concat_css = \ concat_css = \
files=$$(cat "$(1)/_loader.js" | ${CSS_SED}); \ files=$$($(CSS_SED) "$(1)/_loader.js"); \
if [ "$$files" ]; then \ if ! [ X = "X$$files" ]; then \
old=$$PWD; \ old=$$PWD; \
(cd "$(1)"; cat $$files; cd "$$old") \ (cd "$(1)"; cat $$files; cd "$$old") \
| ${VER_SED} \ | ${VER_SED} \
| ${DATE_SED} \ | ${DATE_SED} \
> "$(2)"; \ > "$(2)"; \
fi fi
zip: FC_V_DIR = $(BUILD_DIR)/fullcalendar-$(VER)
@rm -rf ${BUILD_DIR}/fullcalendar FC_DIR = $(FC_V_DIR)/fullcalendar
@rm -rf ${BUILD_DIR}/fullcalendar-* FCJS = $(FC_DIR)/fullcalendar.js
@mkdir -p ${BUILD_DIR}/fullcalendar/fullcalendar/ FCCSS = $(FC_DIR)/fullcalendar.css
FCPCSS = $(FC_DIR)/fullcalendar.print.css
@echo "building core..." FCMJS = $(FC_DIR)/fullcalendar.min.js
@$(call concat_js,${SRC_DIR},"${BUILD_DIR}/fullcalendar/fullcalendar/fullcalendar.js") JQ_DIR = $(FC_V_DIR)/jquery
@$(call concat_css,${SRC_DIR},"${BUILD_DIR}/fullcalendar/fullcalendar/fullcalendar.css") DEMOS_DIR = $(FC_V_DIR)/demos
@cat "${SRC_DIR}/common/print.css" \ FC_ZIP = $(FC_V_DIR).zip
| ${VER_SED} \ DIST = $(DIST_DIR)/$(shell basename $(FC_ZIP))
| ${DATE_SED} \
> "${BUILD_DIR}/fullcalendar/fullcalendar/fullcalendar.print.css" .PHONY: all distribute dist
all: distribute
@echo "compressing core js..." distribute: core plugins jquery demos others
@java -jar ${BUILD_DIR}/compiler.jar --warning_level VERBOSE --jscomp_off checkTypes --externs build/externs.js \
--js ${BUILD_DIR}/fullcalendar/fullcalendar/fullcalendar.js \ .PHONY: clean
> ${BUILD_DIR}/fullcalendar/fullcalendar/fullcalendar.min.js; \ clean: Makefile
rm -rf $(FC_ZIP)
@echo "building plugins..." rm -rf $(FC_V_DIR)
@for loader in ${SRC_DIR}/*/_loader.js; do \ rm -rf $(DIST_DIR)
$(FC_V_DIR): Makefile
mkdir -p $@
$(FC_DIR):
mkdir -p $@
$(DEMOS_DIR):
mkdir -p $@
$(JQ_DIR):
mkdir -p $@
$(DIST_DIR):
mkdir -p $@
$(FCJS): $(FC_DIR)
$(call concat_js,$(SRC_DIR),$@)
$(FCCSS): $(FC_DIR)
$(call concat_css,$(SRC_DIR),$@)
$(FCPCSS): $(SRC_DIR)/common/print.css $(FC_DIR)
$(VER_SED) $< | $(DATE_SED) > $@
.PHONY: core
core: $(FCJS) $(FCCSS) $(FCPCSS)
$(FCMJS): $(FCJS)
java -jar $(BUILD_DIR)/compiler.jar --warning_level VERBOSE --jscomp_off checkTypes --externs build/externs.js --js $< > $@
.PHONY: plugins
plugins: $(FCMJS) core
for loader in $(SRC_DIR)/*/_loader.js; do \
dir=`dirname $$loader`; \ dir=`dirname $$loader`; \
name=`basename $$dir`; \ name=`basename $$dir`; \
$(call concat_js,$$dir,"${BUILD_DIR}/fullcalendar/fullcalendar/$$name.js"); \ $(call concat_js,$$dir,$(FC_DIR)/$$name.js); \
done done
@echo "copying jquery..." $(JQ_DIR)/$(JQ): lib/$(JQ) $(JQ_DIR)
@mkdir -p ${BUILD_DIR}/fullcalendar/jquery cp $< $@
@cp lib/${JQ} ${BUILD_DIR}/fullcalendar/jquery
@cp lib/${JQUI} ${BUILD_DIR}/fullcalendar/jquery $(JQ_DIR)/$(JQUI): lib/$(JQUI) $(JQ_DIR)
cp $< $@
@echo "building demos..."
@mkdir -p ${BUILD_DIR}/fullcalendar/demos .PHONY: jquery
@for f in ${DEMO_FILES}; do \ jquery: $(JQ_DIR)/$(JQ) $(JQ_DIR)/$(JQUI)
cat ${DEMOS_DIR}/$$f \
| ${DEMO_SED} \ .PHONY: demos
demos: $(FC_DIR) $(DEMOS_DIR)
for f in $(DEMO_FILES); do \
cat $(DEMOS_DIR)/$$f \
| $(DEMO_SED) \
| sed "s/jquery\.js/${JQ}/" \ | sed "s/jquery\.js/${JQ}/" \
| sed "s/jquery-ui\.js/${JQUI}/" \ | sed "s/jquery-ui\.js/${JQUI}/" \
> ${BUILD_DIR}/fullcalendar/demos/$$f; \ > $(DEMOS_DIR)/$$f; \
done done
@for d in ${DEMO_SUBDIRS}; do \ for d in $(DEMO_SUBDIRS); do \
cp -r ${DEMOS_DIR}/$$d ${BUILD_DIR}/fullcalendar/demos/$$d; \ cp -r $(DEMOS_DIR)/$$d $(DEMOS_DIR)/$$d; \
done done
@echo "copying other files..."
@cp -r ${OTHER_FILES} ${BUILD_DIR}/fullcalendar
@echo "zipping..."
@mv ${BUILD_DIR}/fullcalendar ${BUILD_DIR}/fullcalendar-${VER}
@cd ${BUILD_DIR}; for f in fullcalendar-*; do \
zip -q -r $$f.zip $$f; \
done
@mv ${BUILD_DIR}/fullcalendar-${VER} ${BUILD_DIR}/fullcalendar
@mkdir -p ${DIST_DIR}
@mv ${BUILD_DIR}/fullcalendar-${VER}.zip ${DIST_DIR}
@echo "done."
clean: .PHONY: others
@rm -rf ${BUILD_DIR}/fullcalendar others: $(FC_DIR)
@rm -rf ${BUILD_DIR}/fullcalendar-* cp -r $(OTHER_FILES) $(FC_DIR)
@rm -rf ${DIST_DIR}/*
$(FC_ZIP): $(FC_V_DIR) distribute
zip -q -r $@ $<
$(DIST): $(FC_ZIP) $(DIST_DIR)
mv $@ $<