Anonymous avatar Anonymous committed 4fa0246

Add new Makefile lexer that should be able to handle BSD and/or GNU
preprocessor directives, and regenerate map files

Comments (0)

Files changed (5)

pygments/formatters/_mapping.py

 FORMATTERS = {
     BBCodeFormatter: ('BBCode', ('bbcode', 'bb'), (), 'Format tokens with BBcodes. These formatting codes are used by many bulletin boards, so you can highlight your sourcecode with pygments before posting it there.'),
     HtmlFormatter: ('HTML', ('html',), ('*.html', '*.htm'), "Format tokens as HTML 4 ``<span>`` tags within a ``<pre>`` tag, wrapped in a ``<div>`` tag. The ``<div>``'s CSS class can be set by the `cssclass` option."),
-    ImageFormatter: ('img', ('img', 'IMG', 'png', 'jpg', 'gif'), ('*.png', '*.jpg', '*.gif'), 'Create an image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
+    ImageFormatter: ('img', ('img', 'IMG', 'png', 'jpg', 'gif', 'bmp'), ('*.png', '*.jpg', '*.gif', '*.bmp'), 'Create an image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
     LatexFormatter: ('LaTeX', ('latex', 'tex'), ('*.tex',), 'Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages.'),
     NullFormatter: ('Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'),
     RawTokenFormatter: ('Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'),

pygments/lexers/_mapping.py

     'ActionScriptLexer': ('pygments.lexers.web', 'ActionScript', ('as', 'actionscript'), ('*.as',), ('application/x-actionscript', 'text/x-actionscript', 'text/actionscript')),
     'ApacheConfLexer': ('pygments.lexers.text', 'ApacheConf', ('apacheconf', 'aconf', 'apache'), ('.htaccess', 'apache.conf', 'apache2.conf'), ('text/x-apacheconf',)),
     'BBCodeLexer': ('pygments.lexers.text', 'BBCode', ('bbcode',), (), ('text/x-bbcode',)),
+    'BaseMakefileLexer': ('pygments.lexers.text', 'Makefile', ('basemake',), (), ()),
     'BashLexer': ('pygments.lexers.other', 'Bash', ('bash', 'sh'), ('*.sh',), ('application/x-sh', 'application/x-shellscript')),
     'BatchLexer': ('pygments.lexers.other', 'Batchfile', ('bat',), ('*.bat', '*.cmd'), ('application/x-dos-batch',)),
     'BefungeLexer': ('pygments.lexers.other', 'Befunge', ('befunge',), ('*.befunge',), ('application/x-befunge',)),
     'ErlangLexer': ('pygments.lexers.functional', 'Erlang', ('erlang',), ('*.erl', '*.hrl'), ('text/x-erlang',)),
     'FortranLexer': ('pygments.lexers.compiled', 'Fortran', ('fortran',), ('*.f', '*.f90'), ('text/x-fortran',)),
     'GasLexer': ('pygments.lexers.asm', 'GAS', ('gas',), ('*.s', '*.S'), ('text/x-gas',)),
+    'GenericMakefileLexer': ('pygments.lexers.text', 'GenericMakefile', ('make', 'makefile', 'mf', 'bsdmake'), ('*.mak', 'Makefile', 'makefile', 'Makefile.*'), ('text/x-makefile',)),
     'GenshiLexer': ('pygments.lexers.templates', 'Genshi', ('genshi', 'kid', 'xml+genshi', 'xml+kid'), ('*.kid',), ('application/x-genshi', 'application/x-kid')),
     'GenshiTextLexer': ('pygments.lexers.templates', 'Genshi Text', ('genshitext',), (), ('application/x-genshi-text', 'text/x-genshi')),
     'GettextLexer': ('pygments.lexers.text', 'Gettext Catalog', ('pot', 'po'), ('*.pot', '*.po'), ('application/x-gettext', 'text/x-gettext', 'text/gettext')),
     'LlvmLexer': ('pygments.lexers.asm', 'LLVM', ('llvm',), ('*.ll',), ('text/x-llvm',)),
     'LuaLexer': ('pygments.lexers.agile', 'Lua', ('lua',), ('*.lua',), ('text/x-lua', 'application/x-lua')),
     'MOOCodeLexer': ('pygments.lexers.other', 'MOOCode', ('moocode',), ('*.moo',), ('text/x-moocode',)),
-    'MakefileLexer': ('pygments.lexers.text', 'Makefile', ('make', 'makefile', 'mf'), ('*.mak', 'Makefile', 'makefile'), ('text/x-makefile',)),
     'MakoCssLexer': ('pygments.lexers.templates', 'CSS+Mako', ('css+mako',), (), ('text/css+mako',)),
     'MakoHtmlLexer': ('pygments.lexers.templates', 'HTML+Mako', ('html+mako',), (), ('text/html+mako',)),
     'MakoJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Mako', ('js+mako', 'javascript+mako'), (), ('application/x-javascript+mako', 'text/x-javascript+mako', 'text/javascript+mako')),

pygments/lexers/text.py

     from sets import Set as set
 from bisect import bisect
 
-from pygments.lexer import RegexLexer, bygroups, include, using, this, \
+from pygments.lexer import Lexer, RegexLexer, bygroups, include, using, this, \
      do_insertions
 from pygments.token import Punctuation, \
     Text, Comment, Keyword, Name, String, Generic, Operator, Number, \
     Whitespace, Literal
 from pygments.util import get_bool_opt
+from pygments.lexers.other import BashLexer
 
-
-__all__ = ['IniLexer', 'SourcesListLexer', 'MakefileLexer', 'DiffLexer',
-           'IrcLogsLexer', 'TexLexer', 'GroffLexer', 'ApacheConfLexer',
-           'BBCodeLexer', 'MoinWikiLexer', 'RstLexer', 'VimLexer',
-           'GettextLexer', 'SquidConfLexer', 'DebianControlLexer',
-           'DarcsPatchLexer']
+__all__ = ['IniLexer', 'SourcesListLexer', 'BaseMakefileLexer',
+           'GenericMakefileLexer', 'DiffLexer', 'IrcLogsLexer', 'TexLexer',
+           'GroffLexer', 'ApacheConfLexer', 'BBCodeLexer', 'MoinWikiLexer',
+           'RstLexer', 'VimLexer', 'GettextLexer', 'SquidConfLexer',
+           'DebianControlLexer', 'DarcsPatchLexer']
 
 
 class IniLexer(RegexLexer):
         return True
 
 
-class MakefileLexer(RegexLexer):
+class GenericMakefileLexer(Lexer):
     """
-    Lexer for Makefiles.
+    Lexer for BSD and GNU make extensions (lenient enough to handle both in
+    the same file even).
+
+    *New in Pygments 1.0*
+    """
+
+    name = 'GenericMakefile'
+    aliases = ['make', 'makefile', 'mf', 'bsdmake']
+    filenames = ['*.mak', 'Makefile', 'makefile', 'Makefile.*']
+    mimetypes = ['text/x-makefile']
+
+    r_special = re.compile(r'^(?:'
+        # BSD Make
+        r'\.\s*(include|undef|error|warning|if|else|elif|endif|for|endfor)|'
+        # GNU Make
+        r'\s*(ifeq|ifneq|ifdef|ifndef|else|endif|-?include|define|endef|:))(?=\s)')
+    r_comment = re.compile(r'^\s*@?#')
+
+    def get_tokens_unprocessed(self, text):
+        ins = []
+        lines = text.splitlines(True)
+        done = ''
+        lex = BaseMakefileLexer(**self.options)
+        backslashflag = False
+        for line in lines:
+            if self.r_special.match(line) or backslashflag:
+                ins.append((len(done), [(0, Comment.Preproc, line)]))
+                backslashflag = line.strip().endswith('\\')
+            elif self.r_comment.match(line):
+                ins.append((len(done), [(0, Comment, line)]))
+            else:
+                done += line
+        for item in do_insertions(ins, lex.get_tokens_unprocessed(done)):
+            yield item
+
+
+class BaseMakefileLexer(RegexLexer):
+    """
+    Lexer for simple Makefiles (no preprocessing).
+
+    *New in Pygments 1.0*
     """
 
     name = 'Makefile'
-    aliases = ['make', 'makefile', 'mf']
-    filenames = ['*.mak', 'Makefile', 'makefile']
-    mimetypes = ['text/x-makefile']
+    aliases = ['basemake']
+    filenames = []
+    mimetypes = []
 
     tokens = {
         'root': [
             (r'\s+', Text),
             (r'#.*?\n', Comment),
-            (r'(cmdswitches|error|export|message|include|if|ifdef|ifndef|else|'
-             r'else\s*if|else\s*ifdef|else\s*ifndef|endif|undef)\b', Keyword),
+            (r'(export)(\s+)(?=[a-zA-Z0-9_${}\t -]+\n)',
+             bygroups(Keyword, Text), 'export'),
+            (r'export\s+', Keyword),
             # assignment
-            (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)([?:+]?=)([ \t]*)',
+            (r'([a-zA-Z0-9_${}-]+)(\s*)([!?:+]?=)([ \t]*)',
              bygroups(Name.Variable, Text, Operator, Text), 'var'),
+            # strings
             (r'"(\\\\|\\"|[^"])*"', String.Double),
             (r"'(\\\\|\\'|[^'])*'", String.Single),
             # targets
-            (r'([^\n:]+)(:)([ \t]*)', bygroups(Name.Function, Operator, Text),
-             'block-header')
+            (r'([^\n:]+)(:+)([ \t]*)', bygroups(Name.Function, Operator, Text),
+             'block-header'),
+            #TODO: add paren handling (grr)
+        ],
+        'export': [
+            (r'[a-zA-Z0-9_${}-]+', Name.Variable),
+            (r'\n', Text, '#pop'),
+            (r'\s+', Text),
         ],
         'var': [
             (r'\\\n', String),
+            (r'\\', String),
             (r'\n', Text, '#pop'),
-            (r'\\', String),
             (r'[^\\\n]+', String),
         ],
         'block-header': [
             (r'[^,\\\n#]+', Number),
             (r',', Punctuation),
             (r'#.*?\n', Comment),
-            # line continuation
-            (r'\\\n', Text),
-            (r'\\', Text),
-            (r'\n[\t ]+', Text, 'block'),
-            (r'\n', Text, '#pop')
+            (r'\\\n', Text), # line continuation
+            (r'\\.', Text),
+            (r'(?:[\t ]+.*\n|\n)+', using(BashLexer), '#pop'),
         ],
-        'block': [
-            (r'#.*?(?=\n)', Comment),
-            (r'\n[\t ]+', Text),
-            (r'[^\n$]+', String),
-            (r'\$[A-Za-z0-9_]+', String.Interpol),
-            (r'\$\(.*?\)', String.Interpol),
-            (r'\$', String),
-            (r'\n', Text, '#pop:2'),
-        ]
     }
 
 

tests/examplefiles/firefox.mak

+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (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.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= .
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+include $(topsrcdir)/build/unix/modules.mk
+
+ifeq ($(BUILD_MODULES),all)
+#
+# And now for something completely different...
+# Divide the default build into tiers. 
+# Tiers must be defined on module boundaries 
+#
+SUPPRESS_DEFAULT_RULES = 1
+
+default alldep all:: $(SUBMAKEFILES)
+	$(RM) -rf $(DIST)/sdk
+	$(RM) -rf $(DIST)/include
+	$(MAKE) -C config export
+	$(MAKE) nspr
+	$(MAKE) ldap
+	$(MAKE) tier_0
+	$(MAKE) tier_1
+	$(MAKE) tier_2
+	$(MAKE) tier_9
+	$(MAKE) tier_50
+	$(MAKE) tier_99
+
+# Make sure that the existing rulesets work
+DIRS = \
+	$(tier_0_dirs) \
+	$(tier_1_dirs) \
+	$(tier_2_dirs) \
+	$(tier_9_dirs) \
+	$(tier_50_dirs) \
+	$(NULL)
+
+ifdef GC_LEAK_DETECTOR
+DIRS += gc/boehm
+endif
+
+DIRS	+= $(tier_99_dirs)
+
+#
+# tier 0 - base build config dirs
+# 
+tier_0_dirs = \
+	config \
+	build \
+	$(NULL)
+
+#
+# tier 1 -  3rd party individual libraries
+#
+tier_1_dirs	+= dbm
+
+ifndef MOZ_NATIVE_JPEG
+tier_1_dirs	+= jpeg
+endif
+
+ifndef MOZ_NATIVE_ZLIB
+tier_1_dirs	+= modules/zlib
+endif
+
+# Installer needs standalone libjar, hence standalone zlib
+ifdef MOZ_INSTALLER
+tier_1_dirs	+= modules/zlib/standalone
+endif
+
+ifdef MOZ_UPDATER
+tier_1_dirs += modules/libbz2
+tier_1_dirs += modules/libmar
+endif
+
+ifdef MOZ_SVG_RENDERER_LIBART
+tier_1_dirs	+= other-licenses/libart_lgpl
+endif
+
+#
+# tier 2 - base libraries
+# 
+tier_2_dirs	= \
+		js \
+		xpcom \
+		$(NULL)
+
+ifndef MOZ_NO_XPCOM_OBSOLETE
+tier_2_dirs += modules/libreg xpcom/obsolete
+endif
+
+ifdef NS_TRACE_MALLOC
+tier_2_dirs	+= tools/trace-malloc/lib
+endif
+
+#
+# tier 9 - core components (necko,gecko)
+#
+
+tier_9_dirs += \
+		js/src/xpconnect \
+		intl \
+		db \
+		$(NULL)
+
+ifdef MOZ_STORAGE
+tier_9_dirs += storage
+endif
+
+ifdef MOZ_ENABLE_XLIB
+tier_9_dirs	+= gfx/src/xlibrgb widget/src/xlibxtbin
+endif
+
+ifdef MOZ_ENABLE_GTK
+tier_9_dirs	+= widget/src/gtksuperwin widget/src/gtkxtbin
+endif
+
+ifdef MOZ_ENABLE_GTK2
+tier_9_dirs     += widget/src/gtkxtbin
+endif
+
+ifdef MOZ_IPCD
+tier_9_dirs += ipc/ipcd
+endif
+
+ifdef MOZ_JSDEBUGGER
+tier_9_dirs += js/jsd
+endif
+
+tier_9_dirs	+= \
+		modules/libutil \
+		netwerk \
+		modules/libjar \
+		uriloader \
+		modules/libpref \
+		modules/libimg \
+		caps \
+		rdf \
+		parser/expat \
+		parser/xml \
+		parser/htmlparser \
+		gfx \
+		modules/libpr0n \
+		sun-java \
+		modules/plugin \
+		dom \
+		view \
+		widget \
+		content \
+		layout \
+		xpfe/components/shistory \
+		docshell \
+		webshell \
+		embedding \
+		editor \
+		xpfe/appshell \
+		$(NULL)
+
+ifdef MOZ_OJI
+tier_9_dirs	+= \
+		js/src/liveconnect \
+		modules/oji \
+		$(NULL)
+endif
+
+ifdef ACCESSIBILITY
+tier_9_dirs    += accessible
+endif
+
+# 
+# tier 50 - xpfe & toolkit
+#
+
+ifdef MOZ_XUL
+ifdef MOZ_XUL_APP
+tier_50_dirs += chrome
+else
+tier_50_dirs += rdf/chrome
+endif
+else
+tier_50_dirs += embedding/minimo/chromelite
+endif
+
+tier_50_dirs += profile
+
+# This must preceed xpfe
+ifdef MOZ_JPROF
+tier_50_dirs        += tools/jprof
+endif
+
+ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+tier_50_dirs	+= xpfe/bootstrap/appleevents
+endif
+
+tier_50_dirs	+= \
+	xpfe \
+	toolkit/components \
+	$(NULL)
+
+ifndef MOZ_XUL_APP
+tier_50_dirs += themes
+endif
+
+ifdef MOZ_ENABLE_XREMOTE
+tier_50_dirs += widget/src/xremoteclient
+endif
+
+ifdef MOZ_XUL_APP
+tier_50_dirs	+= toolkit
+endif
+
+ifdef MOZ_PHOENIX
+#XXXBlake this shell path is a temp hack; toolkit shouldn't depend on browser
+tier_50_dirs    += browser/components/shell/public
+endif
+
+ifdef MOZ_XPINSTALL
+tier_50_dirs     +=  xpinstall
+endif
+
+# JavaXPCOM JNI code is compiled into libXUL
+ifdef MOZ_JAVAXPCOM
+tier_50_dirs	+= extensions/java/xpcom/src
+endif
+
+ifdef MOZ_ENABLE_LIBXUL
+tier_50_dirs += \
+		toolkit/library \
+		xpcom/stub \
+		$(NULL)
+endif
+
+ifdef NS_TRACE_MALLOC
+tier_50_dirs += tools/trace-malloc
+endif
+
+ifdef MOZ_PSM
+tier_50_dirs	+= security/manager
+else
+tier_50_dirs	+= security/manager/boot/public security/manager/ssl/public
+endif
+
+ifdef MOZ_LDAP_XPCOM
+tier_50_dirs	+= directory/xpcom
+endif
+
+ifndef MINIMO
+ifdef MOZ_XUL_APP
+ifdef MOZ_ENABLE_GTK2
+tier_50_dirs    += toolkit/components/gnome
+endif
+endif
+endif
+
+ifdef MOZ_LEAKY
+tier_50_dirs        += tools/leaky
+endif
+
+ifdef MOZ_MAPINFO
+tier_50_dirs	+= tools/codesighs
+endif
+
+#
+# tier 99 - application features
+#
+
+ifdef MOZ_MAIL_NEWS
+tier_99_dirs	+= mailnews
+endif
+
+ifdef MOZ_CALENDAR
+tier_99_dirs	+= calendar
+endif
+
+ifdef MOZ_EXTENSIONS
+tier_99_dirs	+= extensions
+endif
+
+ifdef MOZ_JAVAXPCOM
+tier_99_dirs	+= extensions/java
+endif
+
+# axcontrol
+ifeq ($(OS_ARCH),WINNT)
+ifndef MOZ_NO_ACTIVEX_SUPPORT
+tier_99_dirs += \
+		embedding/browser/activex/src/control \
+		embedding/browser/activex/src/control_kicker \
+		$(NULL)
+endif
+endif
+
+# Java Embedding Plugin
+ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
+tier_99_dirs += plugin/oji/JEP
+endif
+
+ifneq (,$(filter browser suite,$(MOZ_BUILD_APP)))
+tier_99_dirs += xpfe/components/search
+endif
+
+ifdef MOZ_BRANDING_DIRECTORY
+tier_99_dirs += $(MOZ_BRANDING_DIRECTORY)
+endif
+
+ifdef MOZ_PHOENIX
+tier_99_dirs	+= browser xpfe/bootstrap/init.d
+endif
+
+ifdef MOZ_XULRUNNER
+tier_99_dirs	+= xulrunner
+endif
+
+ifdef MOZ_COMPOSER
+tier_99_dirs	+= editor/ui
+endif
+
+ifdef MOZ_THUNDERBIRD
+tier_99_dirs	+= mail xpfe/bootstrap/init.d
+endif
+
+ifdef MOZ_STANDALONE_COMPOSER
+tier_99_dirs	+= composer
+endif
+
+ifdef MOZ_SUNBIRD
+tier_99_dirs	+= calendar/sunbird
+endif
+
+ifdef MOZ_SUITE
+tier_99_dirs	+= suite
+endif
+
+ifdef MINIMO
+tier_99_dirs	+= minimo
+endif
+
+ifdef MOZ_XUL_APP
+ifdef MOZ_INSTALLER
+tier_99_dirs     +=  toolkit/mozapps/installer
+endif
+else
+ifneq (,$(MOZ_XPFE_COMPONENTS)$(MOZ_XUL))
+ifndef MINIMO
+tier_99_dirs	+= xpfe/bootstrap
+endif
+endif
+endif
+
+ifneq (,$(MOZ_ENABLE_GTK)$(MOZ_ENABLE_GTK2))
+tier_99_dirs	+= embedding/browser/gtk
+endif
+
+# viewer
+ifneq (,$(ENABLE_TESTS))
+ifndef MOZ_ENABLE_LIBXUL
+tier_99_dirs += webshell/tests
+endif
+endif
+
+# winembed, mfcembed
+ifeq ($(OS_ARCH),WINNT)
+ifneq (,$(ENABLE_TESTS)$(MOZILLA_OFFICIAL))
+tier_99_dirs += embedding/tests
+endif
+endif
+
+# os2embed
+ifeq ($(OS_ARCH),OS2)
+ifneq (,$(ENABLE_TESTS)$(MOZILLA_OFFICIAL))
+tier_99_dirs += embedding/tests
+endif
+endif
+
+ifeq ($(MOZ_BUILD_APP),macbrowser)
+tier_99_dirs += \
+	embedding/config \
+	camino \
+	$(NULL)
+endif
+
+# test harnesses 
+ifdef ENABLE_TESTS
+tier_99_dirs += tools/test-harness
+endif
+
+else
+
+# Standalone build
+
+DIRS		= $(BUILD_MODULE_DIRS)
+
+# Hack to generate xpidl Makefile
+ifneq ($(BUILD_MODULES),all)
+ifneq (,$(findstring xpcom, $(BUILD_MODULE_DIRS)))
+DIRS		:= xpcom/typelib $(DIRS)
+SUBMAKEFILES	:= xpcom/typelib/Makefile
+endif
+endif
+
+default:: $(SUBMAKEFILES)
+	$(MAKE) export
+	$(MAKE) libs
+
+endif # BUILD_MODULES == all
+
+STATIC_MAKEFILES := nsprpub directory/c-sdk security/nss
+
+GARBAGE_DIRS += dist
+DIST_GARBAGE = config.cache config.log config.status config-defs.h \
+   dependencies.beos config/autoconf.mk config/myrules.mk config/myconfig.mk \
+   unallmakefiles mozilla-config.h \
+   $(topsrcdir)/.mozconfig.mk $(topsrcdir)/.mozconfig.out 
+
+# Build pseudo-external modules first when export is explicitly called
+export::
+	$(RM) -rf $(DIST)/sdk
+	$(MAKE) -C config export
+	$(MAKE) nspr
+	$(MAKE) ldap
+ifneq ($(BUILD_MODULES),all)
+ifneq (,$(findstring xpcom, $(BUILD_MODULE_DIRS)))
+	$(MAKE) -C xpcom/typelib
+	$(MAKE) export-idl
+endif
+endif
+
+install::
+ifndef MOZ_NATIVE_NSPR
+	$(MAKE) -C nsprpub real_install DESTDIR=$(DESTDIR) libdir=$(mozappdir) includedir=$(includedir)/nspr
+	$(RM) -f $(addprefix $(DESTDIR)$(mozappdir)/$(LIB_PREFIX), $(addsuffix .$(LIB_SUFFIX), nspr4 plds4 plc4))
+	$(RM) -f $(addprefix $(DESTDIR)$(bindir)/,nspr-config compile-et.pl prerr.properties)
+endif
+ifdef MOZ_LDAP_XPCOM
+	$(MAKE) -C directory/c-sdk real_install DESTDIR=$(DESTDIR) libdir=$(mozappdir) includedir=$(includedir)/ldap
+endif
+
+include $(topsrcdir)/config/rules.mk
+
+# Clean up after pseudo-external modules
+clean clobber realclean clobber_all distclean::
+ifndef MOZ_NATIVE_NSPR
+	$(MAKE) -C nsprpub $@
+endif
+ifdef MOZ_LDAP_XPCOM
+	$(MAKE) -C directory/c-sdk $@
+endif
+
+# Map mozilla targets to standard automake target
+ifdef MOZ_ENABLE_LIBXUL
+tier_50: $(addsuffix /Makefile, $(filter-out $(STATIC_MAKEFILES), $($@_dirs)))
+	@echo "tier_50: $(tier_50_dirs)"
+	@$(EXIT_ON_ERROR) \
+	for d in $(tier_50_dirs); do \
+	    $(UPDATE_TITLE) \
+	    if test ! -f $$d/Makefile; then \
+	      $(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR) $$d/Makefile; \
+	    fi; \
+	    $(MAKE) -C $$d export; \
+	done ; \
+	for d in $(tier_50_dirs); do \
+	    $(UPDATE_TITLE) \
+	    $(MAKE) -C $$d libs; \
+	done
+	@echo "Building tools from tier 2/9/50"
+	@$(EXIT_ON_ERROR) \
+	for d in $(tier_2_dirs) $(tier_9_dirs) $(tier_50_dirs); do \
+	    $(UPDATE_TITLE) \
+	    $(MAKE) -C $$d tools; \
+	done;
+endif
+
+tier_%:
+	@echo "$@: $($@_dirs)"
+	@$(EXIT_ON_ERROR) \
+	  for d in $($@_dirs); do \
+	    $(UPDATE_TITLE) \
+	    if test ! -f $$d/Makefile; then \
+	      $(PERL) $(AUTOCONF_TOOLS)/make-makefile -t $(topsrcdir) -d $(DEPTH) $(CYGWIN_TOPSRCDIR) $$d/Makefile; \
+	    fi; \
+	    $(MAKE) -C $$d export; \
+	  done ; \
+	  for d in $($@_dirs); do $(UPDATE_TITLE) \
+	    $(MAKE) -C $$d libs; \
+	  done
+
+#
+# Individual modules
+#
+boehm:
+ifdef GC_LEAK_DETECTOR
+	$(MAKE) -C gc/boehm
+endif
+
+nspr: boehm
+ifndef MOZ_NATIVE_NSPR
+	$(MAKE) -C nsprpub
+endif
+
+ldap:
+ifdef MOZ_LDAP_XPCOM
+	$(MAKE) -C directory/c-sdk
+endif
+
+distclean::
+	cat unallmakefiles | $(XARGS) rm -f
+	rm -f unallmakefiles $(DIST_GARBAGE)
+
+ifeq ($(OS_ARCH),WINNT)
+rebase:
+ifdef MOZILLA_OFFICIAL
+	echo rebasing $(DIST)
+	/bin/find $(DIST) -name "*.dll" > rebase.lst
+	rebase -b 60000000 -R . -G rebase.lst
+	rm rebase.lst
+endif
+
+splitsymbols:
+ifdef MOZILLA_OFFICIAL
+ifdef MOZ_DEBUG_SYMBOLS
+	echo finding pdb files
+	mkdir -p $(DIST)/$(BUILDID)
+	-cp `/bin/find . -path "./dist" -prune -o -name "*.dll" | sed "s/\.dll$$/\.pdb/" | xargs` $(DIST)/$(BUILDID)
+	-cp `/bin/find . -path "./dist" -prune -o -name "*.exe" | sed "s/\.exe$$/\.pdb/" | xargs` $(DIST)/$(BUILDID)
+	-cp `/bin/find . -path "./dist" -prune -o -name "*.EXE" | sed "s/\.EXE$$/\.pdb/" | xargs` $(DIST)/$(BUILDID)
+endif # MOZ_DEBUG_SYMBOLS
+ifdef MOZ_PROFILE
+	echo splitting symbols out of binaries
+	/bin/find $(DIST) -name "*.dll" -exec splitsym {} \;
+	/bin/find $(DIST) -name "*.exe" -exec splitsym {} \;
+	/bin/find $(DIST) -name "*.EXE" -exec splitsym {} \;
+	mkdir -p $(DIST)/$(BUILDID)
+	/bin/find $(DIST) -name "*.dbg" -exec mv {} $(DIST)/$(BUILDID) \;
+endif # MOZ_PROFILE
+endif # MOZILLA_OFFICIAL
+
+signnss:
+ifdef MOZILLA_OFFICIAL
+	echo signing NSS libs
+	cd $(DIST)/bin; ./shlibsign.exe -v -i softokn3.dll
+	cd $(DIST)/bin; ./shlibsign.exe -v -i freebl3.dll
+endif # MOZILLA_OFFICIAL
+
+BUILDID = $(shell cat $(DEPTH)/config/build_number)
+deliver: splitsymbols rebase signnss
+
+endif # WINNT
+

tests/examplefiles/python25-bsd.mak

+# New ports collection makefile for:    python25
+# Date created:         3 July 2003
+# Whom:                 Hye-Shik Chang <perky@FreeBSD.org>
+#
+# $FreeBSD: ports/lang/python25/Makefile,v 1.145 2007/10/03 23:22:04 edwin Exp $
+
+PORTNAME=	python25
+PORTVERSION=	2.5.1
+CATEGORIES=	lang python ipv6
+MASTER_SITES=	${PYTHON_MASTER_SITES}
+MASTER_SITE_SUBDIR=	${PYTHON_MASTER_SITE_SUBDIR}
+DISTFILES=	${PYTHON_DISTFILE}
+
+MAINTAINER=	python@FreeBSD.org
+COMMENT?=	An interpreted object-oriented programming language
+
+DIST_SUBDIR=	python
+WRKSRC=		${PYTHON_WRKSRC}/portbld.static
+PATCH_WRKSRC=	${PYTHON_WRKSRC}
+GNU_CONFIGURE=	yes
+CONFIGURE_TARGET=	--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
+CONFIGURE_SCRIPT=	../configure # must be relative
+CONFIGURE_ENV=	OPT="${CFLAGS}" SVNVERSION="echo freebsd"
+MAKE_ENV=	VPATH="${PYTHON_WRKSRC}"
+INSTALLS_SHLIB=	yes
+INSTALL_TARGET=	altinstall
+MAN1=		${PYTHON_VERSION}.1
+
+USE_PYTHON=	yes
+PYTHON_VERSION=	python2.5
+PYTHON_NO_DEPENDS=	yes
+
+SHARED_WRKSRC=	${PYTHON_WRKSRC}/portbld.shared
+PLIST=		${WRKDIR}/PLIST
+PLIST_TEMPLATE?=${PKGDIR}/pkg-plist
+PLIST_SUB=	PYVER=${PYTHON_VERSION:S/python//} \
+		PYVER_WITHPAT=${PORTVERSION:S/.c/c/}
+DEMODIR=	${PREFIX}/share/examples/${PYTHON_VERSION}
+TOOLSDIR=	${PREFIX}/share/${PYTHON_VERSION}
+
+BIN_SCRIPTS=	idle pydoc python python-shared smtpd.py python-config \
+		python-shared-config
+BINLINKS_SUB=	-e 's,smtpd,smtpd${PYTHON_VER},' \
+		-e 's,(idle|pydoc|python-shared|python),\1${PYTHON_VER},'
+
+OPTIONS=	THREADS "Enable thread support" on \
+		HUGE_STACK_SIZE "Use a larger thread stack" off \
+		UCS4 "Use UCS4 for unicode support" on \
+		PYMALLOC "Use python's internal malloc" on \
+		IPV6 "Enable IPv6 support" on \
+		FPECTL "Enable floating point exception handling" off
+
+.include <bsd.port.pre.mk>
+
+.if ${PYTHON_VERSION} == ${PYTHON_DEFAULT_VERSION}
+MLINKS=		${PYTHON_VERSION}.1 python.1
+PLIST_SUB+=	IF_DEFAULT=""
+.else
+PLIST_SUB+=	IF_DEFAULT="@comment "
+.endif
+
+# workaround for a bug in base curses.h.
+CFLAGS+=	-D__wchar_t=wchar_t
+
+.if !defined(WITHOUT_THREADS)
+CONFIGURE_ARGS+=	--with-threads
+CFLAGS+=		${PTHREAD_CFLAGS}
+.if defined(WITHOUT_HUGE_STACK_SIZE)
+CFLAGS+=		-DTHREAD_STACK_SIZE=0x20000
+.else
+CFLAGS+=		-DTHREAD_STACK_SIZE=0x100000
+.endif # defined(WITHOUT_HUGE_STACK_SIZE)
+CONFIGURE_ENV+=		LDFLAGS="${PTHREAD_LIBS} ${LDFLAGS}"
+.else
+CONFIGURE_ARGS+=	--without-threads
+.if defined(LDFLAGS)
+CONFIGURE_ENV+=		LDFLAGS="${LDFLAGS}"
+.endif # defined(LDFLAGS)
+.endif # !defined(WITHOUT_THREADS)
+
+.if !defined(WITHOUT_UCS4) && !defined(WITH_UCS2)
+CONFIGURE_ARGS+=	--enable-unicode=ucs4
+.endif
+
+.if defined(WITHOUT_PYMALLOC)
+CONFIGURE_ARGS+=        --without-pymalloc
+.endif
+
+.if ${ARCH} == i386
+PLIST_SUB+=	X86_ONLY=""
+.else
+PLIST_SUB+=	X86_ONLY="@comment "
+.endif
+.if ${ARCH} == amd64 || ${ARCH} == ia64 || ${ARCH} == sparc64 || ${ARCH} == alpha
+PLIST_SUB+=     32BIT_ONLY="@comment "
+.else
+PLIST_SUB+=     32BIT_ONLY=""
+.endif
+.if ${ARCH} == sparc64
+CFLAGS+=        -DPYTHON_DEFAULT_RECURSION_LIMIT=900
+.endif
+
+.if !exists(/usr/bin/ypcat) # the world with NO_NIS
+PLIST_SUB+=	NO_NIS="@comment "
+.else
+PLIST_SUB+=	NO_NIS=""
+.endif
+
+.if !defined(WITHOUT_IPV6)
+CONFIGURE_ARGS+= --enable-ipv6
+.else
+CONFIGURE_ARGS+= --disable-ipv6
+.endif
+
+.if defined(WITH_FPECTL)
+CONFIGURE_ARGS+= --with-fpectl
+.endif
+
+.if ${OSVERSION} >= 700000
+PLATFORMS=plat-freebsd4 plat-freebsd5 plat-freebsd6
+.elif ${OSVERSION} >= 600000
+PLATFORMS=plat-freebsd4 plat-freebsd5 plat-freebsd7
+.else
+PLATFORMS=plat-freebsd4 plat-freebsd6 plat-freebsd7
+.endif
+
+pre-patch:
+	${MKDIR} ${WRKSRC} ${SHARED_WRKSRC}/Modules
+	${SED} -e '1s,^.*$$,#!${PREFIX}/bin/${PYTHON_VERSION},' \
+		${PATCH_WRKSRC}/Tools/scripts/pydoc > ${WRKDIR}/pydoc2.5
+	${SED} -e '1s,^.*$$,#!${PREFIX}/bin/${PYTHON_VERSION},' \
+		${PATCH_WRKSRC}/Tools/scripts/idle > ${WRKDIR}/idle2.5
+	${SED} -e '1s,^.*$$,#!${PREFIX}/bin/${PYTHON_VERSION},' \
+		${PATCH_WRKSRC}/Lib/smtpd.py > ${WRKDIR}/smtpd2.5.py
+	${REINPLACE_CMD} -e \
+		's,/usr/doc/python-docs-,${PREFIX}/share/doc/python,g' \
+		${PATCH_WRKSRC}/Lib/pydoc.py
+	${REINPLACE_CMD} -e \
+		's|^\( *prefixes = .*\)\]$$|\1, "${X11BASE}"]|g' \
+		${PATCH_WRKSRC}/Lib/site.py
+	${REINPLACE_CMD} -e \
+		's|^	\(..ASDLGEN.*\)$$|	${TRUE}|g' \
+		${PATCH_WRKSRC}/Makefile.pre.in
+
+	${REINPLACE_CMD} -e \
+		's|*\(..INSTALL_SCRIPT.*\)python-config$$|#port \1|' \
+		${PATCH_WRKSRC}/Makefile.pre.in
+
+	${SED} -e 's|^#!.*|#!${PREFIX}/bin/${PYTHON_VERSION}|' \
+		${PATCH_WRKSRC}/Misc/python-config.in > ${WRKDIR}/${PYTHON_VERSION}-config
+	${SED} -e 's|^#!.*|#!${PREFIX}/bin/${PYTHON_VERSION:S/thon/thon-shared/}|' \
+		${PATCH_WRKSRC}/Misc/python-config.in > ${WRKDIR}/${PYTHON_VERSION:S/thon/thon-shared/}-config
+
+.if defined(WITH_FPECTL) && ${ARCH} == i386
+	${MKDIR} ${WRKSRC}/Modules
+	${ECHO} "fpectl fpectlmodule.c" >> ${WRKSRC}/Modules/Setup.dist
+.endif
+
+post-configure:
+	${TAR} -C ${WRKSRC} -cf - . | ${TAR} -C ${SHARED_WRKSRC} -xf -
+	${LN} -sf ${PYTHON_WRKSRC}/Lib ${WRKSRC}/Lib
+	${SED} -e 's,^\(LDLIBRARY=\).*$$,\1libpython$$(VERSION).so,' \
+		-e 's,^\(BLDLIBRARY=\).*$$,\1-L. -lpython$$(VERSION),' \
+		-e 's,^\(CFLAGSFORSHARED=\).*$$,\1$$(CCSHARED),' \
+		-e 's,^\(Makefile Modules/config.c:.*\)Makefile.pre,\1,' \
+		-e 's,^\(.(BUILDPYTHON)\: .*\).(LIBRARY),\1,' \
+		-e 's,^\(.(BUILDPYTHON):.*\).(LIBRARY),\1,' \
+		${WRKSRC}/Makefile > ${SHARED_WRKSRC}/Makefile
+
+pre-build:
+	cd ${SHARED_WRKSRC}; \
+	${SETENV} ${MAKE_ENV} ${MAKE} lib${PYTHON_VERSION}.so python; \
+	${LN} -f lib${PYTHON_VERSION}.so lib${PYTHON_VERSION}.so.1; \
+	${LN} -f python ${PYTHON_VERSION:S/thon/thon-shared/}
+
+pre-su-install:
+.for platform in ${PLATFORMS}
+	${MKDIR} ${PYTHONPREFIX_LIBDIR}/${platform}
+.for file in IN.py regen
+	${INSTALL_DATA} ${WRKSRC}/Lib/${platform}/${file} \
+		${PYTHONPREFIX_LIBDIR}/${platform}/
+.endfor
+.endfor
+
+pre-install:
+	${CAT} ${PLIST_TEMPLATE} | ${AWK} '{ print $$0; } \
+	/LIBDIR.*\.py$$/ && !/\/bad/ { print $$0 "o"; print $$0 "c"; }'	> ${PLIST}
+
+	@# if openssl 0.9.8 is detected, _sha{256,512} module won't be installed
+	([ -f ${WRKSRC}/.without_own_sha ] && \
+		${GREP} -v 'lib-dynload/_sha' ${PLIST} > ${PLIST}.tmp && \
+		${CAT} ${PLIST}.tmp > ${PLIST}) || ${TRUE}
+
+post-install:
+	@# install config providers
+	${INSTALL_SCRIPT} ${WRKDIR}/${PYTHON_VERSION}-config ${PREFIX}/bin
+	${INSTALL_SCRIPT} ${WRKDIR}/${PYTHON_VERSION:S/thon/thon-shared/}-config ${PREFIX}/bin
+
+	@# shared version of executable and library
+	${INSTALL_PROGRAM} ${SHARED_WRKSRC}/lib${PYTHON_VERSION}.so.1 \
+		${PREFIX}/lib
+	cd ${PREFIX}/lib; ${LN} -sf lib${PYTHON_VERSION}.so.1 \
+		lib${PYTHON_VERSION}.so
+	${LN} -sf ${PREFIX}/lib/lib${PYTHON_VERSION}.so ${PYTHONPREFIX_LIBDIR}/config
+	${INSTALL_PROGRAM} \
+		${SHARED_WRKSRC}/${PYTHON_VERSION:S/thon/thon-shared/} \
+		${PREFIX}/bin
+
+	@# additional files installing by ports
+	${INSTALL_SCRIPT} ${WRKDIR}/pydoc2.5 ${WRKDIR}/idle2.5 \
+		${WRKDIR}/smtpd2.5.py ${PREFIX}/bin
+	@${MKDIR} ${MANPREFIX}/man/man1
+	${INSTALL_MAN} ${PYTHON_WRKSRC}/Misc/python.man \
+		${MANPREFIX}/man/man1/${PYTHON_VERSION}.1
+
+.if ${PYTHON_VERSION} == ${PYTHON_DEFAULT_VERSION}
+	for f in ${BIN_SCRIPTS}; do \
+		TARGET=`${ECHO_CMD} $$f | ${SED} -E ${BINLINKS_SUB}`; \
+		cd ${PREFIX}/bin && ${LN} -f $$TARGET $$f; \
+	done
+.endif
+
+.if !defined(NOPORTDOCS)
+	@${MKDIR} ${TOOLSDIR}
+	@cd ${PYTHON_WRKSRC}; ${TAR} -cf - Tools | \
+		(cd ${TOOLSDIR}; ${TAR} -xf -)
+	@${MKDIR} ${DEMODIR}
+	@cd ${PYTHON_WRKSRC}/Demo; ${TAR} -cf - * | \
+		(cd ${DEMODIR}; ${TAR} -xf -)
+.endif
+
+	@${CAT} ${PKGMESSAGE}
+
+.include <bsd.port.post.mk>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.