Tags:
create new tag
view all tags
CategoryStale DeleteMe

-- KenEstes - 04 Oct 2001


# the directory where non cgi files will be installed
PREFIX=/home/httpd/twiki

# the directory where cgi files will be installed
CGI_PREFIX=$(PREFIX)

# the directory where html files will be installed
HTML_PREFIX=$(PREFIX)

DATA_PREFIX=$(PREFIX)/data
LIB_PREFIX=$(PREFIX)/lib
TEMPLATES_PREFIX=$(PREFIX)/templates
BIN_PREFIX=$(CGI_PREFIX)/bin
PUB_PREFIX=$(HTML_PREFIX)/pub

# build directory, used as a temporary staging area
BUILD=./build

# where to find build tools on the build machine
PERL=/usr/bin/perl
MKDIR=mkdir
CP=cp


# where perl is located on the target machine
TARGET_PERL=$(PERL)

# The extension which cgi files must have. Typically this is:
# .cgi, .pl, or the empty string

EXT=

# file owners for installed files
# these are used only if the target owners is run.

CGI_USER=nobody
CGI_USER=nobody
FILE_OWNER=root
FILE_GROUP=twiky

#-------------------------------------------------------------
# Users should not need to configure anything below this line
#-------------------------------------------------------------

# The basic targets

# Remember that when people make rpms they set the PREFIX differently
# during 'make all' then 'make install'.  The prefix for installation
# is where to put the files for packaging and this is not the same as
# where the files will be installed on the target system.  The prefix
# in the compilation step represents where the files will be installed
# on the target system so that this data can be hard coded by
# applications.

all: build

build: all_build_files

install: all_install_files dir_permissions

owners: install
groups: install

# ------------------------------------
# Variables derived from file searches
# ------------------------------------


BIN_FILES = $(shell find ./bin -type f)
LIB_FILES = $(shell find ./lib -type f)
DATA_FILES = $(shell find ./data -type f)
PUB_FILES = $(shell find ./pub -type f)
TEMPLATES_FILES = $(shell find ./templates -type f)

BIN_BUILD_FILES = $(patsubst ./%,$(BUILD)/%$(EXT),$(BIN_FILES))
LIB_BUILD_FILES = $(patsubst ./%,$(BUILD)/%,$(LIB_FILES))
DATA_BUILD_FILES = $(patsubst ./%,$(BUILD)/%,$(DATA_FILES))
PUB_BUILD_FILES = $(patsubst ./%,$(BUILD)/%,$(PUB_FILES))
TEMPLATES_BUILD_FILES = $(patsubst ./%,$(BUILD)/%,$(TEMPLATES_FILES))

ALL_BUILD_FILES = $(BIN_BUILD_FILES) $(LIB_BUILD_FILES) $(DATA_BUILD_FILES) $(PUB_BUILD_FILES) $(TEMPLATES_BUILD_FILES)
all_build_files: $(ALL_BUILD_FILES)


BIN_INSTALL_FILES = $(patsubst ./bin/%,$(BIN_PREFIX)/%$(EXT),$(BIN_FILES))
LIB_INSTALL_FILES = $(patsubst ./lib/%,$(LIB_PREFIX)/%,$(LIB_FILES))
DATA_INSTALL_FILES = $(patsubst ./data/%,$(DATA_PREFIX)/%,$(DATA_FILES))
PUB_INSTALL_FILES = $(patsubst ./pub/%,$(PUB_PREFIX)/%,$(PUB_FILES))
TEMPLATES_INSTALL_FILES = $(patsubst ./templates/%,$(TEMPLATES_PREFIX)/%,$(TEMPLATES_FILES))

ALL_INSTALL_FILES = $(BIN_INSTALL_FILES) $(LIB_INSTALL_FILES) $(DATA_INSTALL_FILES) $(PUB_INSTALL_FILES) $(TEMPLATES_INSTALL_FILES)
all_install_files: $(ALL_INSTALL_FILES)


debug: 
   @ echo BIN_FILES $(BIN_FILES) 
   @ echo
   @ echo LIB_FILES $(LIB_FILES) 
   @ echo
   @ echo DATA_FILES $(DATA_FILES) 
   @ echo
   @ echo PUB_FILES $(PUB_FILES) 
   @ echo
   @ echo TEMPLATES_FILES $(TEMPLATES_FILES) 
   @ echo
   @ echo ALL_BUILD_FILES $(ALL_BUILD_FILES) 
   @ echo
   @ echo ALL_INSTALL_FILES $(ALL_INSTALL_FILES) 
   @ echo

# change source files to reflect the resources on the target machine.

BIN_SUBSTITUTE= $(PERL) -pi   -e "s!/usr/bin/perl!$(TARGET_PERL)!;" \
         -e "s!use lib \( \'\.' \);!use lib \( \'$(LIB_PREFIX)\' \);!;" \
         -e "s!use lib \( \'\.\./lib\' \);\n!!;"

# In a target rule ensure that the dirname of the target file exists.

CHECK_DIR= DIR=$(dir $@); [ -d $$DIR ] || $(MKDIR) -p $$DIR;

# If the file is a ,v file change the line which tells who the owner
# of the lock file is to match the user name who will run the
# cgi-bin's.

