summaryrefslogtreecommitdiff
path: root/makefile
blob: 89b83ae844b2116fd83f881ac522c9de50dceb71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#
# This file is part of Libsvgtiny
# Licensed under the MIT License,
#                http://opensource.org/licenses/mit-license.php
# Copyright 2008 James Bursa <james@semichrome.net>
#

SOURCE = svgtiny.c svgtiny_gradient.c svgtiny_list.c colors.c
HDRS = svgtiny.h svgtiny_internal.h

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
ARFLAGS = cr
INSTALL = install

ifeq ($(TARGET),riscos)
  GCCSDK_INSTALL_CROSSBIN ?= /home/riscos/cross/bin
  GCCSDK_INSTALL_ENV ?= /home/riscos/env
  CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
  AR := $(wildcard $(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
  ifneq (,$(findstring arm-unknown-riscos-gcc,$(CC)))
    EXEEXT := ,e1f
    SUBTARGET := -elf-
  else
    EXEEXT := ,ff8
    SUBTARGET := -aof-
  endif
  PREFIX = $(GCCSDK_INSTALL_ENV)
else
  CFLAGS += -g `xml2-config --cflags` -fgnu89-inline
  LIBS = `xml2-config --libs`
  PREFIX = /usr/local
endif

OBJDIR = $(TARGET)$(SUBTARGET)objects
LIBDIR = $(TARGET)$(SUBTARGET)lib
BINDIR = $(TARGET)$(SUBTARGET)bin

OBJS = $(addprefix $(OBJDIR)/, $(SOURCE:.c=.o))

.PHONY: all install clean

all: $(LIBDIR)/libsvgtiny.a $(BINDIR)/svgtiny_test$(EXEEXT) colors.c

$(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=$@ $<

install: $(LIBDIR)/libsvgtiny.a
	$(INSTALL) -t $(PREFIX)/lib $(LIBDIR)/libsvgtiny.a
	$(INSTALL) -t $(PREFIX)/include svgtiny.h

clean:
	-rm $(OBJS) $(LIBDIR)/libsvgtiny.a $(BINDIR)/svgtiny_test$(EXEEXT) colors.c