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

View File

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

View File

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