CHOWN_LOCKS_IN_RCS_FILES= echo $@ | egrep ',v$$'; \
   if [ $$? -eq 0 ]; then \
   $(PERL) -pi   -e 's!^\tnobody:!\t$(CGI_USER):!;' $@ ; \
   fi

# ---------------------------------------------

# pattern rules for the 'building' of a release from sources.

# Perform all subsitutions on the text files and create a directory
# hierarchy suitable for installation.


# While copying the bin directory, perform substituions and add file
# name extensions as needed. After copying chmod files to the propper permissions.

$(BUILD)/bin/%$(EXT) : ./bin/%
   $(CHECK_DIR)
   $(CP) $< $@
   $(BIN_SUBSTITUTE) $@
   chmod 755 $@

# Other directories are just copied as is, not substitutions and no
# extensions. After copying chmod files to the propper permissions.

$(BUILD)/lib/% : ./lib/%
   $(CHECK_DIR)
   $(CP) $< $@
   chmod 444 $@

$(BUILD)/data/% : ./data/%
   $(CHECK_DIR)
   $(CP) $< $@
   $(CHOWN_LOCKS_IN_RCS_FILES)
   chmod 664 $@

$(BUILD)/pub/% : ./pub/%
   $(CHECK_DIR)
   $(CP) $< $@
   chmod 664 $@

$(BUILD)/templates/% : ./templates/%
   $(CHECK_DIR)
   $(CP) $< $@
   chmod 444 $@

# ----------------------------

# pattern rules for installation

$(BIN_PREFIX)/% : $(BUILD)/bin/%
   $(CHECK_DIR)
   $(CP) -p $< $@

$(LIB_PREFIX)/% : $(BUILD)/lib/%
   $(CHECK_DIR)
   $(CP) -p $< $@ 

$(DATA_PREFIX)/% : $(BUILD)/data/%
   $(CHECK_DIR)
   $(CP) -p $< $@

$(PUB_PREFIX)/% : $(BUILD)/pub/%
   $(CHECK_DIR)
   $(CP) -p $< $@

$(TEMPLATES_PREFIX)/% : $(BUILD)/templates/%
   $(CHECK_DIR)
   $(CP) -p $< $@


# ---------------------------------

# Set the permissions on the installation directories

dir_permissions:
   find $(BIN_PREFIX) -type d      | xargs chmod 755 
   find $(LIB_PREFIX) -type d      | xargs chmod 755 
   find $(TEMPLATES_PREFIX) -type d   | xargs chmod 755 
   find $(DATA_PREFIX) -type d      | xargs chmod 775 
   find $(PUB_PREFIX) -type d      | xargs chmod 775 

# Set the owner on the installation directories

# If the installer does not have root access then this step may not be
# run.  We do not require it for 'make all' or 'make install' (these
# are traditional commands used to build RPM's and RPM has other
# mechanisms to set the owner of files inside the packages it creates)
# but provide it as a convienence for those who need it.

owners: install
   find $(BIN_PREFIX) -type f      | xargs chown $(FILE_OWNER)
   find $(BIN_PREFIX) -type d      | xargs chown $(FILE_OWNER)
   find $(LIB_PREFIX) -type f      | xargs chown $(FILE_OWNER)
   find $(LIB_PREFIX) -type d      | xargs chown $(FILE_OWNER)
   find $(TEMPLATES_PREFIX) -type f   | xargs chown $(FILE_OWNER)
   find $(TEMPLATES_PREFIX) -type d   | xargs chown $(FILE_OWNER)
   #
   find $(DATA_PREFIX) -type f      | xargs chown $(CGI_USER_OWNER)
   find $(DATA_PREFIX) -type d      | xargs chown $(CGI_USER_OWNER)
   find $(PUB_PREFIX) -type f      | xargs chown $(CGI_USER_OWNER)
   find $(PUB_PREFIX) -type d      | xargs chown $(CGI_USER_OWNER)


groups: install
   find $(BIN_PREFIX) -type f      | xargs chgrp $(FILE_GROUP)
   find $(BIN_PREFIX) -type d      | xargs chgrp $(FILE_GROUP)
   find $(LIB_PREFIX) -type f      | xargs chgrp $(FILE_GROUP)
   find $(LIB_PREFIX) -type d      | xargs chgrp $(FILE_GROUP)
   find $(TEMPLATES_PREFIX) -type f   | xargs chgrp $(FILE_GROUP)
   find $(TEMPLATES_PREFIX) -type d   | xargs chgrp $(FILE_GROUP)
   #
   find $(DATA_PREFIX) -type f      | xargs chgrp $(CGI_USER_GROUP)
   find $(DATA_PREFIX) -type d      | xargs chgrp $(CGI_USER_GROUP)
   find $(PUB_PREFIX) -type f      | xargs chgrp $(CGI_USER_GROUP)
   find $(PUB_PREFIX) -type d      | xargs chgrp $(CGI_USER_GROUP)


How about splitting this up at the "Users should not need to configure anything below this line" line?
The second part could be reused for a TWikiUnderCygwin installation. The information from the first part is usually asked via some dialog, not entered with a text editor. (Mostly a cultural difference, but it will be a barrier for the typical Windows user.)

-- JoachimDurchholz - 05 Oct 2001

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2006-03-09 - CrawfordCurrie
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.