forked from dontcallmedom/widlproc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
141 lines (114 loc) · 4.13 KB
/
Makefile
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
########################################################################
# $Id$
# Copyright 2009 Aplix Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
########################################################################
UNAME = $(shell uname)
INCDIRS = $(OBJDIR)
SRCDIR = src
DOCDIR = doc
EXAMPLESDIR = examples
OBJDIR = obj
########################################################################
# Linux configuration
#
ifneq (,$(filter Linux%, $(UNAME)))
CFLAGS = -g -Wall -Werror -O0 $(patsubst %, -I%, $(INCDIRS))
OBJSUFFIX = .o
EXESUFFIX =
#LIBS = -lefence
OBJOPTION = -o
EXEOPTION = -o
else
########################################################################
# Darwin configuration
#
ifneq (,$(filter Darwin%, $(UNAME)))
CFLAGS = -g -Wall -Werror -O2 $(patsubst %, -I%, $(INCDIRS))
OBJSUFFIX = .o
EXESUFFIX =
OBJOPTION = -o
# The -o in the following line has a space after it, which must not be removed.
EXEOPTION = -o
else
########################################################################
# Windows (cygwin but using MS compiler) configuration
#
ifneq (,$(filter CYGWIN%, $(UNAME)))
VISUALSTUDIODIR = $(wildcard /cygdrive/c/Program*Files/Microsoft*Visual*Studio*8)
ifeq (,$(VISUALSTUDIODIR))
$(error Could not find MS Visual Studio)
else
WINVISUALSTUDIODIR = $(shell cygpath -w '$(VISUALSTUDIODIR)')
CC = \
Lib='$(WINVISUALSTUDIODIR)\VC\LIB;$(WINVISUALSTUDIODIR)\VC\PlatformSDK\Lib' \
PATH='$(VISUALSTUDIODIR)/Common7/IDE:$(VISUALSTUDIODIR)/VC/BIN:$(VISUALSTUDIODIR)/Common7/Tools:$(VISUALSTUDIODIR)/SDK/v2.0/bin:'$$PATH \
Include='$(WINVISUALSTUDIODIR)\VC\INCLUDE;$(WINVISUALSTUDIODIR)\VC\PlatformSDK\Include' \
cl
endif
CFLAGS = /nologo /WX /W3 /wd4996 /Zi /O2 $(patsubst %, /I%, $(INCDIRS))
OBJSUFFIX = .obj
EXESUFFIX = .exe
OBJOPTION = /Fo
EXEOPTION = /Fe
endif
endif
endif
########################################################################
# Common makefile
#
WIDLPROC = $(OBJDIR)/widlproc$(EXESUFFIX)
DTD = $(OBJDIR)/widlprocxml.dtd
ALL = $(WIDLPROC) $(DTD)
all : $(ALL)
SRCS = \
comment.c \
lex.c \
main.c \
misc.c \
node.c \
parse.c \
process.c
OBJS = $(patsubst %.c, $(OBJDIR)/%$(OBJSUFFIX), $(SRCS))
$(WIDLPROC) : $(OBJS)
$(CC) $(CFLAGS) $(EXEOPTION)$@ $^ $(LIBS)
$(OBJDIR)/%$(OBJSUFFIX) : $(SRCDIR)/%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(OBJOPTION)$@ -c $<
$(OBJDIR)/%.d : $(SRCDIR)/%.c
mkdir -p $(dir $@)
cc $(patsubst %, -I%, $(INCDIRS)) -MM -MG -MT $(patsubst %.d, %$(OBJSUFFIX), $@) $< | sed '$(patsubst %, s| \(%\)| $(OBJDIR)/\1|;, $(AUTOGENHEADERS))' >$@
include $(patsubst %.c, $(OBJDIR)/%.d, $(SRCS))
$(DTD) : $(DOCDIR)/htmltodtd.xsl $(DOCDIR)/widlproc.html
xsltproc -html $^ >$@
clean :
rm -f $(ALL) $(OBJS)
veryclean :
rm -rf $(OBJDIR)
SVNFILES = $(shell test -d .svn && svn info -R . | sed -n 's/^Path: \(.*\)$$/\1/p')
SVNBRANCH = $(shell test -d .svn && svn info . | sed -n 's|^URL:.*/\([^/]*\)$$|\1|p')
SVNREV = $(shell test -d .svn && svn info -R . | sed -n 's/^Last Changed Rev: \([0-9][0-9]*\)$$/\1/p' | sort -g | tail -1)
SVNLOG = history
$(SVNLOG) : $(SVNFILES)
svn log -vrHEAD:311 >$@
zip : $(OBJDIR)/widlproc-$(SVNBRANCH)$(SVNREV).zip
$(OBJDIR)/widlproc-$(SVNBRANCH)$(SVNREV).zip : $(WIDLPROC) $(DTD) $(DOCDIR)/widlproc.html $(SRCDIR)/widlprocxmltohtml.xsl Makefile $(SVNLOG)
rm -f $@
zip -j $@ $^ -x Makefile
zip $@ examples/*.widl examples/*.css examples/Makefile examples/README examples/*.xsl examples/*.html
srczip : widlproc-src-$(SVNBRANCH)$(SVNREV).zip
widlproc-src-%.zip : $(SVNFILES) $(SVNLOG)
zip $@ $^
examples :
$(MAKE) -C examples SRCDIR=../src OBJDIR=../obj EXAMPLESOBJDIR=../obj/examples
test : $(OBJS)
$(MAKE) -C test SRCDIR=../src OBJDIR=../obj
.DELETE_ON_ERROR: