SUBDIRS := $(patsubst %/, %, $(filter %/, $(shell ls -F)))

SUBDIRMARKS := $(patsubst %, _dir_%, $(SUBDIRS))

all : $(patsubst %.php, %.phps, $(wildcard *.php)) \
      $(patsubst %.php, %.html, $(wildcard *.php)) \
      $(patsubst %.inc, %.inc.phps, $(wildcard *.inc)) \
      $(SUBDIRMARKS)

# Create symbolic links to all *.php and *.inc files

%.phps : %.php
	ln -s $< $@

%.inc.phps : %.inc
	ln -s $< $@

# Compile static html from php

%.html : %.php
	echo "<?php set_include_path('.:/home/odonnell/html/Include'); ?>" | cat - $< | php > $@

# Make subdirectories recursively

.PHONY : $(SUBDIRMARKS)

.PHONY : makesubdirs

$(SUBDIRMARKS) : makesubdirs
	-$(MAKE) -C $(patsubst _dir_%, %, $@)
