summaryrefslogtreecommitdiff
path: root/binary/src/Makefile
blob: 6522151509b71b8afbd4be9694caf4fb99da51c5 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
ROOT = ..

XPTDIR		= $(ROOT)/components/$(ABI)/
SODIR		= $(ROOT)/components/$(ABI)/
OBJDIR		= $(ABI)/

MODULE		= $(SODIR)dactyl

XPIDLSRCS	= \
		dactylIUtils.idl \
		$(NULL)

CPPSRCS		= \
		dactylModule.cpp \
		dactylUtils.cpp \
		mozJSLoaderUtils.cpp \
		subscriptLoader.cpp \
		$(NULL)

GECKO_DEFINES  = -DMOZILLA_STRICT_API

GECKO_INCLUDES = -I$(ABI)/			\
		 -I$(GECKO_SDK_PATH)		\
		 -I$(GECKO_SDK_PATH)/idl	\
		 -I$(GECKO_SDK_PATH)/include

GECKO_LDFLAGS =  -L$(GECKO_SDK_PATH)/bin \
		 -L$(GECKO_SDK_PATH)/lib \
		 -lxpcomglue_s	\
		 -lxpcom	\
		 -lnspr4	\
		 -shared	\
		 $(NULL)

ifeq "$(shell uname -s)" "Darwin"
	GECKO_LDFLAGS += -undefined dynamic_lookup
endif

include $(ROOT)/config.mk
sinclude $(ROOT)/config.local.mk

CPPFLAGS += $(EXCPPFLAGS)

XPTS = $(XPIDLSRCS:%.idl=$(XPTDIR)%.xpt)
OBJS = $(CPPSRCS:%.cpp=$(OBJDIR)%.o)
HEADERS = $(XPIDLSRCS:%.idl=$(ABI)/%.h)


all: build

dirs: $(XPTDIR) $(SODIR) $(OBJDIR)

depend: .depend

module: dirs $(MODULE).so

dll: dirs $(MODULE).dll

xpts: $(XPTS)

build: dirs module xpts

clean:
	rm $(MODULE).so


$(OBJS): $(HEADERS)

$(ABI)/%.h: %.idl
	$(IDL_H) $@ $(GECKO_INCLUDES) $<

$(XPTDIR)%.xpt: %.idl
	$(IDL_XPT) $@ $(GECKO_INCLUDES) $<

_CPPFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(GECKO_DEFINES) $(GECKO_INCLUDES) $(DEFINES)

$(OBJDIR)%.o: %.cpp Makefile
	$(CPP)$@ -c $(_CPPFLAGS) $<

.depend: $(CPPSRCS) Makefile
	$(MKDEP) $(_CPPFLAGS) $(CPPSRCS) | $(SED) 's;^[^ ];$(OBJDIR)&;' >.depend

$(MODULE).so: $(OBJS)
	$(LINK) -o $@ $(OBJS) $(LDFLAGS) $(GECKO_LDFLAGS)
	chmod +x $@

$(MODULE).dll: $(OBJS)
	$(LINK)$@ $(GECKO_LDFLAGS) $(OBJS)

$(sort $(XPTDIR) $(SODIR) $(OBJDIR)):
	mkdir -p $@
.PHONY: module xpts build clean all depend

sinclude .depend