#
# This file is licensed under the terms of the GNU General Public License,
# version 2. See the file COPYING in the main directory for details.
#
#  Copyright (C) 2002,2003  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
#

CC = gcc
INSTALL = install

CFLAGS = -O2 -W -Wall
CPPFLAGS += -I../include

SOURCES = delo.c isoio.c extents.c
OBJS = $(patsubst %.S,%.o,$(patsubst %.c,%.o,$(SOURCES)))

.SUFFIXES = .c.o
.PHONY = all install clean reallyclean

all: delo

delo: $(OBJS)
	$(CC) $(CFLAGS) -o $@ $^

install: delo
	$(INSTALL) -d -m 755 /sbin
	$(INSTALL) -m 0755 delo /sbin

tags:
	ctags *.h *.c

clean:
	-rm -f $(OBJS) $(OBJS:.o=.d) delo core tags *~

reallyclean: clean

# Dependency handling
%.d: %.c
	@set -e; $(CC) -MM $(CPPFLAGS) $< \
	| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	[ -s $@ ] || rm -f $@

%.d: %.S
	@set -e; $(CC) -MM $(CPPFLAGS) $< \
	| sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
	[ -s $@ ] || rm -f $@

ifneq ($(MAKECMDGOALS),clean)
-include $(OBJS:.o=.d)
endif
