import os.path CC = "/usr/bin/gcc" CFLAGS = "-g" IFLAGS = "-I ../source -I ../include/chipmunk -I ../include/libstem" LFLAGS = "-framework OpenGL -framework Cocoa -framework GLUT ../libs/libstem.a ../libs/libstemshell_glut.a ../libs/libChipmunk.a ../libs/libpng.a ../libs/libjpeg.a -lz" WFLAGS = "-Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Werror" ARCHS = Split("ppc i386") ARCH_CFLAGS = { "ppc": "-arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4", "i386": "-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4", "x86_64": "-arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5" } SOURCE_DIR = "../source" def arch_env(arch): return Environment( CC = CC, CCFLAGS = "%s %s %s %s" % (CFLAGS, ARCH_CFLAGS[arch], WFLAGS, IFLAGS) ) def obj_name(file): return os.path.splitext(os.path.basename(str(file)))[0] def mkdir_if_not_exists(target, source, env): if not os.path.exists(str(target)): Execute(Mkdir(target)) sources_game = Glob(SOURCE_DIR + "/game/*.c") sources_main = Glob(SOURCE_DIR + "/main/*.c") sources_types = Glob(SOURCE_DIR + "/types/*.c") files_adhesion = sources_game + sources_main + sources_types base_env = Environment( CC = CC, CCFLAGS = "%s %s %s" % (CFLAGS, WFLAGS, IFLAGS), LINKFLAGS = LFLAGS ) outputs = [] for arch in ARCHS: env = base_env.Clone( CC = CC, CCFLAGS = "%s %s %s -arch %s" % (CFLAGS, WFLAGS, IFLAGS, arch), LINKFLAGS = "%s -arch %s" % (LFLAGS, arch) ) objs = [] for file in files_adhesion: objs += env.Object("intermediate/%s/%s.o" % (arch, obj_name(file)), file) outputs += env.Program("intermediate/%s/Adhesion" % arch, objs) program = base_env.Command("build/Adhesion.app/Contents/MacOS/Adhesion", outputs, "lipo -create -output $TARGET $SOURCES") base_env.Command("build/Adhesion.app/Contents/Resources", None, base_env.Action(mkdir_if_not_exists)) base_env.Command("build/Adhesion.app/Contents/Info.plist", "Info.plist", Copy("$TARGET", "$SOURCE")) for resource_file in Glob("../resources/*"): base_env.Command("build/Adhesion.app/Contents/Resources/%s" % os.path.basename(str(resource_file)), resource_file, Copy("$TARGET", "$SOURCE"))