summaryrefslogtreecommitdiffstats
path: root/lib/skin_parser/Makefile
blob: c4dd57dcac5411ab3e07c4f99a95446868c927f9 (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
76
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
#

ifndef V
SILENT = @
endif

CC ?= gcc
AR ?= ar
OUTPUT=libskin_parser
TARGET_DIR ?= ./

ifeq ($(OS),Windows_NT)
mkdir = if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
rm = if exist $(subst /,\,$(1)) del /q /s $(subst /,\,$(1))
else
mkdir = mkdir -p $(1)
rm = rm -rf $(1)
endif

CPPDEFINES := $(shell echo foo | $(CC) -dM -E -)

# construct build directory if BUILDDIR is not set.
BUILDDIR ?= $(TARGET_DIR)build

CFLAGS += -D__PCTOOL__
ifdef RBARCH
CFLAGS += -arch $(RBARCH)
OBJDIR = $(BUILDDIR)/$(RBARCH)/
else
OBJDIR = $(BUILDDIR)/
endif

# input files
SOURCES := skin_buffer.c skin_debug.c skin_parser.c skin_scan.c tag_table.c
OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(SOURCES)))

all: $(OUTPUT).a

$(OBJDIR)%.o: %.c
	$(info CC $<)
	$(SILENT)$(call mkdir,$(dir $@))
	$(SILENT)$(CC) $(CFLAGS) -c -o $@ $<

ifeq ($(findstring Darwin,$(TARGETPLATFORM)),Darwin)
# some trickery to build ppc and i386 from a single call
$(OUTPUT).a: $(TARGET_DIR)$(OUTPUT)i386.a $(TARGET_DIR)$(OUTPUT)ppc.a
	$(info lipo $(TARGET_DIR)$@)
	$(SILENT)$(call rm,$(TARGET_DIR)$(OUTPUT))
	$(SILENT)lipo -create $(TARGET_DIR)$(OUTPUT)ppc.a $(TARGET_DIR)$(OUTPUT)i386.a -output $(TARGET_DIR)$(OUTPUT).a

ifneq ($(RBARCH),)
$(OUTPUT)$(RBARCH).a: $(OBJS)
	$(info AR $@)
	$(SILENT)$(AR) ruc $(TARGET_DIR)$@ $^
else
$(TARGET_DIR)$(OUTPUT)i386.a:
	make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) $(OUTPUT)i386.a

$(TARGET_DIR)$(OUTPUT)ppc.a:
	make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) $(OUTPUT)ppc.a
endif
else
$(OUTPUT).a: $(OBJS)
	$(info AR $@)
	$(SILENT)$(AR) ruc $(TARGET_DIR)$@ $^
endif

clean:
	$(call rm,$(OBJS) $(OUTPUT) $(TARGET_DIR)$(OUTPUT)*.a)