# $Id: Makefile,v 1.13 2002/01/18 13:47:24 zw Exp $

USER = zhaoway

# Argh, this file is confidential!
PASS = s3x!SfUn
SITE = ftp.zhaoway.com

SCAN = $(shell echo *.scan)
HTML = $(patsubst %.scan,%.html,$(SCAN))

# If you have images around, you should adjust the below.
SOURCES = $(shell echo *.css *.js)

# The use of `:=' below is critical! Read your Make Manual!
UPLOADS := $(SOURCES)
UPLOADS += $(HTML)
SOURCES += $(SCAN)

TARGETS = $(patsubst %,%.upload,$(UPLOADS))

none:
	@echo we are doomed. gimme a target.

upload: check $(TARGETS)

scan: scan.l
	$(LEX) -oscan.c $<
	$(CC) -Wall -o $@ scan.c -lfl

html: $(HTML)

# We use RCS because CVS is too strong for personal homepage use. So
# if files are synchronized with RCS repository, they should have the
# permission mode -r-------- as listed by ls.
check: $(SOURCES)
	@test -z "`/bin/ls -l $^|awk '{print $$1}'|grep w`" 					\
		|| (echo -n "Error: "; 								\
		echo -n "`/bin/ls -l $^|awk '{print $$1" "$$9}'|grep w|awk '{print $$2}'` "; 	\
		echo "is not synchronized with the repository. Stop."; false)

# Cautions, this will print your password on the screen. DON'T LET
# OTHERS WATCH YOU ON YOUR BACK!! ;-)
%.upload: %
	lftp -c "open -u \"$(USER),$(PASS)\" $(SITE); put $<"
	touch $@

%.html: %.scan scan
	./scan < $< > $@

.PHONY: upload check none html
