shell编程例子 -- 一个makefile例子

unix.mkf
========
#=============================================================================#
# Copyright (C) BS P4 2000. All Rights Reserved. Confidential #
#=============================================================================#

#=============================================================================#
# module: unix.mkf #
# description: global include for all makefiles #
# system UNIX #
# version: 2000.08.01 #
# Author: Zhou zeyan #
#=============================================================================#

#=============================================================================#
# processline #
#=============================================================================#
PLINE = PCFC

#=============================================================================#
# useful #
#=============================================================================#
NOTHING =
BLANC = $(NOTHING) $(NOTHING)
SAY = $(BLANC)echo$(BLANC)
CONTINUE = $(BLANC)echo"">/dev/null$(BLANC)
IF = $(BLANC)if$(BLANC)
THEN = ;then$(BLANC)
FI = ;fi$(BLANC)
FSY = [ -f$(BLANC)
FSN = [ ! -f$(BLANC)
FSE = $(BLANC)]$(BLANC)
CP = cp$(BLANC)
RCP = rcp$(BLANC)
PU = echo>/dev/null<
RM = rm$(BLANC)
DTOU = dos2unix
SS =
SM1 = .*

#=============================================================================#
# home device and directory #
#=============================================================================#
DEVHOME = /
DIRHOME = home/$(PROJ)

#=============================================================================#
# global directories #
#=============================================================================#
GLOBALDOS = $(DEVHOME)$(DIRHOME)/dos/
GLOBALMKF = $(DEVHOME)$(DIRHOME)/mkf/

#=============================================================================#
# Include application mkf #
#=============================================================================#
include $(GLOBAL_MKF_HOME)$(PROJ).mkf

#=============================================================================#
# oracle directories #
#=============================================================================#
ORAINC = $(ORACLE_HOME)/precomp/public/

#=============================================================================#
# system directories #
#=============================================================================#
SYSINC = /usr/include/
SYSINC2 = /usr/include/sys/

#=============================================================================#
# file extensions #
#=============================================================================#
EXTCOM =
EXTORS = .pc
EXTSRC = .c
EXTINC = .h
EXTOBJ = .o
EXTLIB = .a
EXTSHL =
EXTBIN =
EXTLIS = .lis

#=============================================================================#
# all include pathes #
#=============================================================================#
OCALLINC = $(BLANC)include=$(GLBINC) include=$(UTLINC) include=$(COMINC) 
include=$(PKSINC) include=$(ORAINC) include=$(SIIXINC) include=$(CCMINC) 
include=$(SYSINC) include=$(SYSINC2)

#=============================================================================#
# depencies for objects #
#=============================================================================#
GLBINC_ELE = $(GLBINC)ch_names.h $(GLBINC)cgl_inc.h $(GLBINC)tele_l1.h /
$(GLBINC)tele_l2.h 
UTLINC_ELE = $(UTLINC)utl_inc.h $(UTLINC)utl_db_i.h
COMINC_ELE = $(COMINC)comp.h $(COMINC)dbgp.h
PKSINC_ELE = $(PKSINC)pks_comm.h
MVAINC_ELE =
MTINC_ELE =
ORAINC_ELE = $(ORAINC)sqlca.h
SIIXINC_ELE = $(SIIXINC)pdv_errno.h $(SIIXINC)ppx_errno.h
CCMINC_ELE = $(CCMINC)pcm_defs_u.h
SYSINC_ELE = $(SYSINC)stdio.h

#=============================================================================#
# depencies for binaries #
#=============================================================================#
GLBLIB_ELE =
UTLLIB_ELE = $(UTLLIB)libutl.a
COMLIB_ELE = $(COMLIB)libcom.a
USERLIB_ELE = $(USERLIBHOME)userlib.a
ORALIB_ELE = $(ORACLE_HOME)/lib/libsql.a
SIIXLIB_ELE =
CCMLIB_ELE = /opt/SiiXdvl/lib/libpics.a /opt/SiiXdvl/lib/libpdi.a /
/usr/lib/libnsl.so
SYSLIB_ELE = /usr/lib/libm.a
SOCKLIB_ELE = /usr/lib/libsocket.a /usr/lib/libdl.so /usr/lib/libintl.so

#=============================================================================#
# libraries for binaries #
#=============================================================================#
LIBGLB =
LIBUTL = $(BLANC)$(UTLLIB)libutl.a
LIBCOM = $(BLANC)$(COMLIB)libcom.a
LIBUSER = $(BLANC)$(USERLIBHOME)userlib.a
LIBMVA =
LIBMT =
LIBORA = $(BLANC)-L$(PROLDLIBS)
LIBSIIX =
LIBCCM = $(BLANC)/opt/SiiXdvl/lib/libpics.a /opt/SiiXdvl/lib/libpdi.a /
/usr/lib/libnsl.so.1
LIBSYS = $(BLANC)/usr/lib/libm.so
LIBSOCK = $(BLANC)/usr/lib/libsocket.so /usr/lib/libdl.so /usr/lib/libintl.so

#=============================================================================#
# Oracle Compiler #
#=============================================================================#
# name of compiler
OC = $(ORACLE_HOME)/bin/proc
# compilerflags and -switches
OCINC = include=
OCOPT = config=$(GLOBALMKF)proc.cfg

#=============================================================================#
# Compiler #
#=============================================================================#
# name of compiler
CC = /usr/bin/cc
# compilerflags and -switches
CCINC = -I
CCDEBUG = $(debug:1=-g)
# comment by zzy CCOPT = -c -DDEBUG $(CCDEBUG)
CCOPT = -c $(CCDEBUG)
# flag for objectfile
CCOBJ = -o

#=============================================================================#
# create and make library #
#=============================================================================#
# create library
CL = /usr/bin/ar -rc
# make library
ML = /usr/bin/ar -rcv
# separator between objectfiles
MLS =

#=============================================================================#
# Oracle Linker #
#=============================================================================#
# name of oracle linker
OL = cc -o
# linkerflags and -switches
OLDEBUG = $(debug:1=-g)
OLOPT = $(OLDEBUG)
# librarymark for object library
OLOL =
# librarymark for shared-library
OLSL =
# separator between objectfiles
OLS = $(BLANC)

#=============================================================================#
# Linker #
#=============================================================================#
# name of linker
LD = /usr/bin/cc
# linkerflags und -switches
LDDEBUG = $(debug:1=-g)
LDOPT = -o $(LDDEBUG)
# librarymark for object library
LDOL =
# librarymark for shared-library
LDSL =
# separator between objectfiles
LDS =

#=============================================================================#
# Copyright (C) BS P4 2000. All Rights Reserved. Confidential #
#=============================================================================#

host.mkf
========
#=============================================================================#
# Copyright (C) BS P4 2000. All Rights Reserved. Confidential #
#=============================================================================#

#=============================================================================#
# module: pcfc.mkf #
# description: application include for all makefiles #
# system UNIX #
# version: 2000.08.01 #
# Author: Zhou zeyan #
#=============================================================================#

#=============================================================================#
# USERLIB directories #
#=============================================================================#
USERLIBHOME = $(DEVHOME)$(DIRHOME)/userlib/

#=============================================================================#
# COMTCP directories #
#=============================================================================#
COMTCPHOME = $(DEVHOME)$(DIRHOME)/comtcp/
COMTCPWORKETC = $(COMTCPHOME)work/etc/
COMTCPWORKSRC = $(COMTCPHOME)work/src/
COMTCPWORKINC = $(COMTCPHOME)work/inc/
COMTCPWORKOBJ = $(COMTCPHOME)work/obj/
COMTCPWORKLIB = $(COMTCPHOME)work/lib/
COMTCPWORKBIN = $(COMTCPHOME)work/bin/
COMTCPWORKLIS = $(COMTCPHOME)work/src/
COMTCPSRC = $(COMTCPHOME)work/src/
COMTCPLIS = $(COMTCPHOME)work/src/
COMTCPETC = $(COMTCPHOME)etc/
COMTCPINC = $(COMTCPHOME)inc/
COMTCPOBJ = $(COMTCPHOME)obj/
COMTCPLIB = $(COMTCPHOME)lib/
COMTCPBIN = $(COMTCPHOME)bin/

#=============================================================================#
# Copyright (C) BS P4 2000. All Rights Reserved. Confidential #
#=============================================================================#

application.mkf
===============
#=============================================================================#
# Copyright (C) BS AG 1998. All Rights Reserved. Confidential #
#=============================================================================#

#=============================================================================#
# #
# Project : #
# BAO CRM3 CGL - Level 2 #
# #
# module name : #
# de.mkf #
# #
# Task #
# Makefile for programe de #
# #
# Author #
# Zhou zeyan #
# #
# Begin of implementation #
# Dec.31, 1998 #
# #
# Update #
# Zhou zeyan #
# #
# Update date #
# Feb.12, 1999 #
# #
# Release #
# Version 1.00 #
# #
# Definition #
# make -f de.mkf #
# #
# Parameters #
# No parameters #
# #
# Return code #
# No return code #
# #
#=============================================================================#

#=============================================================================#
# global include #
#=============================================================================#
include $(GLOBAL_MKF_HOME)$(OS).mkf

#=============================================================================#
# directories/files #
#=============================================================================#
DOS = $(DEWORKDOS)
ETC = $(DEWORKETC)
SRC = $(DEWORKSRC)
INC = $(DEWORKINC)
OBJ = $(DEWORKOBJ)
LIB = $(DEWORKLIB)
BIN = $(DEWORKBIN)
MSC = $(DEWORKMSC)
LIS = $(DEWORKLIS)
RUNETC = $(DEETC)
RUNSRC = $(DESRC)
RUNINC = $(DEINC)
RUNOBJ = $(DEOBJ)
RUNLIB = $(DELIB)
RUNBIN = $(DEBIN)
RUNMSC = $(DEMSC)

INAM_1 = qdr_inc

SNAM_1 = qdr
SNAM_2 = qdr_list
SNAM_3 = de

ONAM_1 = $(SNAM_1)
ONAM_2 = $(SNAM_2)
ONAM_3 = $(SNAM_3)

LNAM_1 = qdr

BNAM_2 = $(SNAM_2)
BNAM_3 = $(SNAM_3)x

IMOD_1 = $(INC)$(INAM_1)$(EXTINC)

PMOD_1 = $(SRC)$(SNAM_1)$(EXTORS)
SMOD_1 = $(SRC)$(SNAM_1)$(EXTSRC)
PMOD_2 = $(SRC)$(SNAM_2)$(EXTORS)
SMOD_2 = $(SRC)$(SNAM_2)$(EXTSRC)
PMOD_3 = $(SRC)$(SNAM_3)$(EXTORS)
SMOD_3 = $(SRC)$(SNAM_3)$(EXTSRC)

OMOD_1 = $(OBJ)$(ONAM_1)$(EXTOBJ)
OMOD_2 = $(OBJ)$(ONAM_2)$(EXTOBJ)
OMOD_3 = $(OBJ)$(ONAM_3)$(EXTOBJ)

LMOD_1 = $(LIB)$(LNAM_1)$(EXTLIB)

BMOD_2 = $(BIN)$(BNAM_2)$(EXTBIN)
BMOD_3 = $(BIN)$(BNAM_3)$(EXTBIN)

LIST_1 = $(LIS)$(SNAM_1)$(EXTLIS)

RUN_IMOD_1 = $(RUNINC)$(INAM_1)$(EXTINC)
RUN_BMOD_2 = $(RUNBIN)$(BNAM_2)$(EXTBIN)
RUN_BMOD_3 = $(RUNBIN)$(BNAM_3)$(EXTBIN)
RUN_LMOD_1 = $(RUNLIB)$(LNAM_1)$(EXTLIB)

#=============================================================================#
# generate #
#=============================================================================#
all : src obj lib bin
@ $(SAY) "$(@) done !"
@ $(SAY) ""

src : $(SMOD_1) $(SMOD_2) $(SMOD_3)
@ $(SAY) "$(@) done !"
@ $(SAY) ""

obj : $(OMOD_1) $(OMOD_2) $(OMOD_3)
@ $(SAY) "$(@) done !"
@ $(SAY) ""

lib : $(LMOD_1)
@ $(SAY) "$(@) done !"
@ $(SAY) ""

bin : $(BMOD_2) $(BMOD_3)
@ $(SAY) "$(@) done !"
@ $(SAY) ""

#=============================================================================#
# sources #
#=============================================================================#
$(SMOD_1) : $(PMOD_1) $(IMOD_1) /
$(GLBINC_ELE) $(UTLINC_ELE) $(COMINC_ELE) $(PKSINC_ELE) /
$(SIIXINC_ELE) $(CCMINC_ELE) /
$(ORAINC_ELE) $(SYSINC_ELE)
$(SAY) "+--- make $(@) ---+"
$(OC) iname=$(PMOD_1) $(OCINC)$(INC)$(OCALLINC) oname=$(@) /
$(OCOPT)
@ $(SAY) ""

$(SMOD_2) : $(PMOD_2) $(IMOD_1) /
$(GLBINC_ELE) $(UTLINC_ELE) $(COMINC_ELE) $(PKSINC_ELE) /
$(SIIXINC_ELE) $(CCMINC_ELE) /
$(ORAINC_ELE) $(SYSINC_ELE)
$(SAY) "+--- make $(@) ---+"
$(OC) iname=$(PMOD_2) $(OCINC)$(INC)$(OCALLINC) oname=$(@) /
$(OCOPT)
@ $(SAY) ""

$(SMOD_3) : $(PMOD_3) $(IMOD_1) /
$(GLBINC_ELE) $(UTLINC_ELE) $(COMINC_ELE) $(PKSINC_ELE) /
$(SIIXINC_ELE) $(CCMINC_ELE) /
$(ORAINC_ELE) $(SYSINC_ELE)
$(SAY) "+--- make $(@) ---+"
$(OC) iname=$(PMOD_3) $(OCINC)$(INC)$(OCALLINC) oname=$(@) /
$(OCOPT)
@ $(SAY) ""

#=============================================================================#
# objects #
#=============================================================================#
$(OMOD_1) : $(SMOD_1) $(IMOD_1) /
$(GLBINC_ELE) $(UTLINC_ELE) $(COMINC_ELE) $(PKSINC_ELE) /
$(SIIXINC_ELE) $(CCMINC_ELE) /
$(ORAINC_ELE) $(SYSINC_ELE)
@ $(SAY) "+--- make $(@) ---+"
$(CC) $(CCOPT)$(LIS) /
$(CCINC)$(INC) $(CCALLINC) $(CCOBJ)$(@) $(SMOD_1)
@ $(SAY) ""

$(OMOD_2): $(SMOD_2) $(IMOD_1) /
$(GLBINC_ELE) $(UTLINC_ELE) $(COMINC_ELE) $(PKSINC_ELE) /
$(SIIXINC_ELE) $(CCMINC_ELE) /
$(ORAINC_ELE) $(SYSINC_ELE)
@ $(SAY) "+--- make $(@) ---+"
$(CC) $(CCOPT)$(LIS) /
$(CCINC)$(INC) $(CCALLINC) $(CCOBJ)$(@) $(SMOD_2)
@ $(SAY) ""

$(OMOD_3): $(SMOD_3) $(IMOD_1) /
$(GLBINC_ELE) $(UTLINC_ELE) $(COMINC_ELE) $(PKSINC_ELE) /
$(SIIXINC_ELE) $(CCMINC_ELE) /
$(ORAINC_ELE) $(SYSINC_ELE)
@ $(SAY) "+--- make $(@) ---+"
$(CC) $(CCOPT)$(LIS) /
$(CCINC)$(INC) $(CCALLINC) $(CCOBJ)$(@) $(SMOD_3)
@ $(SAY) ""

#=============================================================================#
# libraries #
#=============================================================================#
$(LMOD_1) : $(OMOD_1)
@ $(SAY) "+--- make $(@) ---+"
@ $(IF) $(FSN) $(LMOD_1) $(FSE) $(THEN) $(CL) $(LMOD_1) $(FI)
$(ML) $(LMOD_1) $(OMOD_1)
@ $(SAY) ""

#=============================================================================#
# binaries #
#=============================================================================#
$(BMOD_2) : $(OMOD_2) /
$(MTLIB_ELE) $(COMLIB_ELE) $(CCMLIB_ELE) /
$(ORALIB_ELE) $(SYSLIB_ELE)
@ $(SAY) "+--- make $(@) ---+"
$(OL) $(@) $(OMOD_2) $(LIBCOM) $(LIBUTL) $(LIBCCM) /
$(LIBORA) $(LMOD_1) $(OLOPT)
@ $(SAY) ""

$(BMOD_3) : $(OMOD_3) /
$(MTLIB_ELE) $(COMLIB_ELE) $(CCMLIB_ELE) /
$(ORALIB_ELE) $(SYSLIB_ELE)
@ $(SAY) "+--- make $(@) ---+"
$(OL) $(@) $(OMOD_3) $(LIBCOM) /
$(LIBUTL) $(LIBPKS) $(LIBCCM) $(LIBORA) $(LMOD_1) $(OLOPT)
@ $(SAY) ""

#=============================================================================#
# export #
#=============================================================================#
export : /
exportetc exportsrc exportinc exportobj exportlib exportbin exportmsc
@ $(SAY) "$(@) done !"
@ $(SAY) ""

exportetc :
@ $(IF)$(FSY)$(RUNETC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(RUNETC)"$(FI)
@ $(IF)$(FSY)$(RUNETC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(RUNETC) $(FI)

exportsrc :
@ $(IF)$(FSY)$(RUNSRC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(RUNSRC)"$(FI)
@ $(IF)$(FSY)$(RUNSRC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(RUNSRC) $(FI)

exportinc : $(RUN_IMOD_1)
@ $(IF)$(FSY)$(RUNINC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(RUNINC)"$(FI)
@ $(IF)$(FSY)$(RUNINC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(RUNINC) $(FI)
$(RUN_IMOD_1) : $(IMOD_1)
$(CP) $(IMOD_1) $(RUN_IMOD_1)

exportobj :
@ $(IF)$(FSY)$(RUNOBJ)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(RUNOBJ)"$(FI)
@ $(IF)$(FSY)$(RUNOBJ)*.*$(SM1)$(FSE)$(THEN) $(PU)$(RUNOBJ) $(FI)

exportlib : $(RUN_LMOD_1)
@ $(IF)$(FSY)$(RUNLIB)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(RUNLIB)"$(FI)
@ $(IF)$(FSY)$(RUNLIB)*.*$(SM1)$(FSE)$(THEN) $(PU)$(RUNLIB) $(FI)
$(RUN_LMOD_1) : $(LMOD_1)
$(CP) $(LMOD_1) $(RUN_LMOD_1)

exportbin : $(RUN_BMOD_2) $(RUN_BMOD_3)
@ $(IF)$(FSY)$(RUNBIN)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(RUNBIN)"$(FI)
@ $(IF)$(FSY)$(RUNBIN)*.*$(SM1)$(FSE)$(THEN) $(PU)$(RUNBIN) $(FI)
$(RUN_BMOD_2) : $(BMOD_2)
$(CP) $(BMOD_2) $(RUN_BMOD_2)
$(RUN_BMOD_3) : $(BMOD_3)
$(CP) $(BMOD_3) $(RUN_BMOD_3)

exportmsc :
@ $(IF)$(FSY)$(RUNMSC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(RUNMSC)"$(FI)
@ $(IF)$(FSY)$(RUNMSC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(RUNMSC) $(FI)

#=============================================================================#
# delete old #
#=============================================================================#
delold : /
deloldetc deloldsrc deloldinc deloldobj deloldlib deloldbin deloldmsc /
deloldlis
@ $(SAY) "$(@) done !"
@ $(SAY) ""
deloldetc :
@ $(IF)$(FSY)$(ETC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(ETC)"$(FI)
@ $(IF)$(FSY)$(ETC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(ETC) $(FI)
deloldsrc :
@ $(IF)$(FSY)$(SRC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(SRC)"$(FI)
@ $(IF)$(FSY)$(SRC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(SRC) $(FI)
deloldinc :
@ $(IF)$(FSY)$(INC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(INC)"$(FI)
@ $(IF)$(FSY)$(INC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(INC) $(FI)
deloldobj :
@ $(IF)$(FSY)$(OBJ)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(OBJ)"$(FI)
@ $(IF)$(FSY)$(OBJ)*.*$(SM1)$(FSE)$(THEN) $(PU)$(OBJ) $(FI)
deloldlib :
@ $(IF)$(FSY)$(LIB)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(LIB)"$(FI)
@ $(IF)$(FSY)$(LIB)*.*$(SM1)$(FSE)$(THEN) $(PU)$(LIB) $(FI)
deloldbin :
@ $(IF)$(FSY)$(BIN)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(BIN)"$(FI)
@ $(IF)$(FSY)$(BIN)*.*$(SM1)$(FSE)$(THEN) $(PU)$(BIN) $(FI)
deloldmsc :
@ $(IF)$(FSY)$(MSC)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(MSC)"$(FI)
@ $(IF)$(FSY)$(MSC)*.*$(SM1)$(FSE)$(THEN) $(PU)$(MSC) $(FI)
deloldlis :
@ $(IF)$(FSY)$(LIS)*.*$(SM1)$(FSE)$(THEN)$(SAY)"$(PU)$(LIS)"$(FI)
@ $(IF)$(FSY)$(LIS)*.*$(SM1)$(FSE)$(THEN) $(PU)$(LIS) $(FI)

#=============================================================================#
# clean #
#=============================================================================#
clean : /
cleanetc cleansrc cleaninc cleanobj cleanlib cleanbin cleanmsc /
cleanlis
@ $(SAY)"$(@) done !"
@ $(SAY)""
cleanetc :
@ $(CONTINUE)
cleansrc :
@ $(IF)$(FSY)$(SMOD_1) $(FSE)$(THEN)$(SAY)"$(RM)$(SMOD_1)$(SS)"$(FI)
@ $(IF)$(FSY)$(SMOD_1) $(FSE)$(THEN) $(RM)$(SMOD_1)$(SS) $(FI)
@ $(IF)$(FSY)$(SMOD_2) $(FSE)$(THEN)$(SAY)"$(RM)$(SMOD_2)$(SS)"$(FI)
@ $(IF)$(FSY)$(SMOD_2) $(FSE)$(THEN) $(RM)$(SMOD_2)$(SS) $(FI)
@ $(IF)$(FSY)$(SMOD_3) $(FSE)$(THEN)$(SAY)"$(RM)$(SMOD_3)$(SS)"$(FI)
@ $(IF)$(FSY)$(SMOD_3) $(FSE)$(THEN) $(RM)$(SMOD_3)$(SS) $(FI)
@ $(CONTINUE)
cleaninc :
@ $(CONTINUE)
cleanobj :
@ $(IF)$(FSY)$(OMOD_1) $(FSE)$(THEN)$(SAY)"$(RM)$(OMOD_1)$(SS)"$(FI)
@ $(IF)$(FSY)$(OMOD_1) $(FSE)$(THEN) $(RM)$(OMOD_1)$(SS) $(FI)
@ $(IF)$(FSY)$(OMOD_2) $(FSE)$(THEN)$(SAY)"$(RM)$(OMOD_2)$(SS)"$(FI)
@ $(IF)$(FSY)$(OMOD_2) $(FSE)$(THEN) $(RM)$(OMOD_2)$(SS) $(FI)
@ $(IF)$(FSY)$(OMOD_3) $(FSE)$(THEN)$(SAY)"$(RM)$(OMOD_3)$(SS)"$(FI)
@ $(IF)$(FSY)$(OMOD_3) $(FSE)$(THEN) $(RM)$(OMOD_3)$(SS) $(FI)
@ $(CONTINUE)
cleanlib :
@ $(IF)$(FSY)$(LMOD_1)$(FSE)$(THEN)$(SAY)"$(RM)$(LMOD_1)$(SS)"$(FI)
@ $(IF)$(FSY)$(LMOD_1)$(FSE)$(THEN) $(RM)$(LMOD_1)$(SS) $(FI)
@ $(CONTINUE)
cleanbin :
@ $(IF)$(FSY)$(BMOD_2)$(FSE)$(THEN)$(SAY)"$(RM)$(BMOD_2)$(SS)"$(FI)
@ $(IF)$(FSY)$(BMOD_2)$(FSE)$(THEN) $(RM)$(BMOD_2)$(SS) $(FI)
@ $(IF)$(FSY)$(BMOD_3)$(FSE)$(THEN)$(SAY)"$(RM)$(BMOD_3)$(SS)"$(FI)
@ $(IF)$(FSY)$(BMOD_3)$(FSE)$(THEN) $(RM)$(BMOD_3)$(SS) $(FI)
@ $(CONTINUE)
cleanmsc :
@ $(CONTINUE)
cleanlis :
@ $(CONTINUE)

#=============================================================================#
# Copyright (C) BS AG 1998. All Rights Reserved. Confidential #
#=============================================================================#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Shell脚本高级编程教程,希望对你有所帮助。 Example 10-23. Using continue N in an actual task: 1 # Albert Reiner gives an example of how to use "continue N": 2 # --------------------------------------------------------- 3 4 # Suppose I have a large number of jobs that need to be run, with 5 #+ any data that is to be treated in files of a given name pattern in a 6 #+ directory. There are several machines that access this directory, and 7 #+ I want to distribute the work over these different boxen. Then I 8 #+ usually nohup something like the following on every box: 9 10 while true 11 do 12 for n in .iso.* 13 do 14 [ "$n" = ".iso.opts" ] && continue 15 beta=${n#.iso.} 16 [ -r .Iso.$beta ] && continue 17 [ -r .lock.$beta ] && sleep 10 && continue 18 lockfile -r0 .lock.$beta || continue 19 echo -n "$beta: " `date` 20 run-isotherm $beta 21 date 22 ls -alF .Iso.$beta 23 [ -r .Iso.$beta ] && rm -f .lock.$beta 24 continue 2 25 done 26 break 27 done 28 29 # The details, in particular the sleep N, are particular to my 30 #+ application, but the general pattern is: 31 32 while true 33 do 34 for job in {pattern} 35 do 36 {job already done or running} && continue 37 {mark job as running, do job, mark job as done} 38 continue 2 39 done 40 break # Or something like `sleep 600' to avoid termination. 41 done 42 43 # This way the script will stop only when there are no more jobs to do 44 #+ (including jobs that were added during runtime). Through the use 45 #+ of appropriate lockfiles it can be run on several machines 46 #+ concurrently without duplication of calculations [which run a couple 47 #+ of hours in my case, so I really want to avoid this]. Also, as search 48 #+ always starts again from the beginning, one can encode priorities in 49 #+ the file names. Of course, one could also do this without `continue 2', 50 #+ but then one would have to actually check whether or not some job 51 #+ was done (so that we should immediately look for the next job) or not 52 #+ (in which case we terminate or sleep for a long time before checking 53 #+ for a new job).

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值