#==================================# # Author: Moreno 'baro' Baricevic # # Date: 02 Oct 2005 # # File: Makefile.devices # #----------------------------------# # Prev Modified: 02 Oct 2005 # # Prev Modified: 27 Oct 2005 # # Prev Modified: 28 Oct 2005 # # Last Modified: 29 Oct 2005 # #==================================# ifndef TEST TEST = test_ endif MKSOCKET = /home/baro/lib/c/strregex/mksocket.x MKSOCKET = /root/lib/c/strregex/mksocket.x all: cleandev dev dev: $(MKSOCKET) touch -- $(TEST)file || : mkdir -- $(TEST)dir || : mknod -- $(TEST)char c 0 0 || : mknod -- $(TEST)block b 0 0 || : mkfifo -- $(TEST)pipe || : ln -s -- $(TEST)none $(TEST)deadlink || : ln -s -- $(TEST)file $(TEST)link || : $(MKSOCKET) $(TEST)socket || : ifeq (0,${MAKELEVEL}) mkdir -- $(TEST)subdir && cd $(TEST)subdir && { make -f ../Makefile TEST=$(TEST)sub_ dev ; cd - ; } ln -s $(TEST)subdir $(TEST)link_to_$(TEST)dir || : endif { eval `resize` ; /bin/ls -laprtsd $$PWD/$(TEST)* | cut -b -$$COLUMNS ; } ifdef TEST ifneq ($(TEST),"") cleandev: @echo 'Checking $(TEST)...' @test "x$(TEST)" != "x" @echo "$(TEST)" | grep -q "[^\./]$$" @echo -- removing $(TEST)subdir/$(TEST)* rm -vi -- $(TEST)subdir/$(TEST)* || : rmdir -v -- $(TEST)subdir/$(TEST)* || : @echo -- removing $(TEST)* rm -vi -- $(TEST)* || : rmdir -v -- $(TEST)* || : endif endif ifdef TEST ifneq ($(TEST),"") forcecleandev: @echo 'Checking $(TEST)...' @test "x$(TEST)" != "x" @echo "$(TEST)" | grep -q "[^\./]$$" @echo -- removing $(TEST)* @for file in $(TEST)subdir/$(TEST)* ; do \ test -d $$file && rmdir -v -- $$file || rm -vf -- $$file ; \ done || : @for file in $(TEST)* ; do \ test -d $$file && rmdir -v -- $$file || rm -vf -- $$file ; \ done || : endif endif distclean: forcecleandev ############################################################################### ############################################################################### MNT = mnt/ DEV = fs/ MKDIR = mkdir -v RM = rm -fv DD = dd bs=1M count=0 if=/dev/zero ifdef RO MOUNT = mount -r -v -o loop else MOUNT = mount -w -v -o loop endif NAME = 0 SIZE = 1 MKFS = 2 MKOPT = 3 MNTOPT = 4 ENABLED = 5 LABELS = \ ext2:1:mkfs.ext2:"-F -v -m0":"-t ext2":true \ ext3:2:mkfs.ext3:"-F -v -m0":"-t ext3":true \ reiserfs:33:mkreiserfs:"-ff":"-t reiserfs":true \ xfs:16:mkfs.xfs:"":"-t xfs":true \ jfs:16:mkfs.jfs:"-q":"-t jfs":true \ bfs:1:mkfs.bfs:"":"-t bfs":false \ minix:1:mkfs.minix:"":"-t minix":true \ minix_v2:1:mkfs.minix:"-v":"-t minix":true \ fat12:1:mkdosfs:"-v -F 12":"-t vfat -o fat=12":true \ fat16:1:mkdosfs:"-v -F 16":"-t vfat -o fat=16":true \ fat32:1:mkdosfs:"-v -F 32":"-t vfat -o fat=32":true \ allfs: dirs fs mount recursive-dev dirs: test -d $(DEV) || $(MKDIR) $(DEV) test -d $(MNT) || $(MKDIR) $(MNT) test = echo fs = test fs: dirs @for dev in $(LABELS) ; \ do \ declare -a p ; \ { t="$$IFS" ; IFS=: p=( $$dev ) ; IFS="$$t" ; } ; \ $${p[$(ENABLED)]} && { \ mnt=$(MNT)$${p[$(NAME)]} ; dev=$(DEV)$${p[$(NAME)]} ; \ test -f $$dev && continue ; \ echo "--- creating $${p[$(NAME)]}" ; \ $($@) $(MKDIR) $$mnt || \ exit 1 ; \ $($@) $(DD) of=$$dev seek=$${p[$(SIZE)]} || \ exit 1 ; \ $($@) $${p[$(MKFS)]} $${p[$(MKOPT)]} $$dev || \ { $(RM) $$dev ; exit 1 ; } ; \ } ; \ done # $($@) $(MOUNT) $${p[$(MNTOPT)]} $$dev $$mnt || \ # exit 1 ; \ mount: dirs @for dev in $(LABELS) ; \ do \ declare -a p ; \ { t="$$IFS" ; IFS=: p=( $$dev ) ; IFS="$$t" ; } ; \ $${p[$(ENABLED)]} && { \ mnt=$(MNT)$${p[$(NAME)]} ; dev=$(DEV)$${p[$(NAME)]} ; \ mount | grep "^.*$$dev .*$$mnt .*$$" || { \ test -f $$dev -a -d $$mnt && \ $(MOUNT) $${p[$(MNTOPT)]} $$dev $$mnt ; \ } ; \ } ; \ done umount: mount | grep -o "^$(PWD)/$(DEV)[^ ]\+" | xargs -r umount -fv recursive-dev: dirs mount @for dir in $(MNT)* ; \ do \ cd $$dir && { \ cp $(PWD)/Makefile . && \ MAKELEVEL=0 make dev ; \ cd - ; \ } ; \ done recursive-cleandev: @for dir in $(MNT)* ; \ do \ cd $$dir && { \ test -f Makefile && \ MAKELEVEL=0 make forcecleandev ; \ cd - ; \ } ; \ done cleanfs: umount $(RM) -r $(MNT) $(DEV) recursive-clean: recursive-cleandev cleanfs ############################################################################### ############################################################################### cleanall: : #EOF