1######################################################################## 2# $Id$ 3# Copyright 2009 Aplix Corporation. All rights reserved. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# http://www.apache.org/licenses/LICENSE-2.0 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13######################################################################## 14 15UNAME = $(shell uname) 16INCDIRS = $(OBJDIR) 17SRCDIR = src 18DOCDIR = doc 19EXAMPLESDIR = examples 20OBJDIR = obj 21 22######################################################################## 23# Linux configuration 24# 25ifneq (,$(filter Linux%, $(UNAME))) 26 27CFLAGS = -g -Wall -Werror -O0 $(patsubst %, -I%, $(INCDIRS)) 28OBJSUFFIX = .o 29EXESUFFIX = 30#LIBS = -lefence 31OBJOPTION = -o 32EXEOPTION = -o 33 34else 35######################################################################## 36# Darwin configuration 37# 38ifneq (,$(filter Darwin%, $(UNAME))) 39 40CFLAGS = -g -Wall -Werror -O2 $(patsubst %, -I%, $(INCDIRS)) 41OBJSUFFIX = .o 42EXESUFFIX = 43OBJOPTION = -o 44# The -o in the following line has a space after it, which must not be removed. 45EXEOPTION = -o 46 47else 48######################################################################## 49# Windows (cygwin but using MS compiler) configuration 50# 51# this is messy - should probably use vcvars.bat 52ifneq (,$(filter CYGWIN%, $(UNAME))) 53VISUALSTUDIODIR = $(wildcard /cygdrive/c/Program*Files/Microsoft*Visual*Studio*8) 54SDKDIR = $(wildcard /cygdrive/c/Program*Files/Microsoft*SDKs/Windows/*/Lib) 55ifeq (,$(VISUALSTUDIODIR)) 56VISUALSTUDIODIR = $(wildcard /cygdrive/c/Program\ Files\ */Microsoft*Visual*Studio*10*) 57endif 58ifeq (,$(VISUALSTUDIODIR)) 59VISUALSTUDIODIR = $(wildcard /cygdrive/c/Program\ Files\ */Microsoft*Visual*Studio*11*) 60endif 61# this is revelvant for vs2012 and windows 8 - sdk location has changed 62ifeq (,$(SDKDIR)) 63SDKDIR = $(wildcard /cygdrive/c/Program\ Files\ */Windows*Kits) 64endif 65 66ifeq (,$(VISUALSTUDIODIR)) 67$(error Could not find MS Visual Studio) 68else 69WINVISUALSTUDIODIR = $(shell cygpath -w '$(VISUALSTUDIODIR)') 70WINSDKDIR = $(shell cygpath -w '$(SDKDIR)') 71 72#$(error $(VISUALSTUDIODIR)) 73 74CC = \ 75 Lib='$(WINVISUALSTUDIODIR)\VC\LIB;$(WINVISUALSTUDIODIR)\VC\PlatformSDK\Lib;$(WINSDKDIR)' \ 76 PATH='$(VISUALSTUDIODIR)/Common7/IDE:$(VISUALSTUDIODIR)/VC/BIN:$(VISUALSTUDIODIR)/Common7/Tools:$(VISUALSTUDIODIR)/SDK/v2.0/bin:$(VISUALSTUDIODIR)/8.0/Lib/win8/um/x86:'$$PATH \ 77 Include='$(WINVISUALSTUDIODIR)\VC\INCLUDE;$(WINVISUALSTUDIODIR)\VC\PlatformSDK\Include' \ 78 cl 79endif 80 81CFLAGS = /nologo /WX /W3 /wd4996 /Zi /O2 $(patsubst %, /I%, $(INCDIRS)) 82OBJSUFFIX = .obj 83EXESUFFIX = .exe 84OBJOPTION = /Fo 85EXEOPTION = /Fe 86 87endif 88endif 89endif 90 91######################################################################## 92# Common makefile 93# 94WIDLPROC = $(OBJDIR)/widlproc$(EXESUFFIX) 95DTD = $(OBJDIR)/widlprocxml.dtd 96 97ALL = $(WIDLPROC) $(DTD) 98all : $(ALL) 99 100SRCS = \ 101 comment.c \ 102 lex.c \ 103 main.c \ 104 misc.c \ 105 node.c \ 106 parse.c \ 107 process.c 108 109OBJS = $(patsubst %.c, $(OBJDIR)/%$(OBJSUFFIX), $(SRCS)) 110$(WIDLPROC) : $(OBJS) 111 $(CC) $(CFLAGS) $(EXEOPTION)$@ $^ $(LIBS) 112 113$(OBJDIR)/%$(OBJSUFFIX) : $(SRCDIR)/%.c 114 mkdir -p $(dir $@) 115 $(CC) $(CFLAGS) $(OBJOPTION)$@ -c $< 116 117$(OBJDIR)/%.d : $(SRCDIR)/%.c 118 mkdir -p $(dir $@) 119 cc $(patsubst %, -I%, $(INCDIRS)) -MM -MG -MT $(patsubst %.d, %$(OBJSUFFIX), $@) $< | sed '$(patsubst %, s| \(%\)| $(OBJDIR)/\1|;, $(AUTOGENHEADERS))' >$@ 120 121include $(patsubst %.c, $(OBJDIR)/%.d, $(SRCS)) 122 123 124$(DTD) : $(DOCDIR)/htmltodtd.xsl $(DOCDIR)/widlproc.html 125 xsltproc -html $^ >$@ 126 127clean : 128 rm -f $(ALL) $(OBJS) 129 130veryclean : 131 rm -rf $(OBJDIR) 132 133SVNFILES = $(shell test -d .svn && svn info -R . | sed -n 's/^Path: \(.*\)$$/\1/p') 134SVNBRANCH = $(shell test -d .svn && svn info . | sed -n 's|^URL:.*/\([^/]*\)$$|\1|p') 135SVNREV = $(shell test -d .svn && svn info -R . | sed -n 's/^Last Changed Rev: \([0-9][0-9]*\)$$/\1/p' | sort -g | tail -1) 136 137SVNLOG = history 138$(SVNLOG) : $(SVNFILES) 139 svn log -vrHEAD:311 >$@ 140 141zip : $(OBJDIR)/widlproc-$(SVNBRANCH)$(SVNREV).zip 142$(OBJDIR)/widlproc-$(SVNBRANCH)$(SVNREV).zip : $(WIDLPROC) $(DTD) $(DOCDIR)/widlproc.html $(SRCDIR)/widlprocxmltohtml.xsl Makefile $(SVNLOG) 143 rm -f $@ 144 zip -j $@ $^ -x Makefile 145 zip $@ examples/*.widl examples/*.css examples/Makefile examples/README examples/*.xsl examples/*.html 146 147srczip : widlproc-src-$(SVNBRANCH)$(SVNREV).zip 148 149widlproc-src-%.zip : $(SVNFILES) $(SVNLOG) 150 zip $@ $^ 151 152examples : 153 $(MAKE) -C examples SRCDIR=../src OBJDIR=../obj EXAMPLESOBJDIR=../obj/examples 154 155test : $(OBJS) 156 $(MAKE) -C test SRCDIR=../src OBJDIR=../obj 157 158.DELETE_ON_ERROR: 159