# $Id$ PREFIX := /usr/local MODULE_PREFIX := $(PREFIX)/lib/mandshurica/module WEBROOT_PREFIX := $(PREFIX)/lib/mandshurica/webroot PROJECT_PREFIX := $(PREFIX)/lib/mandshurica/project TOOL_PREFIX := $(PREFIX)/lib/mandshurica/tool DATABASE_PREFIX := $(PREFIX)/lib/mandshurica/db .PHONY: all clean format replace ./Mandshurica ./Module ./Tool all: ./config.mk ./Mandshurica ./Module ./Tool ./CTool ./config.mk: echo "PREFIX := $(PREFIX)" > $@ echo "MODULE_PREFIX := $(MODULE_PREFIX)" >> $@ echo "WEBROOT_PREFIX := $(WEBROOT_PREFIX)" >> $@ echo "PROJECT_PREFIX := $(PROJECT_PREFIX)" >> $@ echo "TOOL_PREFIX := $(TOOL_PREFIX)" >> $@ echo "DATABASE_PREFIX := $(DATABASE_PREFIX)" >> $@ include config.mk PREFIXES := PREFIX="$(PREFIX)" MODULE_PREFIX="$(MODULE_PREFIX)" PROJECT_PREFIX="$(PROJECT_PREFIX)" TOOL_PREFIX="$(TOOL_PREFIX)" WEBROOT_PREFIX="$(WEBROOT_PREFIX)" CC := gcc CFLAGS := -g -std=c99 -DPREFIX=\\\"$(PREFIX)\\\" -DWEBROOT_PREFIX=\\\"$(WEBROOT_PREFIX)\\\" -DMODULE_PREFIX=\\\"$(MODULE_PREFIX)\\\" -DPROJECT_PREFIX=\\\"$(PROJECT_PREFIX)\\\" -DTOOL_PREFIX=\\\"$(TOOL_PREFIX)\\\" -DDATABASE_PREFIX=\\\"$(DATABASE_PREFIX)\\\" -D_DEFAULT_SOURCE LDFLAGS := LIBS := ./Mandshurica:: $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" ./Module:: $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" ./Tool:: $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" ./CTool:: $(MAKE) -C $@ CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" format: clang-format -i $(wildcard Module/*.c Module/*.h Mandshurica/*.c Mandshurica/*.h) replace: for i in $(wildcard Module/*.c Module/*.h Mandshurica/*.c Mandshurica/*.h); do \ echo -n $$i"... "; \ cat $$i | perl replace.pl > $$i.new; \ mv $$i.new $$i; \ echo done; \ done install: all mkdir -p $(PREFIX) $(MODULE_PREFIX) $(DATABASE_PREFIX) $(WEBROOT_PREFIX) $(PROJECT_PREFIX) $(TOOL_PREFIX) $(PREFIX)/etc $(PREFIX)/bin $(PREFIX)/lib/mandshurica/db touch $(PREFIX)/lib/mandshurica/db/auth.db $(PREFIX)/lib/mandshurica/db/login.db $(PREFIX)/lib/mandshurica/db/project.db if [ -e $(PREFIX)/etc/mandshurica.conf ]; then \ while true; do\ read -p "Overwrite the config with default one? " "yn";\ if [ "$$yn" = "y" -o "$$yn" = "Y" ]; then\ ./Mandshurica/mandshurica --create $(PREFIX)/etc/mandshurica.conf;\ break;\ elif [ "$$yn" = "n" -o "$$yn" = "N" ]; then\ break;\ else\ echo "Please enter Y or N";\ fi;\ done;\ else\ ./Mandshurica/mandshurica --create $(PREFIX)/etc/mandshurica.conf;\ fi $(MAKE) -C ./Mandshurica install $(PREFIXES) $(MAKE) -C ./Module install $(PREFIXES) $(MAKE) -C ./Tool install $(PREFIXES) $(MAKE) -C ./Webroot install $(PREFIXES) $(MAKE) -C ./CTool install $(PREFIXES) @echo "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*" @echo "Mandshurica executable has been installed to $(PREFIX)/bin" @echo "mkpasswd has been installed to $(PREFIX)/bin" @echo "Authentication database is at $(PREFIX)/lib/mandshurica/db/auth.db" @echo @echo "Thank you for choosing Mandshurica" @echo "-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*" clean: $(MAKE) -C ./Mandshurica clean $(MAKE) -C ./Module clean $(MAKE) -C ./Tool clean $(MAKE) -C ./CTool clean rm -f ./config.mk