# Definitionen und Regeln fuer alle makefiles
# (c) Klaus Gebhardt, 1994

include i:/project/c/makeversions

CC = gcc

AR = ar
ARFLAGS = r
RANLIB = $(AR) s

LDFLAGS = -L.

%.o : %.f
	f2c -A -a $<
	$(CC) $(CFLAGS) -c $(patsubst %.f,%.c,$<) -o $@
	@rm $(patsubst %.f,%.c,$<)

%.o : %.cc ; $(CC) $(CFLAGS) -c $< -o $@
%.o : %.c ; $(CC) $(CFLAGS) -c $< -o $@

%.o : %.s ; $(CC) -mprobe -c -x assembler-with-cpp -I. $<
%l.o : %.s ; $(CC) -mprobe -DLONG_DOUBLE -c -x assembler-with-cpp -I. $< -o $@

%.obj : %.f
	f2c -A -a $<
	$(CC) $(CFLAGS) -c $(patsubst %.f,%.c,$<) -o $@ -Zomf
	@rm $(patsubst %.f,%.c,$<)

%.obj : %.cc ; $(CC) $(CFLAGS) -c $< -o $@ -Zomf
%.obj : %.c ; $(CC) $(CFLAGS) -c $< -o $@ -Zomf

%.obj : %.s ; $(CC) -mprobe -c -x assembler-with-cpp -I. $< -Zomf
%l.obj : %.s ; $(CC) -mprobe -DLONG_DOUBLE -c -x assembler-with-cpp -I. $< -o $@ -Zomf

%.a : $(OBJECTS)
	rm -f $@
	$(AR) $(ARFLAGS) $@ $(OBJECTS)
	$(RANLIB) $@

%.lib : %.a
	emxomf -l $<

%.res : %.rc
	rc -r $<

all : $(LIBRARY) $(EXEC)

install : all
ifdef LIBRARY
	cp $(LIBRARY) $(LIBDIR)
endif
ifdef INCLUDES
	cp $(INCLUDES) $(INCLDIR)
endif
ifdef INFO
	cp $(INFO) $(INFODIR)
endif

clean :
	rm -f *.a *.lib *.o *.obj *.exe *.dll
