summaryrefslogtreecommitdiff
path: root/objective-c/config/Make.rules
blob: 394a11a170047c40ee0515801761aa9e03064b47 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# **********************************************************************
#
# Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************

#
# Select an installation base directory. The directory will be created
# if it does not exist.
#
prefix			?= /opt/Ice-$(VERSION)

#
# Define OPTIMIZE as yes if you want to build with
# optimization. Otherwise Ice is build with debug information.
#
#OPTIMIZE		= yes

#
# The build architectures for gcc/llvm based builds. The format of
# these build flags are OS dependent. For example, under OS X to
# build binaries which support both i386 and x86_64 you would use
# "-arch i386 -arch x86_64".  The default is OS version dependent. Be
# aware that this value may conflict with the setting of LP64 above.
#
#OBJCARCHFLAGS		= -arch i386 -arch x86_64

# ----------------------------------------------------------------------
# Don't change anything below this line!
# ----------------------------------------------------------------------

#
# Common definitions
#
ice_language     = objective-c
slice_translator = slice2objc

ifeq ($(shell test -f $(top_srcdir)/config/Make.common.rules && echo 0),0)
    include $(top_srcdir)/config/Make.common.rules
else
    include $(top_srcdir)/../config/Make.common.rules
endif

bindir	= $(top_srcdir)/bin
ifdef ice_src_dist
    libdir      = $(top_srcdir)/lib
    includedir	= $(top_srcdir)/include
else
    libdir	= $(ice_dir)/$(libsubdir)
    testlibdir  = $(top_srcdir)/lib
    includedir	= $(ice_dir)/include
endif
headerdir	= $(top_srcdir)/include

install_includedir  := $(prefix)/include/objc
install_libdir	:= $(prefix)/$(libsubdir)
install_bindir	:= $(prefix)/$(binsubdir)

#
# Platform specific definitions
#
include	 $(top_srcdir)/config/Make.rules.$(UNAME)

ICECPPFLAGS		= -I$(slicedir)
SLICE2OBJCFLAGS	= $(ICECPPFLAGS)
FLEXFLAGS		=
BISONFLAGS		= -dvt
CPPFLAGS		+= -I$(includedir)
LDFLAGS			= $(OBJCFLAGS) $(ARCFLAGS) -L$(libdir)
ifndef ice_src_dist
    LDFLAGS += -L$(testlibdir)
endif

ifdef ice_src_dist
    ifeq ($(ice_cpp_dir), $(ice_dir)/cpp)
        SLICE2OBJC = $(ice_cpp_dir)/bin/slice2objc
    else
        SLICE2OBJC = $(ice_cpp_dir)/$(binsubdir)/slice2objc
    endif
else
    SLICE2OBJC = $(ice_dir)/$(binsubdir)/slice2objc
endif

# This cannot use .cpp:.o as we have multiple types of source files.

EVERYTHING		= all clean install
EVERYTHING_EXCEPT_ALL   = clean install

.SUFFIXES:
.SUFFIXES:		.mm .m .o .cpp  .c

ifneq ($(SLICE_OBJS),)
-include $(addprefix .depend/, $(SLICE_OBJS:.o=.ice.d))
endif

ifneq ($(OBJS),)
-include $(addprefix .depend/, $(OBJS:.o=.d))
endif

ifeq ($(wildcard .depend/*.d),)
ifneq ($(OBJCXX_OBJS),)
$(OBJS): $(SLICE_OBJS:.o=.m) $(OBJC_OBJS:.o=.m) $(OBJCXX_OBJS:.o=.mm)
else
$(OBJS): $(OBJS:.o=.m)
endif
endif

all:: $(TARGETS)

.m.o:
	$(CC) -c $(ARCFLAGS) $(CPPFLAGS) $(OBJCFLAGS) $<
	@mkdir -p .depend
	@$(CXX) -DMAKEDEPEND -MM $(CPPFLAGS) $< > .depend/$(*F).d

.mm.o:
	$(CXX) -c $(ARCFLAGS) $(CPPFLAGS) $(OBJCFLAGS) $<
	@mkdir -p .depend
	@$(CXX) -DMAKEDEPEND -MM $(CPPFLAGS) $< > .depend/$(*F).d

$(HDIR)/%F.h: $(SDIR)/%F.ice $(SLICE2OBJC)
	rm -f $(HDIR)/$(*F)F.h $(*F)F.m
	$(SLICE2OBJC) $(SLICE2OBJCFLAGS) $<
	mv $(*F)F.h $(HDIR)
	@touch $(*F)F.m
	@mkdir -p .depend
	@$(SLICE2OBJC) $(SLICE2OBJCFLAGS) --depend $< | sed 's/\(.*: \\\)/\$$(HDIR)\/\1/' > .depend/$(*F)F.ice.d

$(HDIR)/%.h %.m: $(SDIR)/%.ice $(SLICE2OBJC)
	rm -f $(HDIR)/$(*F).h $(*F).m
	$(SLICE2OBJC) $(SLICE2OBJCFLAGS) $<
	mv $(*F).h $(HDIR)
	@touch $(*F).m
	@mkdir -p .depend
	@$(SLICE2OBJC) $(SLICE2OBJCFLAGS) --depend $< | sed 's/\(.*: \\\)/\$$(HDIR)\/\1/' > .depend/$(*F).ice.d

%.h %.m: %.ice $(SLICE2OBJC)
	rm -f $(*F).h $(*F).m
	$(SLICE2OBJC) $(SLICE2OBJCFLAGS) $<
	@touch $(*F).m
	@mkdir -p .depend
	@$(SLICE2OBJC) $(SLICE2OBJCFLAGS) --depend $(*F).ice > .depend/$(*F).ice.d

%.h %.m: %.y
	rm -f $(*F).h $(*F).c
	bison $(BISONFLAGS) $<
	mv $(*F).tab.c $(*F).m
	mv $(*F).tab.h $(*F).h
	rm -f $(*F).output

%.m: %.l
	flex $(FLEXFLAGS) $<
	rm -f $@
	cat lex.yy.c >> $@
	rm -f lex.yy.c

clean::
	-rm -f $(TARGETS)
	-rm -f core *.o *.bak
	-rm -rf .depend

ifneq ($(SLICE_OBJS),)
clean::
	rm -f $(addsuffix .m, $(basename $(notdir $(SLICE_OBJS))))
	rm -f $(addsuffix .h, $(basename $(notdir $(SLICE_OBJS))))
endif

ifneq ($(HDIR),)
clean::
	rm -f $(addprefix $(HDIR)/, $(addsuffix .h, $(basename $(SLICE_OBJS))))
endif

install::