# generic makefile for atoms for (gcc)
# runs under DOS and OS/2
#
TARGET_NAME = libatoms.a

GCC=gcc
GXX=gpp
FLAGS=-Wall -O2 -I./include/ -fno-rtti -fno-exceptions
GXXFLAGS=-fno-rtti -fno-exceptions
#FLAGS+=-DERROR_HANDLER
OBJ=.o

OBJECTS=struct$(OBJ)

%OBJECTS=containe$(OBJ)
OBJECTS+=dbllist$(OBJ)
OBJECTS+=sets$(OBJ)
OBJECTS+=std_str$(OBJ)
OBJECTS+=struct$(OBJ)
OBJECTS+=lists$(OBJ)
OBJECTS+=strings$(OBJ)
OBJECTS+=stack$(OBJ)

OBJECTS+=utf8$(OBJ)
OBJECTS+=mtx_impl$(OBJ)

#### OS autodetection part of makefile ####


#Nothing is an indentifier for DOS? Too bad.
ifeq ($(OSTYPE),)
ifeq ($(HOSTTYPE),iris4d)
OSTYPE = iris4d
else
OSTYPE = dos
endif
endif


# for Linux - debian
ifeq ($(OSTYPE),linux-gnu)
GXX = g++
endif

# for 'linux' - Slackware; 'Linux' - Red Hat
#ifeq ($(OSTYPE),$(filter $(OSTYPE),linux Linux))
#endif
#end of Linux


# for MAC
ifeq ($(OSTYPE),darwin)
GXX = g++
endif

# for sun
#ifeq ($(OSTYPE),solaris)
#LIBS=-lm
#endif
#ifeq ($(OSTYPE),$(filter $(OSTYPE),solaris2.9 solaris2.10))
#endif

#ifeq ($(OSTYPE),sunos4)
#endif
#end of sun

#for OS/2
ifneq "$(OS2_SHELL)" ""
OSTYPE = os2
endif

# for aix
#ifeq ($(OSTYPE),aix)
#endif
#end of aix

# for MSDOS under djgpp
#ifeq ($(OSTYPE),msdosdjgpp)
#endif
#end of MSDOS under DJGPP


.SUFFIXES: .c .cc $(OBJ) .exe .a

.cc$(OBJ):
	$(GXX) $(FLAGS) $(GXXFLAGS) $(DEBUG) -c $*.cc $(ERROR) -o $*$(OBJ) $(GETTEXT)

.c$(OBJ):
	$(GCC) $(FLAGS) $(DEBUG) -c $*.c $(ERROR) -o $*$(OBJ) $(GETTEXT)


$(TARGET_NAME): $(OBJECTS)
	ar rcs $(TARGET_NAME) $(OBJECTS)


struct$(OBJ):	struct.c
utf8$(OBJ):	utf8.c

%complex$(OBJ):	complex.cc
containe$(OBJ):	containe.cc
interval$(OBJ):	interval.cc include/interval.h
std_str$(OBJ):	std_str.cc include/std_str.h
stack$(OBJ):	stack.cc include/stacks.h
sets$(OBJ):	sets.cc include/sets.h
strings$(OBJ):	strings.cc include/stringa.h

all:     $(TARGET_NAME)
#	cp -f strings/*.h include/*.h
#	cp -f sets/*.h include/*.h


default: $(TARGET_NAME)


clean:
	rm -f $(TARGET_NAME) *.exe *$(OBJ) *.obj *.o *.bak core *.bak *.bkp *.a
	rm -f include/*.bak include/*.bkp

distclean: clean
	cp include/common.h.gen include/common.h
	cp makefile.gen makefile

generic:
	cp include/common.h.gen include/common.h
	rm makefile
	cp makefile.gen makefile



