1#!/bin/env python 2# Copyright (C) 2001-2019 Artifex Software, Inc. 3# All Rights Reserved. 4# 5# This software is provided AS-IS with no warranty, either express or 6# implied. 7# 8# This software is distributed under license and may not be copied, 9# modified or distributed except as expressly authorized under the terms 10# of the license contained in the file LICENSE in this distribution. 11# 12# Refer to licensing information at http://www.artifex.com or contact 13# Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, 14# CA 94945, U.S.A., +1(415)492-9861, for further information. 15# 16# 17# script to generate ldf_jb2.mak 18# whose source sometimes changes 19 20 21import time, glob 22import os.path 23 24outfile="ldf_jb2.mak" 25 26license = """# Copyright (C) %d Artifex Software, Inc. All rights reserved. 27# 28# This software is provided AS-IS with no warranty, either express or 29# implied. 30# 31# This software is distributed under license and may not be copied, 32# modified or distributed except as expressly authorized under the terms 33# of the license contained in the file LICENSE in this distribution. 34# 35# For more information about licensing, please refer to 36# http://www.ghostscript.com/licensing/. For information on 37# commercial licensing, go to http://www.artifex.com/licensing/ or 38# contact Artifex Software, Inc., 1305 Grant Avenue - Suite 200, 39# Novato, CA 94945, U.S.A., +1(415)492-9861. 40 41# $""" """Id$ 42""" % time.gmtime().tm_year 43 44comment = """ 45# makefile for Luratech ldf_jb2 library code. 46# Users of this makefile must define the following: 47# SHARE_JBIG2 - whether to compile in or link to the library 48# JBIG2SRCDIR - the library source directory 49# 50# gs.mak and friends define the following: 51# JBIG2OBJDIR - the output obj directory 52# JBIG2GENDIR - generated (.dev) file directory 53# LDF_JB2I_ - include path for the library 54# JB2CF_ - cflags for building the library 55# 56# We define the ldf_jb2.dev target and its dependencies 57# 58# This partial makefile compiles the ldf_jb2 library for use in 59# Ghostscript. 60""" 61 62common = """ 63LDF_JB2_MAK=$(GLSRC)%s 64 65LDF_JB2_SRC=$(JBIG2SRCDIR)$(D) 66LDF_JB2_GEN=$(JBIG2OBJDIR)$(D) 67LDF_JB2_OBJ=$(JBIG2OBJDIR)$(D) 68 69# paths to source directories 70LDF_JB2_COMMON=$(JBIG2SRCDIR)$(D)source$(D)common$(D) 71LDF_JB2_COMPRESS=$(JBIG2SRCDIR)$(D)source$(D)compress$(D) 72""" % outfile 73 74dev = """ 75ldf_jb2_OBJS=$(ldf_jb2_common_OBJS) $(ldf_jb2_compress_OBJS) 76ldf_jb2_HDRS=$(ldf_jb2_common_HDRS) $(ldf_jb2_compress_HDRS) 77 78# switch in the selected library .dev 79$(LDF_JB2_GEN)ldf_jb2.dev : $(TOP_MAKEFILES) $(LDF_JB2_MAK) $(LDF_JB2_GEN)ldf_jb2_$(SHARE_JBIG2).dev 80 $(CP_) $(LDF_JB2_GEN)ldf_jb2_$(SHARE_JBIG2).dev $(LDF_JB2_GEN)ldf_jb2.dev 81 82# external link .dev 83$(LDF_JB2_GEN)ldf_jb2_1.dev : $(TOP_MAKEFILES) $(LDF_JB2_MAK) $(ECHOGS_XE) 84 $(SETMOD) $(LDF_JB2_GEN)ldf_jb2_1 -lib ldf_jb2 85 86# compile our own .dev 87$(LDF_JB2_GEN)ldf_jb2_0.dev : $(TOP_MAKEFILES) $(LDF_JB2_MAK) $(ECHOGS_XE) $(ldf_jb2_OBJS) 88 $(SETMOD) $(LDF_JB2_GEN)ldf_jb2_0 $(ldf_jb2_common_OBJS) 89 $(ADDMOD) $(LDF_JB2_GEN)ldf_jb2_0 $(ldf_jb2_compress_OBJS) 90 91# define our specific compiler 92LDF_JB2_CC=$(CC_) $(I_)$(LDF_JB2I_) $(II)$(LDF_JB2_COMMON) $(II)$(LDF_JB2_COMPRESS)$(_I) $(JB2CF_) 93LDF_JB2_O=$(O_)$(LDF_JB2_OBJ) 94 95LDF_JB2_DEP=$(AK) $(LDF_JB2_MAK) 96""" 97 98common_srcs = glob.glob("ldf_jb2/source/common/*.c") 99common_srcs.sort() 100common_hdrs = glob.glob("ldf_jb2/source/common/*.h") 101common_hdrs.sort() 102compress_srcs = glob.glob("ldf_jb2/source/compress/*.c") 103compress_srcs.sort() 104compress_hdrs = glob.glob("ldf_jb2/source/compress/*.h") 105compress_srcs.sort() 106 107source = """ 108# source files to build from the CSDK source 109""" 110 111source += """ 112ldf_jb2_common_OBJS = \\ 113""" 114for file in common_srcs: 115 name = os.path.splitext(os.path.basename(file))[0] 116 source += "\t$(LDF_JB2_OBJ)%s.$(OBJ)" % name 117 if file != common_srcs[-1]: source += "\t\t\\" 118 source += "\n" 119 120source += """ 121ldf_jb2_compress_OBJS = \\ 122""" 123for file in compress_srcs: 124 name = os.path.splitext(os.path.basename(file))[0] 125 source += "\t$(LDF_JB2_OBJ)%s.$(OBJ)" % name 126 if file != compress_srcs[-1]: source += "\t\t\\" 127 source += "\n" 128 129source += """ 130ldf_jb2_common_HDRS = \\ 131""" 132for file in common_hdrs: 133 source += "\t$(LDF_JB2_COMMON)%s" % os.path.basename(file) 134 if file != common_hdrs[-1]: source += "\t\t\\" 135 source += "\n" 136 137source += """ 138ldf_jb2_compress_HDRS = \\ 139""" 140for file in compress_hdrs: 141 source += "\t$(LDF_JB2_COMPRESS)%s" % os.path.basename(file) 142 if file != compress_hdrs[-1]: source += "\t\t\\" 143 source += "\n" 144 145 146rules = """ 147# explicit rules for building each source file 148# for simplicity we have every source file depend on all headers 149 150""" 151 152for file in common_srcs: 153 cfile = os.path.basename(file) 154 name = os.path.splitext(cfile)[0] 155 rules += "$(LDF_JB2_OBJ)%s.$(OBJ)" % name 156 rules += " : $(LDF_JB2_COMMON)%s" % cfile 157 rules += " $(LDF_JB2_DEP) $(ldf_jb2_HDRS)\n" 158 rules += "\t$(LDF_JB2_CC) $(LDF_JB2_O)%s.$(OBJ)" % name 159 rules += " $(C_) $(LDF_JB2_COMMON)%s\n" % cfile 160 rules += "\n" 161 162for file in compress_srcs: 163 cfile = os.path.basename(file) 164 name = os.path.splitext(cfile)[0] 165 rules += "$(LDF_JB2_OBJ)%s.$(OBJ)" % name 166 rules += " : $(LDF_JB2_COMPRESS)%s" % cfile 167 rules += " $(LDF_JB2_DEP) $(ldf_jb2_HDRS)\n" 168 rules += "\t$(LDF_JB2_CC) $(LDF_JB2_O)%s.$(OBJ)" % name 169 rules += " $(C_) $(LDF_JB2_COMPRESS)%s\n" % cfile 170 rules += "\n" 171 172 173 174print license + comment + common 175print source 176print dev 177print rules 178print "# end of file" 179