🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3716

Re: how to do this with Makefile

#3716
From: Pascal Bourguignon
Date: Thu, 14 Dec 2006 00:39
62 lines
3382 bytes
"FangQ" <fangqq@gmail.com> writes:

> hi
>
> I am writing a Makefile to convert a bdf file into different pcf files
> corresponding to different unicode ranges, the striped down version of
> my Makefile looks like the following
>
> B2P=bdftopcf
> SLICE=bdfmerge.pl
>
> CJKBASIC=0x4E00--0x9FA5
> CJKEXTA=0x3400--0x4DB5
> CJK1=0x1100--0x11FF 0x2460--0x24EA
> CJK2=0x2605--0x2606 0x262F--0x2637
> CJK3=0x3105--0x312C 0x3131--0x318E
>
> RANGE=$(CJKBASIC) $(CJKEXTA) $(CJK1) $(CJK2) $(CJK3)
>
> cjk0: RANGE=$(CJKBASIC)
> cjka: RANGE=$(CJKEXTA)
> cjk: $(SLICE)
> 	$(SLICE) $(RANGE) $(R9).bdf  > $(R9)_cjk.bdf
> 	$(SLICE) $(RANGE) $(R10).bdf > $(R10)_cjk.bdf
> 	$(SLICE) $(RANGE) $(R11).bdf > $(R11)_cjk.bdf
> 	$(B2P) $(R9)_cjk.bdf  > $(R9).pcf
> 	$(B2P) $(R10)_cjk.bdf > $(R10).pcf
> 	$(B2P) $(R11)_cjk.bdf > $(R11).pcf
>
> (the above code snip does not work, as you may notice)
>
> what I want to do is when user make different targets, I want the
> variable RANGE to change its value correspondingly. However, I don't
> want to repeat the command block for each target.
>
> I believe there must be an elegant way of doing this, i.e. set
> variables differently for each target and execute a common set of
> commands. However, I can not find it after an hour of search, so I hope
> someone can help me up.

What I do:

cjk0:
	$(MAKE) $(MFLAGS) RANGE=$(CJKBASIC) cjk

cjka:
	$(MAKE) $(MFLAGS) RANGE=$(CJKEXTA)  cjk

cjk: $(SLICE)
	[ -z $(RANGE) ] && (echo must define RANGE ; exit 1) || true
 	$(SLICE) $(RANGE) $(R9).bdf  > $(R9)_cjk.bdf
 	$(SLICE) $(RANGE) $(R10).bdf > $(R10)_cjk.bdf
 	$(SLICE) $(RANGE) $(R11).bdf > $(R11)_cjk.bdf
 	$(B2P) $(R9)_cjk.bdf  > $(R9).pcf
 	$(B2P) $(R10)_cjk.bdf > $(R10).pcf
 	$(B2P) $(R11)_cjk.bdf > $(R11).pcf

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
You're always typing.
Well, let's see you ignore my
sitting on your hands.
Technical Details
Message-ID: <87d56nnwe2.fsf@thalassa.informatimago.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news-ber1.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <1166056492.050495.19580@73g2000cwn.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: fc89c,ae7c4df633e2435b
X-Google-Thread: 109f73,ae7c4df633e2435b
X-Google-Attributes: gidfc89c,gid109f73,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news-ber1.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Pascal Bourguignon <pjb@informatimago.com>
Newsgroups: comp.unix.programmer,gnu.utils.help
Subject: Re: how to do this with Makefile
Date: Thu, 14 Dec 2006 01:39:33 +0100
Organization: Informatimago
Lines: 62
Message-ID: <87d56nnwe2.fsf@thalassa.informatimago.com>
References: <1166056492.050495.19580@73g2000cwn.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: individual.net pvoZYE7WSv4+GTUzt3AsuwrfCzQnCH2iT7W76jhMtKj5qaM+RZ
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA
      oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9
      033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac
      l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR
      mV+hO/VvFAAAAABJRU5ErkJggg==
X-Accept-Language:         fr, es, en
X-Disabled: X-No-Archive: no
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux)
Cancel-Lock: sha1:pfZCpyW/JhrjmPAn+PzqUKTnn+M=