# Makefile -- Makefile for util-etc 2.0 Linux utilities
# Created: Sat Dec 26 20:09:40 1992
# Revised: Sun Oct 10 17:58:57 1993 by faith@cs.unc.edu
# Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu)
#

CC=        gcc
CFLAGS=    -pipe -O6 -m486 -I.
LDFLAGS=   -s -N

MAN8= agetty.8 clock.8 ctrlaltdel.8 dmesg.8 doshell.8 fastboot.8 fasthalt.8 \
fdformat.8 fdisk.8 frag.8 fsck.8 fsck.minix.8 halt.8 ipcrm.8 ipcs.8 \
kbdrate.8 makehole.8 mkfs.8 mkfs.minix.8 mkswap.8 ramsize.8 rdev.8 reboot.8 \
rootflags.8 setfdprm.8 setserial.8 shutdown.8 simpleinit.8 swapdev.8 sync.8 \
update.8 vidmode.8

ETC= agetty clock ctrlaltdel dmesg doshell fdformat fdisk frag fsck \
	fsck.minix ipcrm ipcs kbdrate makehole mkfs.minix mkswap rdev \
	setfdprm setserial shutdown simpleinit sync update

ETC_FILES= fdprm

SUBDIRS=   syslogd mount

all: $(ETC) $(SPECIAL)
	@@for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "Running make in $$i..."; \
	$(MAKE)); \
	done

%.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@

$(ETC):
	$(CC) $(LDFLAGS) $^ -o $@

agetty: agetty.o
clock: clock.o
ctrlaltdel: ctrlaltdel.o
doshell: doshell.o
fdformat: fdformat.o
fdisk: fdisk.o
frag: frag.o
fsck.minix: fsck.minix.o
kbdrate: kbdrate.o
makehole: makehole.o
mkfs.minix: mkfs.minix.o
mkswap: mkswap.o
rdev: rdev.o
setfdprm: setfdprm.o
setroot: setroot.o
setserial: setserial.o
shutdown: shutdown.o
simpleinit: simpleinit.o
sync: sync.o
update: update.o
ipcs: ipcs.o
ipcrm: ipcrm.o
fsck: fsck.o
dmesg: dmesg.o


install: all
	install -m 755 $(ETC) /etc
	ln -sf /etc/shutdown /etc/reboot
	ln -sf /etc/shutdown /etc/fastboot
	ln -sf /etc/shutdown /etc/halt
	ln -sf /etc/shutdown /etc/fasthalt
	ln -sf /etc/rdev /etc/swapdev
	ln -sf /etc/rdev /etc/ramsize
	ln -sf /etc/rdev /etc/vidmode
	ln -sf /etc/rdev /etc/rootflags
	ln -sf /etc/fsck /etc/mkfs
	install -m 644 $(ETC_FILES) /etc
	install -m 644 $(MAN8) /usr/man/man8
	install -m 644 ipc.info /usr/info
	@@for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "Running make install in $$i..."; \
	$(MAKE) install); \
	done

clean:
	-rm -f $(ETC) *.o *~
	@@for i in $(SUBDIRS) ;\
	do \
	(cd $$i ; echo "Running make clean in $$i..."; \
	$(MAKE) clean); \
	done
