# RS-232 Serial Library Makefile for DJGPP cross-compilation

DJGPP_PREFIX  = $(HOME)/djgpp/djgpp
DJGPP_LIBPATH = $(HOME)/claude/windriver/tools/lib
CC            = $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-gcc
AR            = LD_LIBRARY_PATH=$(DJGPP_LIBPATH) $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-ar
RANLIB        = LD_LIBRARY_PATH=$(DJGPP_LIBPATH) $(DJGPP_PREFIX)/bin/i586-pc-msdosdjgpp-ranlib
CFLAGS        = -O2 -Wall -Wextra -march=i486 -mtune=i586

OBJDIR = ../obj/rs232
LIBDIR = ../lib

SRCS = rs232.c
OBJS = $(patsubst %.c,$(OBJDIR)/%.o,$(SRCS))
TARGET = $(LIBDIR)/librs232.a

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(OBJS) | $(LIBDIR)
	$(AR) rcs $@ $(OBJS)
	$(RANLIB) $@

$(OBJDIR)/%.o: %.c | $(OBJDIR)
	$(CC) $(CFLAGS) -c -o $@ $<

$(OBJDIR):
	mkdir -p $(OBJDIR)

$(LIBDIR):
	mkdir -p $(LIBDIR)

# Dependencies
$(OBJDIR)/rs232.o: rs232.c rs232.h

clean:
	rm -rf $(OBJDIR) $(TARGET)
