Makefile update.

- kanband is now Makefile-produced.
  - Improved dependency handling for client-related files (ls, css).
master
Luka Vandervelden 2019-07-07 11:50:32 +02:00
parent 8b5e0a0c02
commit 802812e99f
3 changed files with 67 additions and 39 deletions

View File

@ -16,35 +16,53 @@ LDFLAGS :=
Q := @ Q := @
all: public/main.js public/style.css all: kanband main.js style.css
@: @:
public/main.js: public/main.bundle.js public kanband: src/main.cr
@echo ' MIN > public/main.js' @echo ' CR > kanband'
$(Q)npx babel --minified public/main.bundle.js -o public/main.js $(Q)crystal src/main.cr -o 'kanband'
public/main.bundle.js: client/index.ls public kanband.install: kanband
@echo ' BUN > public/main.bundle.js' @echo ' IN > $(BINDIR)/kanband'
$(Q)npx browserify -t browserify-livescript client/index.ls -o public/main.bundle.js $(Q)mkdir -p '$(DESTDIR)$(BINDIR)'
$(Q)install -m0755 kanband $(DESTDIR)$(BINDIR)/kanband
kanband.clean:
@echo ' RM > kanband'
$(Q)rm -f kanband
kanband.uninstall:
@echo ' RM > $(BINDIR)/kanband'
$(Q)rm -f '$(DESTDIR)$(BINDIR)/kanband'
main.js: main.bundle.js
@echo ' MIN > main.js'
$(Q)npx babel --minified main.bundle.js -o main.js
public/main.js.clean: main.bundle.js: client/index.ls client/bulma.ls
@echo ' RM > public/main.js' @echo ' BUN > main.bundle.js'
$(Q)rm -f public/main.js $(Q)npx browserify -t browserify-livescript client/index.ls -o main.bundle.js
@echo ' RM > public/main.bundle.js'
$(Q)rm -f public/main.bundle.js
public/style.css: client/style.sass public main.js.clean:
@echo ' CSS > public/style.css' @echo ' RM > main.js'
$(Q)sassc client/style.sass > public/style.css $(Q)rm -f main.js
@echo ' RM > main.bundle.js'
$(Q)rm -f main.bundle.js
public/style.css.clean: style.css: client/style.sass
@echo ' CSS > style.css'
$(Q)sassc client/style.sass > style.css
style.css.clean:
@echo ' RM > style.css'
$(Q)rm -f style.css
public:
$(Q)mkdir -p public
$(DESTDIR)$(PREFIX): $(DESTDIR)$(PREFIX):
@echo ' DIR > $(PREFIX)' @echo ' DIR > $(PREFIX)'
$(Q)mkdir -p $(DESTDIR)$(PREFIX) $(Q)mkdir -p $(DESTDIR)$(PREFIX)
@ -63,12 +81,12 @@ $(DESTDIR)$(INCLUDEDIR):
$(DESTDIR)$(MANDIR): $(DESTDIR)$(MANDIR):
@echo ' DIR > $(MANDIR)' @echo ' DIR > $(MANDIR)'
$(Q)mkdir -p $(DESTDIR)$(MANDIR) $(Q)mkdir -p $(DESTDIR)$(MANDIR)
install: subdirs.install public/main.js.install public/style.css.install install: subdirs.install kanband.install main.js.install style.css.install
@: @:
subdirs.install: subdirs.install:
uninstall: subdirs.uninstall public/main.js.uninstall public/style.css.uninstall uninstall: subdirs.uninstall kanband.uninstall main.js.uninstall style.css.uninstall
@: @:
subdirs.uninstall: subdirs.uninstall:
@ -78,7 +96,7 @@ test: all subdirs subdirs.test
subdirs.test: subdirs.test:
clean: public/main.js.clean public/style.css.clean clean: kanband.clean main.js.clean style.css.clean
distclean: clean distclean: clean
@ -93,22 +111,28 @@ dist-gz: $(PACKAGE)-$(VERSION).tar.gz
$(PACKAGE)-$(VERSION).tar.gz: distdir $(PACKAGE)-$(VERSION).tar.gz: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.gz' @echo ' TAR > $(PACKAGE)-$(VERSION).tar.gz'
$(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \ $(Q)tar czf $(PACKAGE)-$(VERSION).tar.gz \
$(PACKAGE)-$(VERSION)/src/main.cr \
$(PACKAGE)-$(VERSION)/client/index.ls \ $(PACKAGE)-$(VERSION)/client/index.ls \
$(PACKAGE)-$(VERSION)/client/style.sass $(PACKAGE)-$(VERSION)/client/style.sass \
$(PACKAGE)-$(VERSION)/client/bulma.ls
dist-xz: $(PACKAGE)-$(VERSION).tar.xz dist-xz: $(PACKAGE)-$(VERSION).tar.xz
$(PACKAGE)-$(VERSION).tar.xz: distdir $(PACKAGE)-$(VERSION).tar.xz: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.xz' @echo ' TAR > $(PACKAGE)-$(VERSION).tar.xz'
$(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \ $(Q)tar cJf $(PACKAGE)-$(VERSION).tar.xz \
$(PACKAGE)-$(VERSION)/src/main.cr \
$(PACKAGE)-$(VERSION)/client/index.ls \ $(PACKAGE)-$(VERSION)/client/index.ls \
$(PACKAGE)-$(VERSION)/client/style.sass $(PACKAGE)-$(VERSION)/client/style.sass \
$(PACKAGE)-$(VERSION)/client/bulma.ls
dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2 dist-bz2: $(PACKAGE)-$(VERSION).tar.bz2
$(PACKAGE)-$(VERSION).tar.bz2: distdir $(PACKAGE)-$(VERSION).tar.bz2: distdir
@echo ' TAR > $(PACKAGE)-$(VERSION).tar.bz2' @echo ' TAR > $(PACKAGE)-$(VERSION).tar.bz2'
$(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \ $(Q)tar cjf $(PACKAGE)-$(VERSION).tar.bz2 \
$(PACKAGE)-$(VERSION)/src/main.cr \
$(PACKAGE)-$(VERSION)/client/index.ls \ $(PACKAGE)-$(VERSION)/client/index.ls \
$(PACKAGE)-$(VERSION)/client/style.sass $(PACKAGE)-$(VERSION)/client/style.sass \
$(PACKAGE)-$(VERSION)/client/bulma.ls
help: help:
@echo ' :: kanban-0.1' @echo ' :: kanban-0.1'
@ -134,8 +158,9 @@ help:
@echo ' - MANDIR  ${MANDIR}' @echo ' - MANDIR  ${MANDIR}'
@echo '' @echo ''
@echo 'Project targets: ' @echo 'Project targets: '
@echo ' - public/main.js livescript' @echo ' - kanband  crystal'
@echo ' - public/style.css css' @echo ' - main.js  livescript'
@echo ' - style.css  css'
@echo '' @echo ''
@echo 'Makefile options:' @echo 'Makefile options:'
@echo ' - gnu: false' @echo ' - gnu: false'

View File

@ -4,9 +4,9 @@
<title>Kanban</title> <title>Kanban</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/> <meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta charset="utf-8"/> <meta charset="utf-8"/>
<link rel="stylesheet" href="public/style.css"/> <link rel="stylesheet" href="/style.css"/>
</head> </head>
<body> <body>
<script src="public/main.js"></script> <script src="/main.js"></script>
</body> </body>
</html> </html>

View File

@ -2,16 +2,19 @@
package=kanban package=kanban
version=0.1 version=0.1
targets=() targets=(kanband)
type[kanband]=crystal
sources[kanband]=src/main.cr
depends[kanband]="$(ls src/*.cr | grep -v '/main.cr$')"
targets+=(public/main.js) targets+=(main.js)
type[public/main.js]=livescript type[main.js]=livescript
sources[public/main.js]=client/index.ls sources[main.js]=client/index.ls
depends[public/main.js]="$(ls client/*.ls | grep -v /index.ls$ | tr '\n' ' ')" depends[main.js]="$(ls client/*.ls | grep -v /index.ls$ | tr '\n' ' ')"
targets+=(public/style.css) targets+=(style.css)
type[public/style.css]=css type[style.css]=css
sources[public/style.css]=client/style.sass sources[style.css]=client/style.sass
# #
# implementation details below, bruh~ # implementation details below, bruh~
@ -36,12 +39,12 @@ function CSS {
} }
function livescript.build { function livescript.build {
write "${target}: ${target%.js}.bundle.js $(dirname $target)" write "${target}: ${target%.js}.bundle.js $(dirdep $target)"
write "\t@echo '$(MIN ${target%.js}.js)'" write "\t@echo '$(MIN ${target%.js}.js)'"
write "\t${Q}npx babel --minified ${target%.js}.bundle.js -o ${target}" write "\t${Q}npx babel --minified ${target%.js}.bundle.js -o ${target}"
write "\n" write "\n"
write "${target%.js}.bundle.js: ${sources[$target]} ${depends[$target]} $(dirname $target)" write "${target%.js}.bundle.js: ${sources[$target]} ${depends[$target]} $(dirdep $target)"
write "\t@echo '$(BUN ${target%.js}.bundle.js)'" write "\t@echo '$(BUN ${target%.js}.bundle.js)'"
write "\t${Q}npx browserify -t browserify-livescript ${sources[$target]} -o ${target%.js}.bundle.js" write "\t${Q}npx browserify -t browserify-livescript ${sources[$target]} -o ${target%.js}.bundle.js"
write "\n" write "\n"
@ -65,7 +68,7 @@ function livescript.uninstall {
} }
function css.build { function css.build {
write "${target}: ${sources[$target]} $(dirname $target)" write "${target}: ${sources[$target]} $(dirdep $target)"
write "\t@echo '$(CSS ${target})'" write "\t@echo '$(CSS ${target})'"
write "\t${Q}sassc ${sources[$target]} > ${target}" write "\t${Q}sassc ${sources[$target]} > ${target}"
write "\n" write "\n"