#!/usr/bin/env scons # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You 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. # import subprocess from os.path import join as pjoin EnsureSConsVersion(1, 1, 0) opts = Variables('build.py') opts.Add(PathVariable('APXS', 'Path apxs','/usr/sbin/apxs')) env = Environment(options=opts) def get_output(cmd): s = subprocess.Popen(cmd, stdout=subprocess.PIPE) out = s.communicate()[0] s.wait() return out.strip() def apxs_query(path, key): cmd = [path, "-q", key] return get_output(cmd) apr_config = apxs_query(env["APXS"], 'APR_CONFIG') apu_config = apxs_query(env["APXS"], 'APU_CONFIG') env.Replace(CC = apxs_query(env["APXS"], 'CC')) env.Replace(CPP = apxs_query(env["APXS"], 'CPP')) # This is a hack to set the RPATH on some operating systems... make me more # portable later.... p1 = get_output([apr_config, '--bindir']) p1 = pjoin(p1[:p1.rfind('/')], 'lib') p2 = get_output([apr_config, '--bindir']) p2 = pjoin(p2[:p2.rfind('/')], 'lib') env.AppendUnique(RPATH = [p1, p2]) env.ParseConfig(apr_config + ' --cflags --cppflags --includes --ldflags') env.ParseConfig(apu_config + ' --includes --ldflags') # TODO: Move to httpd-config when it comes out ! env.ParseConfig(env['APXS'] + ' -q EXTRA_CFLAGS') env.ParseConfig(env['APXS'] + ' -q EXTRA_CPPFLAGS') env.ParseConfig(env['APXS'] + ' -q EXTRA_LIBS') env.AppendUnique(CPPPATH = [apxs_query(env['APXS'], 'exp_includedir')]) if env['PLATFORM'] == 'darwin': env.AppendUnique(LINKFLAGS = ['-undefined', 'dynamic_lookup']) modsources = Split("""modules/allowmethods/mod_allowmethods.c""") env.ParseConfig(apr_config + ' --link-ld --libs') env.ParseConfig(apu_config + ' --link-ld --libs') module = env.LoadableModule(target = "modules/allowmethods/mod_allowmethods.so", source = [modsources], SHLIBPREFIX='') mod_path = apxs_query(env["APXS"], 'exp_libexecdir') bin_path = apxs_query(env["APXS"], 'exp_bindir') imod = env.Install(mod_path, source = [module]) env.Alias('install', [imod]) targets = [module] env.Default(targets)