# makefile for atoms for (gcc)
# runs under DOS, Windows, OS/2 and many Linux systems
#
@SET_MAKE@
@SET_OSTYPE@

ifeq ($(MAKE),)
MAKE=make
endif


TARGET_LIB_NAME = libimages.a
TEST_NAME_STR = TestImages.exe

FLAGS=-Wall -I../atoms/include/
#FLAGS+=-DERROR_HANDLER
CFLAGS=@CPPFLAGS@ @CFLAGS@ @OPTIMIZE_CFLAGS@ -DOPTIMISE_SPEED $(FLAGS)
CXXFLAGS=@CPPFLAGS@ @CXXFLAGS@ @OPTIMIZE_CFLAGS@ -DOPTIMISE_SPEED -DNO_EXTENSIONS $(FLAGS)

OBJ=.o

OBJECTS=imgop$(OBJ)
OBJECTS+=img_tool$(OBJ)
OBJECTS+=rasterOp$(OBJ) 

OBJECTS+=filehnd$(OBJ)
OBJECTS+=img_futi$(OBJ)
OBJECTS+=imgsupp$(OBJ)
OBJECTS+=imgut$(OBJ)
OBJECTS+=ras_bmp$(OBJ)
OBJECTS+=ras_gif$(OBJ)
OBJECTS+=ras_img$(OBJ)
OBJECTS+=ras_jpg$(OBJ)
OBJECTS+=ras_png$(OBJ)
OBJECTS+=ras_webp$(OBJ)
OBJECTS+=vecimage$(OBJ)


COMMONDEP=../atoms/include/common.h $(MAKEFILE_LIST)


.SUFFIXES: .c .cc $(OBJ) .exe .a
.PHONY: all default distclean generic clean test


.cc$(OBJ): ../atoms/include/*.h *.h
	@CXX@ $(CXXFLAGS) $(DEBUG) -c $*.cc $(ERROR) -o $*$(OBJ) $(GETTEXT)

.c$(OBJ): ../atoms/include/*.h *.h
	@CC@ $(CFLAGS) $(DEBUG) -c $*.c $(ERROR) -o $*$(OBJ) $(GETTEXT)


$(TARGET_LIB_NAME): $(OBJECTS)
	@AR@ rcs $(TARGET_LIB_NAME) $(OBJECTS)


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


default: $(TARGET_LIB_NAME)


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

distclean: clean
	cp makefile.gen makefile

generic:
	rm makefile
	cp makefile.gen makefile


#################### TEST ONLY #######################

../atoms/libatoms.a: ../atoms/include/*.h ../atoms/*.c ../atoms/*.cc
	$(MAKE) -C ../atoms libatoms.a

test/bench$(OBJ): ../atoms/test/bench.c $(MAKEFILE_LIST)

test/test$(OBJ): test/test.cc *.h ../atoms/include/*.h $(MAKEFILE_LIST)
	@CXX@ $(CXXFLAGS) $(DEBUG) -c $*.cc $(ERROR) -o $*$(OBJ) -I../ -I../atoms $(GETTEXT)

test/test.exe: test/test$(OBJ) ../atoms/test/bench$(OBJ) error$(OBJ) $(TARGET_LIB_NAME) ../atoms/libatoms.a
	@CXX@ -o $@ $*$(OBJ) ../atoms/test/bench$(OBJ) error$(OBJ) ../atoms/libatoms.a $(LDFLAGS) $(LIBS) $(TARGET_LIB_NAME) $(ERROR)


test: test/test.exe
	test/test.exe -test
