Ticket #47315: simplify-makefile.diff

File simplify-makefile.diff, 2.8 KB (added by grimreaper (Eitan Adler), 9 years ago)

avoid touching checked in file

  • Makefile

    MKDIR = /bin/mkdir 
    2020CP       = /bin/cp
    2121RM       = /bin/rm
    2222LN       = /bin/ln
     23ifeq ($(UNAME), Linux)
     24SED = /bin/sed
     25REINPLACE = $(SED) -i -r
     26else
    2327SED      = /usr/bin/sed
    24 ifeq ($(UNAME), Linux)
    25 SED      = /bin/sed
     28REINPLACE = $(SED) -i '' -E
    2629endif
    2730TCLSH    = /usr/bin/tclsh
    2831XSLTPROC = $(PREFIX)/bin/xsltproc
    endif 
    7578            $(GUIDE_XSL) $(GUIDE_SRC)/guide.xml
    7679        # Convert all sections (h1-h9) to a link so it's easy to link to them.
    7780        # If someone knows a better way to do this please change it.
    78 ifeq ($(UNAME), Linux)
    79         $(SED) -i -r -e \
     81        $(REINPLACE) \
    8082            's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
    8183            $(GUIDE_RESULT)/index.html
    82 else
    83         $(SED) -i "" -E \
    84             's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
    85             $(GUIDE_RESULT)/index.html
    86 endif
    8784
    8885# Generate the chunked HTML guide with one section per file.
    8986guide-chunked:
    endif 
    10097            $(GUIDE_XSL_CHUNK) $(GUIDE_SRC)/guide.xml
    10198        # Convert all sections (h1-h9) to a link so it's easy to link to them.
    10299        # If someone knows a better way to do this please change it.
    103 ifeq ($(UNAME), Linux)
    104         $(SED) -i -r -e \
     100        $(REINPLACE) \
    105101            's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
    106102            $(GUIDE_RESULT_CHUNK)/*.html
    107 else
    108         $(SED) -i "" -E \
    109             's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
    110             $(GUIDE_RESULT_CHUNK)/*.html
    111 endif
    112103        # Add the table of contents to every junked HTML file.
    113104        # If someone knows a better way to do this please change it.
    114105        $(TCLSH) toc-for-chunked.tcl $(GUIDE_RESULT_CHUNK)
    man: $(MAN_XSL) 
    134125        $(MKDIR) -p $(MAN_TMP)
    135126        $(CP) $(GUIDE_SRC)/portfile-*.xml $(MAN_TMP)
    136127        $(CP) $(GUIDE_SRC)/portgroup-*.xml $(MAN_TMP)
    137 ifeq ($(UNAME), Linux)
    138         $(SED) -i -r -e 's|<section|<refsection|g' $(MAN_TMP)/*
    139         $(SED) -i -r -e 's|</section>|</refsection>|g' $(MAN_TMP)/*
    140 else
    141         $(SED) -i "" 's|<section|<refsection|g' $(MAN_TMP)/*
    142         $(SED) -i "" 's|</section>|</refsection>|g' $(MAN_TMP)/*
    143 endif
     128        $(REINPLACE) 's|<section|<refsection|g' $(MAN_TMP)/*
     129        $(REINPLACE) 's|</section>|</refsection>|g' $(MAN_TMP)/*
    144130        $(XSLTPROC) --xinclude --output $(MAN_RESULT) $(MAN_XSL) \
    145131            $(MAN_SRC)/port.1.xml \
    146132            $(MAN_SRC)/portfile.7.xml \
    man: $(MAN_XSL) 
    150136
    151137# Create XSL from template for man pages.
    152138$(MAN_XSL):
    153 ifeq ($(UNAME), Linux)
    154         $(SED) -r -e 's:@PREFIX@:$(PREFIX):' $@.in > $@
    155 else
    156         $(SED) 's:@PREFIX@:$(PREFIX):' $@.in > $@
    157 endif
     139        $(CP) $@.in $@.tmp
     140        $(REINPLACE) 's:@PREFIX@:$(PREFIX):' $@.tmp
     141        $(CP) $@.tmp $@
    158142
    159143# Remove all temporary files generated by guide: and man:.
    160144clean: