
TOP = @TOP@
SRC = .
LIB = .
DIR = Modules
INCS = -I$(TOP) -I$(TOP)/OSLib -I.
DIRS = @HOSTOS@

CC = @CC@
LD = @LD@
CFLAGS = @CFLAGS@ $(INCS)
LDFLAGS = @LDFLAGS@
ARFLAGS = @ARFLAGS@

SRCS = @MODSRCS@

# VPATH = $(TOP)/source $(TOP)/source/Modules/Unix $(OBJ)

DEPS = $(SRCS:%.c=%.d)
OBJS = $(SRCS:%.c=%.o)

all: compile

clean: sub-clean
	rm -f $(OBJS) $(DEPS)

-include $(DEPS)

%.o: %.c $(TOP)/conf.h
	$(CC) $(CFLAGS) @DEPFLAGS@ $(CFLAGS_$<) -o $@ -c $<

$(LIB)/lib$(DIR).a: $(OBJS)
	$(AR) $(ARFLAGS) $(LIB)/lib$(DIR).a $(OBJS)

compile: $(LIB)/lib$(DIR).a sub-compile

sub:	$(DIRS)
	for i in $(DIRS); do \
	if ! $(MAKE) -C $$i $(WHICH) ; then exit 1; fi ;\
	done

sub-compile:
	if ! $(MAKE) sub WHICH=compile; then false; fi

sub-clean:
	if ! $(MAKE) sub WHICH=clean; then false; fi



