Skip to content

Commit

Permalink
Makefile: only generate resource headers if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
cgzones committed Nov 15, 2019
1 parent 9b9fb33 commit c07f543
Showing 1 changed file with 30 additions and 38 deletions.
68 changes: 30 additions & 38 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ noinst_PROGRAMS = bin2c
bin2c_SOURCES = src/bin2c.c

BUILT_SOURCES = \
tpls.h \
bootstrapcss.h \
facss.h \
appcss.h \
d3js.h \
hoganjs.h \
chartsjs.h \
appjs.h
src/tpls.h \
src/bootstrapcss.h \
src/facss.h \
src/appcss.h \
src/d3js.h \
src/hoganjs.h \
src/chartsjs.h \
src/appjs.h

CLEANFILES = \
src/tpls.h \
Expand All @@ -44,74 +44,66 @@ CLEANFILES = \
resources/js/app.js.tmp

# Tpls
tpls.h: bin2c$(EXEEXT) $(srcdir)/resources/tpls.html
src/tpls.h: bin2c$(EXEEXT) $(srcdir)/resources/tpls.html
if HAS_SEDTR
mkdir -p resources
cat $(srcdir)/resources/tpls.html | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/tpls.html.tmp
./bin2c resources/tpls.html.tmp src/tpls.h tpls
else
./bin2c $(srcdir)/resources/tpls.html src/tpls.h tpls
endif
# Bootstrap
bootstrapcss.h: bin2c$(EXEEXT) $(srcdir)/resources/css/bootstrap.min.css
src/bootstrapcss.h: bin2c$(EXEEXT) $(srcdir)/resources/css/bootstrap.min.css
if HAS_SEDTR
mkdir -p resources/css
cat $(srcdir)/resources/css/bootstrap.min.css | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/css/bootstrap.min.css.tmp
./bin2c resources/css/bootstrap.min.css.tmp src/bootstrapcss.h bootstrap_css
cat $(srcdir)/resources/css/bootstrap.min.css | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/css/bootstrap.min.css.tmp
./bin2c $(srcdir)/resources/css/bootstrap.min.css.tmp src/bootstrapcss.h bootstrap_css
else
./bin2c $(srcdir)/resources/css/bootstrap.min.css src/bootstrapcss.h bootstrap_css
endif
# Font Awesome
facss.h: bin2c$(EXEEXT) $(srcdir)/resources/css/fa.min.css
src/facss.h: bin2c$(EXEEXT) $(srcdir)/resources/css/fa.min.css
if HAS_SEDTR
mkdir -p resources/css
cat $(srcdir)/resources/css/fa.min.css | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/css/fa.min.css.tmp
./bin2c resources/css/fa.min.css.tmp src/facss.h fa_css
cat $(srcdir)/resources/css/fa.min.css | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/css/fa.min.css.tmp
./bin2c $(srcdir)/resources/css/fa.min.css.tmp src/facss.h fa_css
else
./bin2c $(srcdir)/resources/css/fa.min.css src/facss.h fa_css
endif
# App.css
appcss.h: bin2c$(EXEEXT) $(srcdir)/resources/css/app.css
src/appcss.h: bin2c$(EXEEXT) $(srcdir)/resources/css/app.css
if HAS_SEDTR
mkdir -p resources/css
cat $(srcdir)/resources/css/app.css | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/css/app.css.tmp
./bin2c resources/css/app.css.tmp src/appcss.h app_css
cat $(srcdir)/resources/css/app.css | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/css/app.css.tmp
./bin2c $(srcdir)/resources/css/app.css.tmp src/appcss.h app_css
else
./bin2c $(srcdir)/resources/css/app.css src/appcss.h app_css
endif
# D3.js
d3js.h: bin2c$(EXEEXT) $(srcdir)/resources/js/d3.v3.min.js
src/d3js.h: bin2c$(EXEEXT) $(srcdir)/resources/js/d3.v3.min.js
if HAS_SEDTR
mkdir -p resources/js
cat $(srcdir)/resources/js/d3.v3.min.js | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/js/d3.v3.min.js.tmp
./bin2c resources/js/d3.v3.min.js.tmp src/d3js.h d3_js
cat $(srcdir)/resources/js/d3.v3.min.js | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/js/d3.v3.min.js.tmp
./bin2c $(srcdir)/resources/js/d3.v3.min.js.tmp src/d3js.h d3_js
else
./bin2c $(srcdir)/resources/js/d3.v3.min.js src/d3js.h d3_js
endif
# Hogan.js
hoganjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/hogan.min.js
src/hoganjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/hogan.min.js
if HAS_SEDTR
mkdir -p resources/js
cat $(srcdir)/resources/js/hogan.min.js | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/js/hogan.min.js.tmp
./bin2c resources/js/hogan.min.js.tmp src/hoganjs.h hogan_js
cat $(srcdir)/resources/js/hogan.min.js | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/js/hogan.min.js.tmp
./bin2c $(srcdir)/resources/js/hogan.min.js.tmp src/hoganjs.h hogan_js
else
./bin2c $(srcdir)/resources/js/hogan.min.js src/hoganjs.h hogan_js
endif
# Charts.js
chartsjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/charts.js
src/chartsjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/charts.js
if HAS_SEDTR
mkdir -p resources/js
cat $(srcdir)/resources/js/charts.js | sed -E "s@(,|;)[[:space:]]*//..*@\1@g" | sed -E "s@^[[:space:]]*//..*@@g" | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/js/charts.js.tmp
./bin2c resources/js/charts.js.tmp src/chartsjs.h charts_js
cat $(srcdir)/resources/js/charts.js | sed -E "s@(,|;)[[:space:]]*//..*@\1@g" | sed -E "s@^[[:space:]]*//..*@@g" | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/js/charts.js.tmp
./bin2c $(srcdir)/resources/js/charts.js.tmp src/chartsjs.h charts_js
else
./bin2c $(srcdir)/resources/js/charts.js src/chartsjs.h charts_js
endif
# App.js
appjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/app.js
src/appjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/app.js
if HAS_SEDTR
mkdir -p resources/js
cat $(srcdir)/resources/js/app.js | sed -E "s@(,|;)[[:space:]]*//..*@\1@g" | sed -E "s@^[[:space:]]*//..*@@g" | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > resources/js/app.js.tmp
./bin2c resources/js/app.js.tmp src/appjs.h app_js
cat $(srcdir)/resources/js/app.js | sed -E "s@(,|;)[[:space:]]*//..*@\1@g" | sed -E "s@^[[:space:]]*//..*@@g" | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/js/app.js.tmp
./bin2c $(srcdir)/resources/js/app.js.tmp src/appjs.h app_js
else
./bin2c $(srcdir)/resources/js/app.js src/appjs.h app_js
endif
Expand Down

0 comments on commit c07f543

Please sign in to comment.