| Line | Revision | Contents |
| 1 | 15 | # Process this file with http://www.scons.org to build FSPlib. |
| 2 | ||
| 3 | 19 | import os |
| 4 | 15 | # init Scons |
| 5 | EnsureSConsVersion(0,96) | |
| 6 | PACKAGE='fsplib' | |
| 7 | 57 | VERSION='0.11' |
| 8 | 15 | |
| 9 | 52 | #Defaults |
| 10 | PREFIX='/usr/local' | |
| 11 | SHARED=0 | |
| 12 | ||
| 13 | 15 | env = Environment() |
| 14 | # Turn CPPFLAGS to list | |
| 15 | env.Append( CPPFLAGS = []) | |
| 16 | 20 | |
| 17 | ################### Functions ###################### | |
| 18 | def importEnv(list=None, prefix=None): | |
| 19 | if list: | |
| 20 | for i in list: | |
| 21 | if os.environ.get(i): | |
| 22 | kw={} | |
| 23 | kw[i]=os.environ.get(i) | |
| 24 | kw={ 'ENV': kw } | |
| 25 | env.Append(**kw) | |
| 26 | if prefix: | |
| 27 | for i in os.environ.keys(): | |
| 28 | if i.startswith(prefix): | |
| 29 | kw={} | |
| 30 | kw[i]=os.environ.get(i) | |
| 31 | kw={ 'ENV': kw } | |
| 32 | env.Append(**kw) | |
| 33 | ||
| 34 | #import environment | |
| 35 | importEnv(['HOME','CC']) | |
| 36 | importEnv(prefix='DISTCC_') | |
| 37 | importEnv(prefix='CCACHE_') | |
| 38 | if env['ENV'].get('CC'): | |
| 39 | env.Replace( CC = env['ENV'].get('CC')) | |
| 40 | 19 | # Get CC from commandline |
| 41 | if ARGUMENTS.get('CC', 0): | |
| 42 | env.Replace(CC = ARGUMENTS.get('CC')) | |
| 43 | 15 | |
| 44 | 58 | ############# Custom configure tests ################### |
| 45 | 15 | |
| 46 | 18 | def checkForDirentMember(conf,member,symbol): |
| 47 | 58 | """Checks if dirent structure has specified field member. |
| 48 | ||
| 49 | Keyword arguments: | |
| 50 | member -- what member we are checking | |
| 51 | symbol -- symbol to be defined by preprocessor if member exists | |
| 52 | ||
| 53 | """ | |
| 54 | 18 | conf.Message("checking whether dirent structure has member "+member+"... ") |
| 55 | 59 | rc=conf.TryCompile(""" |
| 56 | #include <sys/types.h> | |
| 57 | #include <dirent.h> | |
| 58 | 15 | |
| 59 | void dummy(void); | |
| 60 | void dummy() | |
| 61 | { | |
| 62 | struct dirent d; | |
| 63 | 18 | d."""+member+"""=0; |
| 64 | 59 | } |
| 65 | """,".c") | |
| 66 | 15 | if rc: |
| 67 | 18 | conf.env.Append(CPPFLAGS = '-D'+symbol) |
| 68 | 15 | conf.Result(rc) |
| 69 | return rc | |
| 70 | ||
| 71 | def checkForGCCOption(conf,option): | |
| 72 | 58 | """Check if compiler supports specified option""" |
| 73 | conf.Message("checking whether CC supports "+option+" ") | |
| 74 | lastCFLAGS=conf.env['CCFLAGS'] | |
| 75 | conf.env.Append(CCFLAGS = option) | |
| 76 | rc = conf.TryCompile(""" | |
| 77 | 59 | void dummy(void); |
| 78 | void dummy(void) {} | |
| 79 | """,'.c') | |
| 80 | 58 | if not rc: |
| 81 | 15 | conf.env.Replace(CCFLAGS = lastCFLAGS) |
| 82 | 58 | conf.Result(rc) |
| 83 | return rc | |
| 84 | 15 | |
| 85 | def checkForMaintainerMode(conf): | |
| 86 | 58 | """Check if maintainer mode is enabled by command line""" |
| 87 | 15 | conf.Message("checking whether to enable maintainer mode... ") |
| 88 | if ARGUMENTS.get('maintainer-mode', 0) or \ | |
| 89 | ARGUMENTS.get('enable-maintainer-mode', 0): | |
| 90 | conf.Result(1) | |
| 91 | conf.env.Append(CCFLAGS = '-O0') | |
| 92 | conf.env.Append(CPPFLAGS = '-DMAINTAINER_MODE') | |
| 93 | else: | |
| 94 | 17 | conf.env.Append(CCFLAGS = '-O') |
| 95 | 15 | conf.Result(0) |
| 96 | ||
| 97 | def checkForLockPrefix(conf): | |
| 98 | 58 | """check for user-supplied lock prefix on command line""" |
| 99 | 15 | conf.Message("checking for user supplied lockprefix... ") |
| 100 | lp = ARGUMENTS.get('lockprefix', 0) or ARGUMENTS.get("with-lockprefix",0) | |
| 101 | ||
| 102 | if lp: | |
| 103 | conf.Result(1) | |
| 104 | conf.env.Append(CPPFLAGS = '-DFSP_KEY_PREFIX=\\"'+lp+'\\"') | |
| 105 | else: | |
| 106 | conf.Result(0) | |
| 107 | ||
| 108 | 17 | def checkForUserPrefix(conf): |
| 109 | 58 | """check for user-supplied installation prefix""" |
| 110 | 17 | global PREFIX |
| 111 | conf.Message("checking for user supplied prefix... ") | |
| 112 | lp = ARGUMENTS.get('prefix', 0) | |
| 113 | if lp: | |
| 114 | conf.Result(1) | |
| 115 | PREFIX=lp | |
| 116 | else: | |
| 117 | conf.Result(0) | |
| 118 | ||
| 119 | 52 | def checkForBuildingSharedLibrary(conf): |
| 120 | 58 | """check if building shared library was requested""" |
| 121 | 52 | global SHARED |
| 122 | conf.Message("checking whether to build shared library... ") | |
| 123 | makeshared=ARGUMENTS.get('enable-shared', 0) | |
| 124 | if makeshared == 0 or makeshared == 'no': | |
| 125 | conf.Result(0) | |
| 126 | SHARED=0 | |
| 127 | else: | |
| 128 | conf.Result(1) | |
| 129 | SHARED=1 | |
| 130 | ||
| 131 | 15 | #Start configuration |
| 132 | conf = Configure(env,{'checkForGCCOption':checkForGCCOption, | |
| 133 | 'MAINTAINER_MODE':checkForMaintainerMode, | |
| 134 | 'checkForLockPrefix':checkForLockPrefix, | |
| 135 | 17 | 'checkPrefix':checkForUserPrefix, |
| 136 | 52 | 'checkDirentFor':checkForDirentMember, |
| 137 | 'ENABLE_SHARED':checkForBuildingSharedLibrary} | |
| 138 | ) | |
| 139 | 15 | for option in Split(""" |
| 140 | -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Wshadow | |
| 141 | -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings | |
| 142 | -Waggregate-return -Wmissing-declarations | |
| 143 | -Wmissing-format-attribute -Wnested-externs | |
| 144 | -ggdb -fno-common -Wchar-subscripts -Wcomment | |
| 145 | -Wimplicit -Wsequence-point -Wreturn-type | |
| 146 | -Wfloat-equal -Wno-system-headers -Wredundant-decls | |
| 147 | -Wmissing-noreturn -pedantic | |
| 148 | -Wlong-long -Wundef -Winline | |
| 149 | -Wpointer-arith -Wno-unused-parameter | |
| 150 | 18 | """): |
| 151 | 15 | conf.checkForGCCOption(option) |
| 152 | 19 | #portability checks |
| 153 | 15 | if not conf.CheckType("union semun", "#include <sys/types.h>\n#include <sys/ipc.h>\n#include <sys/sem.h>",'c'): |
| 154 | conf.env.Append(CPPFLAGS = "-D_SEM_SEMUN_UNDEFINED=1") | |
| 155 | 18 | conf.checkDirentFor('d_namlen','HAVE_DIRENT_NAMLEN') |
| 156 | conf.checkDirentFor('d_fileno','HAVE_DIRENT_FILENO') | |
| 157 | conf.checkDirentFor('d_type','HAVE_DIRENT_TYPE') | |
| 158 | 19 | if conf.CheckCHeader('stdint.h'): |
| 159 | conf.env.Append(CPPFLAGS = "-DHAVE_STDINT_H") | |
| 160 | #locking type checks | |
| 161 | 15 | fun_lockf=conf.CheckFunc("lockf") |
| 162 | fun_semop=conf.CheckFunc("semop") | |
| 163 | fun_shmget=conf.CheckFunc("shmget") | |
| 164 | #select locking type | |
| 165 | lt=ARGUMENTS.get('locking', 0) or ARGUMENTS.get("with-locking",0) or ARGUMENTS.get("lock",0) or ARGUMENTS.get("with-lock",0) | |
| 166 | if lt == "none": | |
| 167 | conf.env.Append(CPPFLAGS = '-DFSP_NOLOCKING') | |
| 168 | elif lt == "lockf" and fun_lockf: | |
| 169 | conf.env.Append(CPPFLAGS = '-DFSP_USE_LOCKF') | |
| 170 | elif lt == "semop" and fun_semop and fun_shmget: | |
| 171 | conf.env.Append(CPPFLAGS = '-DFSP_USE_SHAREMEM_AND_SEMOP') | |
| 172 | elif fun_semop and fun_shmget: | |
| 173 | conf.env.Append(CPPFLAGS = '-DFSP_USE_SHAREMEM_AND_SEMOP') | |
| 174 | elif fun_lockf: | |
| 175 | conf.env.Append(CPPFLAGS = '-DFSP_USE_LOCKF') | |
| 176 | else: | |
| 177 | conf.env.Append(CPPFLAGS = '-DFSP_NOLOCKING') | |
| 178 | conf.checkForLockPrefix() | |
| 179 | 17 | conf.checkPrefix() |
| 180 | 52 | conf.ENABLE_SHARED() |
| 181 | 15 | conf.MAINTAINER_MODE() |
| 182 | conf.Finish() | |
| 183 | ||
| 184 | # process build rules | |
| 185 | 52 | Export( Split("env PREFIX PACKAGE VERSION SHARED")) |
| 186 | 15 | env.SConscript(dirs=['.']) |
Loggerhead is a web-based interface for Bazaar branches