SOURCE = svgtiny.c colors.c
HDRS = svgtiny.h
-.PHONY: all install clean
-
-CFLAGS = -std=c99 -g -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
+CFLAGS = -std=c99 -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations \
- -Wnested-externs -Winline -Wno-cast-align \
- `xml2-config --cflags`
-LIBS = `xml2-config --libs`
+ -Wnested-externs -Winline -Wno-cast-align
ARFLAGS = cr
-OBJS = $(SOURCE:.c=.o)
+ifeq ($(TARGET),riscos)
+GCCSDK_INSTALL_CROSSBIN ?= /home/riscos/cross/bin
+GCCSDK_INSTALL_ENV ?= /home/riscos/env
+CC = $(GCCSDK_INSTALL_CROSSBIN)/gcc
+AR = $(GCCSDK_INSTALL_CROSSBIN)/ar
+CFLAGS += -Driscos -mpoke-function-name -I$(GCCSDK_INSTALL_ENV)/include \
+ -I$(GCCSDK_INSTALL_ENV)/include/libxml2
+LIBS = -L$(GCCSDK_INSTALL_ENV)/lib -lxml2 -lz
+EXEEXT = ,ff8
+else
+CFLAGS += -g `xml2-config --cflags` -fgnu89-inline
+LIBS = `xml2-config --libs`
+endif
-all: libsvgtiny.a svgtiny_test$(EXEEXT)
+ifeq ($(TARGET),)
+OBJDIR = objects
+LIBDIR = lib
+BINDIR = bin
+else
+OBJDIR = $(TARGET)-objects
+LIBDIR = $(TARGET)-lib
+BINDIR = $(TARGET)-bin
+endif
-libsvgtiny.a: $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
+OBJS = $(addprefix $(OBJDIR)/, $(SOURCE:.c=.o))
-svgtiny_test$(EXEEXT): svgtiny_test.c libsvgtiny.a
- $(CC) $(CFLAGS) $(LIBS) -o $@ $^
+.PHONY: all install clean
-clean:
- -rm *.o libsvgtiny.a svgtiny_test$(EXEEXT) colors.c
+all: $(LIBDIR)/libsvgtiny.a $(BINDIR)/svgtiny_test$(EXEEXT) colors.c
-colors.c: colors.gperf
- gperf --output-file=$@ $<
+$(LIBDIR)/libsvgtiny.a: $(OBJS)
+ @echo " LINK:" $@
+ @mkdir -p $(LIBDIR)
+ @$(AR) $(ARFLAGS) $@ $(OBJS)
+
+$(BINDIR)/svgtiny_test$(EXEEXT): svgtiny_test.c $(LIBDIR)/libsvgtiny.a
+ @echo " LINK:" $@
+ @mkdir -p $(BINDIR)
+ @$(CC) $(CFLAGS) $(LIBS) -o $@ $^
+
+$(OBJDIR)/%.o: %.c $(HDRS)
+ @echo " COMPILE:" $<
+ @mkdir -p $(OBJDIR)
+ @$(CC) $(CFLAGS) -c -o $@ $<
+
+%.c: %.gperf
+ @echo " GPERF:" $<
+ @gperf --output-file=$@ $<
+
+clean:
+ -rm $(OBJS) $(LIBDIR)/libsvgtiny.a $(BINDIR)/svgtiny_test$(EXEEXT) colors.c
-.c.o: $(HDRS)
- $(CC) $(CFLAGS) -c -o $@ $<