# Generic makefile , do NOT edit !

# !!! GNU Make needed !!!

include Makefile.in

RM    = rm -f
CC    = gcc
MKDEP = -M
AR    = ld -r -o




TARGET_DIR=$(shell if [ ! "$(CURRENT_DIR)" ]; then printf "$(TARGET_PATH)/"; else printf "$(TARGET_PATH)/$(CURRENT_DIR)/"; fi)
	
ARCHIVE_LIB=.lib
ARCHIVE=$(TARGET_DIR)$(ARCHIVE_LIB)
DEPEND=$(shell if [ ! "$(CURRENT_DIR)" ];  then printf ""; else printf "$(TARGET_DIR).depend"; fi)

OBJ=$(shell for X in . $(TODO) ; do if [ "$$X" != . ] ; then printf "%s " "$(TARGET_DIR)$$X.o" ; fi ; done)
SRC=$(shell for X in . $(TODO) ; do if [ "$$X" != . ] && [ -f $$X.cpp ] ; then printf "%s " "$$X.cpp" ; fi ; if [ "$$X" != . ] && [ -f $$X.c ] ; then printf "%s " "$$X.c" ; fi ; done)
ARC=$(shell for X in . $(SUBS) ; do if [ "$$X" != . ] ; then printf "%s " "$(TARGET_DIR)$$X/$(ARCHIVE_LIB)" ; fi ; done)

TARGET0=$(shell if [ ! "$(CURRENT_DIR)" ]; then printf "$(TARGET)"; else printf "$(ARCHIVE)"; fi)


all: init subs $(TARGET0)


init:	
	@mkdir -p $(TARGET_DIR)


subs:
	@for X in . $(SUBS) ; do if [ "$$X" != . ] ; then if [ ! "$(CURRENT_DIR)" ]; then export CURRENT_DIR=$$X; else export CURRENT_DIR=$(CURRENT_DIR)/$$X; fi ; $(MAKE) -C $$X ; fi ; done



$(TARGET0): $(DEPEND) $(OBJ) $(ARC)
	@if [ ! "$(CURRENT_DIR)" ]; then $(TARGET_MAKE) $(OBJ) $(ARC) -o $@ $(LFLAGS); else $(AR) $(ARCHIVE) $(OBJ) $(ARC); fi
	@chmod 755 $(TARGET0)



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



$(TARGET_DIR)%.o: %.cpp
	$(CC) $(CFLAGS) -c $*.cpp -o $@







clean: init
	@for X in . $(SUBS) ; do if [ "$$X" != . ] ; then if [ ! "$(CURRENT_DIR)" ]; then export CURRENT_DIR=$$X; else export CURRENT_DIR=$(CURRENT_DIR)/$$X; fi ; $(MAKE) -C $$X clean ; $(RM) -r $(TARGET_DIR)$$X; fi ; done
	$(RM) $(OBJ) $(DEPEND) $(TARGET0);


$(DEPEND): Makefile.in
	$(CC) $(MKDEP) $(CFLAGS) $(SRC) >$(DEPEND)


ifneq ($(wildcard $(DEPEND)),)
  include $(DEPEND)
endif