A make file: BIT = 32 # could override in commandline ARCH_PLATFORM:sh = /usr/bin/uname -p # invokes sh cmd: output:sparc ARCH_sparc = sparc-$BIT ARCH_DIR = $(ARCH_$(ARCH_PLATFORM)) # Two macros nesting OK. RELEASE:sh = /usr/bin/uname -r | sed 's/^5/2/' | cut -d\. -f1,2 opt := VARIANT = opt clean-opt := VARIANT = clean-opt # Assign macros depending on target %.i := VARIANT = cpp # If the target is any file.i bits64 := OBJ_DEST_DIR = sparcv9 bits32 := OBJ_DEST_DIR = . # use TOP_DIR or WS_ROOT or VTS_BASE # the individual make files provide these as follows: SOURCE = a.c b.c c.c BINARY = a.out TARG = $(BIN) # The macros manipulate this as follows: OBJS = $(SOURCE:%.c=$(OBJ_DEST_DIR)/%.o) BIN = $(BINARY:%=$(OBJ_DEST_DIR)/%) $(BIN) : $$(OBJS) # The rule of making binary goes here... # You can say a set of .o files could be compiled from local .c file: sparcv9/%.o ./%.o : %.c $(CC) -c $< -o $@ sparcv9/a.o ./b.o : %.c # This will fail. The target should have % $(CC) -c $< -o $@ OBJ_FORM = sparcv9/%.o ./%.o $(OBJ_FORM) : %.c $(CC) -c $< -o $@ # OBJ = $(SOURCE:.c=.o) # replaces the suffix OBJ = $(SOURCE:%.c=sparcv9/%.o) # produces sparcv9/a.o, etc. DIRS = opt/sparcv9 debug/sparcv9 BIN_TARGS.c = $(DIRS:%=%/bin/$(BINARY.c)) #what does this mean ?