From: Constantin Kaplinsky Date: Tue, 30 May 2006 06:05:33 +0000 (+0000) Subject: Adapted build scripts for the common/* sub-tree. X-Git-Tag: v0.0.90~384^2~270 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0bb538bf85b60123430a956c181eea8ffbdf79ec;p=tigervnc.git Adapted build scripts for the common/* sub-tree. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@602 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/common/Makefile.in b/common/Makefile.in new file mode 100644 index 00000000..29aa2632 --- /dev/null +++ b/common/Makefile.in @@ -0,0 +1,4 @@ + +SUBDIRS = @ZLIB_DIR@ @JPEG_DIR@ rdr network Xregion rfb + +# followed by boilerplate.mk diff --git a/common/boilerplate.mk b/common/boilerplate.mk new file mode 100644 index 00000000..6792b925 --- /dev/null +++ b/common/boilerplate.mk @@ -0,0 +1,35 @@ + +all:: + @subdirs="$(SUBDIRS)"; for d in $$subdirs; do (cd $$d; $(MAKE) $@) || exit 1; done + +clean:: + @subdirs="$(SUBDIRS)"; for d in $$subdirs; do (cd $$d; $(MAKE) $@) || exit 1; done + +clean:: + rm -f $(program) $(library) *.o + +SHELL = @SHELL@ +top_srcdir = @top_srcdir@ +@SET_MAKE@ +CC = @CC@ +CFLAGS = @CFLAGS@ $(DIR_CFLAGS) +CCLD = $(CC) +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +CXXLD = $(CXX) +CPPFLAGS = @CPPFLAGS@ +DEFS = @DEFS@ +ALL_CPPFLAGS = $(CPPFLAGS) $(DEFS) $(DIR_CPPFLAGS) +LIBS = @LIBS@ +LDFLAGS = @LDFLAGS@ +RANLIB = @RANLIB@ +AR = ar cq + +.SUFFIXES: +.SUFFIXES: .cxx .c .o + +.c.o: + $(CC) $(ALL_CPPFLAGS) $(CFLAGS) -o $@ -c $< + +.cxx.o: + $(CXX) $(ALL_CPPFLAGS) $(CXXFLAGS) -o $@ -c $< diff --git a/common/configure.in b/common/configure.in new file mode 100644 index 00000000..7bbce072 --- /dev/null +++ b/common/configure.in @@ -0,0 +1,138 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(rdr/InStream.h) + +dnl dirty hack to prevent use of -g in CFLAGS and CXXFLAGS +ac_cv_prog_cc_g=no +ac_cv_prog_cxx_g=no + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AC_PROG_RANLIB +AC_PROG_MAKE_SET +AC_LANG_CPLUSPLUS + +case "`(uname -sr) 2>/dev/null`" in +"SunOS 5"*) + SOLARIS=yes + ;; +"Linux"*) + LINUX=yes + ;; +"IRIX 6"*) + X_LIBS="-L/usr/lib32" + ;; +"LynxOS 2"*) + SJLJ_EXCEPTIONS=yes + ;; +esac + +dnl FIXME: Remove duplication between this script and ../unix/configure.in +if test "$GCC" = yes; then + CFLAGS="$CFLAGS -Wall" + if test "$SOLARIS" = yes; then + CFLAGS="$CFLAGS -Wno-unknown-pragmas -Wno-implicit-int" + fi +fi +if test "$GXX" = yes; then + CXXFLAGS="$CXXFLAGS -Wall" + if test "$SOLARIS" = yes; then + CXXFLAGS="$CXXFLAGS -Wno-unknown-pragmas -fpermissive" + fi + if test "$SJLJ_EXCEPTIONS" = yes; then + CXXFLAGS="$CXXFLAGS -fsjlj-exceptions" + fi +fi + +AC_PATH_XTRA + +AC_ARG_WITH(installed-zlib, +[ --with-installed-zlib use the version of zlib which is installed on the + system instead of the one distributed with VNC]) + +if test "$with_installed_zlib" = yes; then + echo "using installed zlib" + ZLIB_LIB=-lz +else + ZLIB_DIR=zlib + ZLIB_INCLUDE='-I$(top_srcdir)/zlib' + ZLIB_LIB='$(top_srcdir)/zlib/libz.a' + echo "configuring zlib..." + (cd zlib; ./configure) + echo "...done configuring zlib" +fi + +AC_SUBST(ZLIB_DIR) +AC_SUBST(ZLIB_INCLUDE) +AC_SUBST(ZLIB_LIB) + +AC_ARG_WITH(installed-jpeg, +[ --with-installed-jpeg use the version of jpeg which is installed on the + system instead of the one distributed with VNC]) + +if test "$with_installed_jpeg" = yes; then + echo "using installed jpeg" + JPEG_LIB=-ljpeg +else + JPEG_DIR=jpeg/build + JPEG_INCLUDE='-I$(top_srcdir)/jpeg' + JPEG_LIB='$(top_srcdir)/jpeg/build/libjpeg.a' + echo "configuring jpeg..." + (mkdir jpeg/build; cd jpeg/build; ../configure) + echo "...done configuring jpeg" +fi + +AC_SUBST(JPEG_DIR) +AC_SUBST(JPEG_INCLUDE) +AC_SUBST(JPEG_LIB) + +AC_CHECK_FUNC(vsnprintf,VSNPRINTF_DEFINE='-DHAVE_VSNPRINTF',VSNPRINTF_DEFINE=) +AC_SUBST(VSNPRINTF_DEFINE) + +AC_CHECK_FUNC(strcasecmp,STRCASECMP_DEFINE='-DHAVE_STRCASECMP', + STRCASECMP_DEFINE=) +AC_SUBST(STRCASECMP_DEFINE) + +AC_CHECK_FUNC(strncasecmp,STRNCASECMP_DEFINE='-DHAVE_STRNCASECMP', + STRNCASECMP_DEFINE=) +AC_SUBST(STRNCASECMP_DEFINE) + +dnl Under Lynx/OS 2.3, we have to link with -lbsd to resolve +dnl gethostbyname, inet_addr, htons etc. Check if it's necessary. +dnl NOTE: Did not want to use AC_SEARCH_LIBS which would add +dnl -lbsd to LIBS. We set INET_LIB instead. +AC_LANG_SAVE +AC_LANG_C +AC_CHECK_FUNC(gethostbyname,INET_LIB_REQ=,INET_LIB_REQ=yes) +if test "$INET_LIB_REQ" = yes; then + AC_CHECK_LIB(bsd,gethostbyname,INET_LIB=-lbsd,INET_LIB=) +fi +AC_LANG_RESTORE +AC_SUBST(INET_LIB) + +AC_MSG_CHECKING(for socklen_t) +AC_TRY_COMPILE( +[#include + #include ], +[socklen_t x; +accept(0, 0, &x);], +AC_MSG_RESULT(yes) +SOCKLEN_T_DEFINE='-DVNC_SOCKLEN_T=socklen_t', +AC_MSG_RESULT(using int) +SOCKLEN_T_DEFINE='-DVNC_SOCKLEN_T=int') +AC_SUBST(SOCKLEN_T_DEFINE) + +BOILERPLATE=boilerplate.mk + +if (sh -c "make --version" 2>/dev/null | grep GNU 2>&1 >/dev/null); then + if sh -c "vncmkdepend" >/dev/null 2>&1; then + BOILERPLATE="$BOILERPLATE:depend.mk" + fi +fi + +AC_OUTPUT(Makefile:Makefile.in:$BOILERPLATE \ + rdr/Makefile:rdr/Makefile.in:$BOILERPLATE \ + network/Makefile:network/Makefile.in:$BOILERPLATE \ + Xregion/Makefile:Xregion/Makefile.in:$BOILERPLATE \ + rfb/Makefile:rfb/Makefile.in:$BOILERPLATE \ +) diff --git a/common/depend.mk b/common/depend.mk new file mode 100644 index 00000000..51d4cd63 --- /dev/null +++ b/common/depend.mk @@ -0,0 +1,76 @@ +# +# C / C++ header dependency stuff +# +# Needs GNU make and vncmkdepend, a hacked version of makedepend + +.SUFFIXES: .d + +CMAKEDEPEND = vncmkdepend +CXXMAKEDEPEND = vncmkdepend + +# +# The recommended method of doing dependency analysis in the GNU make manual +# turns out to be painfully slow. This method is similar but it's +# substantially faster and retains the desirable property that the user doesn't +# need to manually invoke a "make depend" step. +# +# As with the method described in the manual, we generate a separate dependency +# (.d) file for each source file. The .d file records the header files that +# each C or C++ source file includes. Any source file recorded in SRCS or +# CXXSRCS will cause us to try and include the corresponding .d file and GNU +# make then treats each .d file as a target to be remade. +# +# Unlike the manual's method, the rule we provide for making the .d file is +# actually a fake. All it does is record in a temporary file that the .d file +# needs to be remade. But as well as all the .d files, we also try to include +# a file called "depend.phony". This file never exists, but it causes GNU make +# to try and make the target "depend.phony". The rule for depend.phony then +# looks at the temporary files generated by the .d rules and then invokes the +# "omkdepend" program on all of the source files in one go. +# + +# +# We use simple assignment here to remove any of the depend.tmp files +# at the time make parses this bit. +# + +dummyvariable := $(shell $(RM) cdepend.tmp cxxdepend.tmp) + +# +# Now the "fake" rules for generating .d files. +# + +%.d: %.c + @echo "$<" >> cdepend.tmp + +%.d: %.cxx + @echo "$<" >> cxxdepend.tmp + +# +# The depend.phony rule which actually runs omkdepend. +# + +depend.phony: + @if [ -f cdepend.tmp ]; then \ + echo $(CMAKEDEPEND) $(ALL_CPPFLAGS) `cat cdepend.tmp`; \ + $(CMAKEDEPEND) $(ALL_CPPFLAGS) `cat cdepend.tmp`; \ + rm -f cdepend.tmp; \ + fi; \ + if [ -f cxxdepend.tmp ]; then \ + echo $(CXXMAKEDEPEND) $(ALL_CPPFLAGS) `cat cxxdepend.tmp`; \ + $(CXXMAKEDEPEND) $(ALL_CPPFLAGS) `cat cxxdepend.tmp`; \ + rm -f cxxdepend.tmp; \ + fi + +# +# Now include the .d files and the "depend.phony" file which never exists. +# For some reason GNU make evaluates the targets in reverse order, so we need +# to include depend.phony first. The "-" tells make not to complain that it +# can't find the file. +# + +-include depend.phony + +ifdef SRCS +-include $(patsubst %.c,%.d,$(patsubst %.cxx,%.d,$(SRCS))) +endif