# Makefile # $Id: Makefile,v 1.9 2003/02/07 08:21:20 andy Exp $ # Rules to compile and install install-log. # Copyright (C) 2002 Andy Goth # For more information visit http://ioioio.net/devel/install-log/ # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place - Suite 330, Boston, MA 02111-1307, USA. # The basics EXE := install-log SRC := main.c config.c globals.c list.c find.c timestamp.c util.c database.c SRC += editor.c configure.c OBJ := $(patsubst %.c,%.o,$(filter %.c,$(SRC))) DEP := $(patsubst %.c,%.d,$(filter %.c,$(SRC))) GEN := core $(EXE) $(OBJ) $(DEP) install-log.1 install-log.rc configure.h\ configure.mk configure.c configure.log all: $(EXE) # Remove generated files from source tree clean: -rm -f $(GEN) # Tell make about special (non-file) targets .PHONY: all clean install # The below is only necessary for compilation ifneq ($(filter-out clean,$(if $(MAKECMDGOALS),$(MAKECMDGOALS),all)),) # Ensure that configure has been run ifeq ($(wildcard configure.mk),) $(warning Running configure with defaults. Check configure.log.) $(shell ./configure -q) endif # Load user options and dependency files -include configure.mk $(DEP) # Generate dependency and object files %.o %.d: %.c $(CC) $(CFLAGS) -MMD -c -o $(patsubst %.d,%.o,$@) $< # Link the program $(EXE): $(OBJ) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) # Only screw with the timestamp if LOGSELF is on TIMESTAMP := $(if $(LOGSELF),$(LOGDIR)/.timestamp) # Install install-log install: /etc/install-log.rc $(BINDIR)/$(EXE) $(MANDIR)/install-log.1\ $(if $(LOGSELF),$(LOGDIR)/install-log) # Install the binary $(BINDIR)/$(EXE): $(EXE) $(TIMESTAMP) install -m 755 $< $@ # Install the configuration file /etc/install-log.rc: install-log.rc install -m 644 $< $@ # Install the man page $(MANDIR)/install-log.1: install-log.1 $(MANDIR) $(TIMESTAMP) install -m 644 $< $@ # Create the man page installation directory $(MANDIR): mkdir -p $(MANDIR) # Create the log directory $(LOGDIR): mkdir $@ # Initialize the timestamp $(LOGDIR)/.timestamp: $(LOGDIR) touch $@ @sleep 2 touch install-log install-log.1 # Create the log of install-log's own installation $(LOGDIR)/install-log: $(LOGDIR)/.timestamp /etc/install-log.rc\ $(BINDIR)/$(EXE) @echo -e "\e[5m***\e[0m Running install-log to test itself..." @echo "$(BINDIR)/install-log and $(MANDIR)/install-log.1 should be" @echo "the only files listed after the install-log invocation below:" $(BINDIR)/install-log install-log -f -e -Ecat endif # EOF