1 | # -*- Mode: makefile -*- |
---|
2 | # |
---|
3 | # The contents of this file are subject to the Netscape Public |
---|
4 | # License Version 1.1 (the "License"); you may not use this file |
---|
5 | # except in compliance with the License. You may obtain a copy of |
---|
6 | # the License at http://www.mozilla.org/NPL/ |
---|
7 | # |
---|
8 | # Software distributed under the License is distributed on an "AS |
---|
9 | # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
---|
10 | # implied. See the License for the specific language governing |
---|
11 | # rights and limitations under the License. |
---|
12 | # |
---|
13 | # The Original Code is Mozilla Communicator client code, released |
---|
14 | # March 31, 1998. |
---|
15 | # |
---|
16 | # The Initial Developer of the Original Code is Netscape |
---|
17 | # Communications Corporation. Portions created by Netscape are |
---|
18 | # Copyright (C) 1998-1999 Netscape Communications Corporation. All |
---|
19 | # Rights Reserved. |
---|
20 | # |
---|
21 | # Contributor(s): |
---|
22 | # Michael Ang <mang@subcarrier.org> |
---|
23 | # |
---|
24 | # Alternatively, the contents of this file may be used under the |
---|
25 | # terms of the GNU Public License (the "GPL"), in which case the |
---|
26 | # provisions of the GPL are applicable instead of those above. |
---|
27 | # If you wish to allow use of your version of this file only |
---|
28 | # under the terms of the GPL and not to allow others to use your |
---|
29 | # version of this file under the NPL, indicate your decision by |
---|
30 | # deleting the provisions above and replace them with the notice |
---|
31 | # and other provisions required by the GPL. If you do not delete |
---|
32 | # the provisions above, a recipient may use your version of this |
---|
33 | # file under either the NPL or the GPL. |
---|
34 | # |
---|
35 | |
---|
36 | # |
---|
37 | # JSRef GNUmake makefile rules |
---|
38 | # |
---|
39 | |
---|
40 | ifdef USE_MSVC |
---|
41 | LIB_OBJS = $(addprefix $(OBJDIR)/, $(LIB_CFILES:.c=.obj)) |
---|
42 | PROG_OBJS = $(addprefix $(OBJDIR)/, $(PROG_CFILES:.c=.obj)) |
---|
43 | else |
---|
44 | LIB_OBJS = $(addprefix $(OBJDIR)/, $(LIB_CFILES:.c=.o)) |
---|
45 | LIB_OBJS += $(addprefix $(OBJDIR)/, $(LIB_ASFILES:.s=.o)) |
---|
46 | PROG_OBJS = $(addprefix $(OBJDIR)/, $(PROG_CFILES:.c=.o)) |
---|
47 | endif |
---|
48 | |
---|
49 | CFILES = $(LIB_CFILES) $(PROG_CFILES) |
---|
50 | OBJS = $(LIB_OBJS) $(PROG_OBJS) |
---|
51 | |
---|
52 | ifdef USE_MSVC |
---|
53 | # TARGETS = $(LIBRARY) # $(PROGRAM) not supported for MSVC yet |
---|
54 | TARGETS += $(SHARED_LIBRARY) $(PROGRAM) # it is now |
---|
55 | else |
---|
56 | TARGETS += $(LIBRARY) $(SHARED_LIBRARY) $(PROGRAM) |
---|
57 | endif |
---|
58 | |
---|
59 | all: |
---|
60 | +$(LOOP_OVER_PREDIRS) |
---|
61 | ifneq "$(strip $(TARGETS))" "" |
---|
62 | $(MAKE) -f Makefile.ref $(TARGETS) |
---|
63 | endif |
---|
64 | +$(LOOP_OVER_DIRS) |
---|
65 | |
---|
66 | $(OBJDIR)/%: %.c |
---|
67 | @$(MAKE_OBJDIR) |
---|
68 | $(CC) -o $@ $(CFLAGS) $*.c $(LDFLAGS) |
---|
69 | |
---|
70 | # This rule must come before the rule with no dep on header |
---|
71 | $(OBJDIR)/%.o: %.c %.h |
---|
72 | @$(MAKE_OBJDIR) |
---|
73 | $(CC) -o $@ -c $(CFLAGS) $*.c |
---|
74 | |
---|
75 | |
---|
76 | $(OBJDIR)/%.o: %.c |
---|
77 | @$(MAKE_OBJDIR) |
---|
78 | $(CC) -o $@ -c $(CFLAGS) $*.c |
---|
79 | |
---|
80 | $(OBJDIR)/%.o: %.s |
---|
81 | @$(MAKE_OBJDIR) |
---|
82 | $(AS) -o $@ $(ASFLAGS) $*.s |
---|
83 | |
---|
84 | # This rule must come before rule with no dep on header |
---|
85 | $(OBJDIR)/%.obj: %.c %.h |
---|
86 | @$(MAKE_OBJDIR) |
---|
87 | $(CC) -Fo$(OBJDIR)/ -c $(CFLAGS) $(JSDLL_CFLAGS) $*.c |
---|
88 | |
---|
89 | $(OBJDIR)/%.obj: %.c |
---|
90 | @$(MAKE_OBJDIR) |
---|
91 | $(CC) -Fo$(OBJDIR)/ -c $(CFLAGS) $(JSDLL_CFLAGS) $*.c |
---|
92 | |
---|
93 | $(OBJDIR)/js.obj: js.c |
---|
94 | @$(MAKE_OBJDIR) |
---|
95 | $(CC) -Fo$(OBJDIR)/ -c $(CFLAGS) $< |
---|
96 | |
---|
97 | ifeq ($(OS_ARCH),OS2) |
---|
98 | $(LIBRARY): $(LIB_OBJS) |
---|
99 | $(AR) $@ $? $(AR_OS2_SUFFIX) |
---|
100 | $(RANLIB) $@ |
---|
101 | else |
---|
102 | ifdef USE_MSVC |
---|
103 | $(SHARED_LIBRARY): $(LIB_OBJS) |
---|
104 | link.exe $(LIB_LINK_FLAGS) /base:0x61000000 $(OTHER_LIBS) \ |
---|
105 | /out:"$@" /pdb:none\ |
---|
106 | /implib:"$(OBJDIR)/$(@F:.dll=.lib)" $^ |
---|
107 | else |
---|
108 | $(LIBRARY): $(LIB_OBJS) |
---|
109 | $(AR) rv $@ $? |
---|
110 | $(RANLIB) $@ |
---|
111 | |
---|
112 | $(SHARED_LIBRARY): $(LIB_OBJS) |
---|
113 | $(MKSHLIB) -o $@ $(LIB_OBJS) $(LDFLAGS) $(OTHER_LIBS) |
---|
114 | endif |
---|
115 | endif |
---|
116 | |
---|
117 | # Java stuff |
---|
118 | $(CLASSDIR)/$(OBJDIR)/$(JARPATH)/%.class: %.java |
---|
119 | mkdir -p $(@D) |
---|
120 | $(JAVAC) $(JAVAC_FLAGS) $< |
---|
121 | |
---|
122 | define MAKE_OBJDIR |
---|
123 | if test ! -d $(@D); then rm -rf $(@D); mkdir -p $(@D); fi |
---|
124 | endef |
---|
125 | |
---|
126 | ifdef DIRS |
---|
127 | LOOP_OVER_DIRS = \ |
---|
128 | @for d in $(DIRS); do \ |
---|
129 | if test -d $$d; then \ |
---|
130 | set -e; \ |
---|
131 | echo "cd $$d; $(MAKE) -f Makefile.ref $@"; \ |
---|
132 | cd $$d; $(MAKE) -f Makefile.ref $@; cd ..; \ |
---|
133 | set +e; \ |
---|
134 | else \ |
---|
135 | echo "Skipping non-directory $$d..."; \ |
---|
136 | fi; \ |
---|
137 | done |
---|
138 | endif |
---|
139 | |
---|
140 | ifdef PREDIRS |
---|
141 | LOOP_OVER_PREDIRS = \ |
---|
142 | @for d in $(PREDIRS); do \ |
---|
143 | if test -d $$d; then \ |
---|
144 | set -e; \ |
---|
145 | echo "cd $$d; $(MAKE) -f Makefile.ref $@"; \ |
---|
146 | cd $$d; $(MAKE) -f Makefile.ref $@; cd ..; \ |
---|
147 | set +e; \ |
---|
148 | else \ |
---|
149 | echo "Skipping non-directory $$d..."; \ |
---|
150 | fi; \ |
---|
151 | done |
---|
152 | endif |
---|
153 | |
---|
154 | export: |
---|
155 | +$(LOOP_OVER_PREDIRS) |
---|
156 | mkdir -p $(DIST)/include $(DIST)/lib $(DIST)/bin |
---|
157 | ifneq "$(strip $(HFILES))" "" |
---|
158 | $(CP) $(HFILES) $(DIST)/include |
---|
159 | endif |
---|
160 | ifneq "$(strip $(LIBRARY))" "" |
---|
161 | $(CP) $(LIBRARY) $(DIST)/lib |
---|
162 | endif |
---|
163 | ifneq "$(strip $(JARS))" "" |
---|
164 | $(CP) $(JARS) $(DIST)/lib |
---|
165 | endif |
---|
166 | ifneq "$(strip $(SHARED_LIBRARY))" "" |
---|
167 | $(CP) $(SHARED_LIBRARY) $(DIST)/lib |
---|
168 | endif |
---|
169 | ifneq "$(strip $(PROGRAM))" "" |
---|
170 | $(CP) $(PROGRAM) $(DIST)/bin |
---|
171 | endif |
---|
172 | +$(LOOP_OVER_DIRS) |
---|
173 | |
---|
174 | clean: |
---|
175 | rm -rf $(OBJS) |
---|
176 | @cd fdlibm; $(MAKE) -f Makefile.ref clean |
---|
177 | |
---|
178 | clobber: |
---|
179 | rm -rf $(OBJS) $(TARGETS) $(DEPENDENCIES) |
---|
180 | @cd fdlibm; $(MAKE) -f Makefile.ref clobber |
---|
181 | |
---|
182 | depend: |
---|
183 | gcc -MM $(CFLAGS) $(LIB_CFILES) |
---|
184 | |
---|
185 | tar: |
---|
186 | tar cvf $(TARNAME) $(TARFILES) |
---|
187 | gzip $(TARNAME) |
---|
188 | |
---|