1# 2# Makefile for 'pcal' under Unix/Linux, DOS+DJGPP, and DOS/Windows+Cygwin 3# 4# Use these commands: 5# 6# Unix/Linux: make 7# 8# DOS+DJGPP: make OS=DJGPP 9# 10# 11# v4.11.0: Bill Marr 12# 13# Provide support for a user-specified destination directory ('$DESTDIR') 14# on the installation step. 15# 16# For example: make DESTDIR=$HOME/test install 17# 18# Remove all remaining references (environment variables, etc) to the 19# unneeded 'pcalinit' items, which were accidentally overlooked in the 20# last release. 21# 22# v4.10.0: Bill Marr 23# 24# Accommodate the fact that the use of 'pcalinit.{c,ps,h}' is no longer 25# needed. PostScript output is now directly generated by C code, without 26# the use of a PostScript template which was converted to a C header file. 27# 28# Eliminate other now-unused files ('pcalglob.h', 'pcalpapr.{c,h}') and add 29# new files ('encvec.c', 'pcallang.c'). 30# 31# Drop support for obsolete platforms (Amiga, VMS, OS/2). 32# 33# Rename 'EPS' definition to 'EPS_DSC' (in order to more clearly show its 34# purpose and to avoid confusion with the embedded EPS image capability for 35# monthly calendars). Enhance comments about its use. 36# 37# Expand the explanation and provide more examples of the use of the 38# timezone setting. 39# 40# Remove the now-unneeded 'VERSION = x.y' declaration. 41# 42# v4.9.1: Bill Marr 43# 44# Fix syntax which causes error when using 'make install' command. 45# 46# v4.9.0: Bill Marr 47# 48# Add comments for new 'MAPFONTS' options to control PostScript character 49# encodings to support multiple languages. 50# 51# Remove obsolete comment about directory usage. Fix minor comment typo. 52# 53# Remove reference to now-obsolete 'Esperanto' character encoding. 54# 55# Enable the '-DSEARCH_PCAL_DIR=0' line by default now, so that the 'pcal' 56# configuration file (a.k.a. the 'date' file, often named 'calendar') will 57# _not_ be looked for in the same directory as the 'pcal' executable file. 58# This prevents erroneous use of a common Unix executable named 'calendar' 59# as a 'pcal' configuration file. This change was done to minimize the 60# deltas applied by the Debian distribution. 61# 62# Bypass some processing of the documentation if the directory specified 63# by 'MANDIR' and/or 'CATDIR' does not exist. This prevents an error 64# during the 'make install' step when building in certain environments 65# (e.g. DOS+DJGPP). 66# 67# v4.8.0: Bill Marr 68# 69# Enhance comments; reverse sense of 'SEARCH_PCAL_DIR' flag so that 70# enabling the commented-out line has the desired effect; remove unused 71# 'make' targets ('compress' and 'uuencode') and now-obsolete list of files 72# for 'TARSRC'; remove refs to obsolete source files; remove now-unneeded 73# specification of paper size; provide for new directory locations for 74# source code, object code, and executable code; merge OS/2 'Makefile.os2' 75# file into this file; add support for DOS+DJGPP building based on a patch 76# from Thiago F.G. Albuquerque; provide a new flag 'BUILD_ENV_xxx' so that 77# we can distinquish the build environment among Unix, OS/2, and DOS+DJGPP 78# at compile time; fixed up the out-of-date target dependency lists 79# 80# v4.7: Andrew Rogers 81# 82# add HTML-specific command-line definitions (cf. pcaldefs.h) 83# delete moon96; add moon98 84# add Makefile.os2 to TARSRC definition 85# parameterize executable names; define pcalinit-specific compiler 86# name (to facilitate cross-builds) 87# 88# v4.6: Andrew Rogers 89# 90# "make compress" creates compressed tar file; "make uuencode" creates 91# uuencode-d version thereof 92# 93# v4.5: Andrew Rogers 94# 95# "make clean" leaves pcal intact but removes other by-products; 96# "make clobber" blows everything away; 97# "make fresh" rebuilds from scratch 98# 99 100# ----------------------------------------------------------------------------- 101# 102# Depending on whether we're compiling for Unix/Linux or DOS+DJGPP, use 103# appropriate values for the OS name, the 'build environment' flag, the names 104# of the executable files, the compiler(s), and the 'PACK' value. 105# 106# The 'PACK' value is used for packing the 'man' page. Note that setting 107# 'PACK' to ":" will cause no packing to be done; otherwise, choose 108# "compress", "pack", or "gzip" as your system requires. 109# 110ifeq ($(OS),DJGPP) # DOS+DJGPP 111 OS_NAME = "DOS+DJGPP" 112 D_BUILD_ENV = -DBUILD_ENV_DJGPP 113 PCAL = pcal.exe 114 CC = gcc 115 PACK = : 116else # Unix 117 OS_NAME = "Unix" 118 D_BUILD_ENV = -DBUILD_ENV_UNIX 119 PCAL = pcal 120 CC = ${HOST_CC} 121 PACK = compress 122 # PACK = pack 123 # PACK = gzip 124endif 125 126# 127# Define various directories for the following items: 128# 129# - source code 130# - object code (and compile-time, auto-generated C header files) 131# - installed 'pcal' executable 132# - documentation 133# - 'man' pages 134# - 'cat' pages 135# 136SRCDIR = src 137OBJDIR = obj 138EXECDIR = exec 139DOCDIR = doc 140 141# 142# Compiling for DOS+DJGPP requires different directories for the installed 143# executable and the 'man'/'cat' pages. Unix uses the values shown below. 144# 145ifeq ($(OS),DJGPP) # DOS+DJGPP 146 BINDIR = $(DJDIR)/bin 147 MANDIR = $(DJDIR)/man/man1 148 CATDIR = $(DJDIR)/man/cat1 149else # Unix 150 BINDIR = ${PREFIX}/bin 151 MANDIR = ${PREFIX}/man/man1 152 CATDIR = ${PREFIX}/man/cat1 153endif 154 155OBJECTS = $(OBJDIR)/pcal.o \ 156 $(OBJDIR)/encvec.o $(OBJDIR)/exprpars.o \ 157 $(OBJDIR)/moonphas.o $(OBJDIR)/pcalutil.o \ 158 $(OBJDIR)/pcallang.o \ 159 $(OBJDIR)/readfile.o $(OBJDIR)/writefil.o 160 161# ------------------------------------------------------------------ 162# 163# Site-specific defaults which may be overridden here (cf. pcallang.h); 164# uncomment the examples below and/or change them to your liking 165# 166 167# 168# Allow the ability to specify an alternate 8-bit character mapping by 169# defining 'MAPFONTS' to one of the following: 170# 171# ENC_LATIN_1 (ISO 8859-1) 172# ENC_LATIN_2 (ISO 8859-2) 173# ENC_LATIN_3 (ISO 8859-3) 174# ENC_LATIN_4 (ISO 8859-4) 175# ENC_CYRILLIC (ISO 8859-5) 176# ENC_ARABIC (ISO 8859-6) (*** unsupported ***) 177# ENC_GREEK (ISO 8859-7) 178# ENC_HEBREW (ISO 8859-8) (*** unsupported ***) 179# ENC_LATIN_5 (ISO 8859-9) 180# ENC_LATIN_6 (ISO 8859-10) 181# ENC_THAI (ISO 8859-11) 182# ENC_LATIN_7 (ISO 8859-13) 183# ENC_LATIN_8 (ISO 8859-14) 184# ENC_LATIN_9 (ISO 8859-15) 185# ENC_LATIN_10 (ISO 8859-16) (*** unsupported ***) 186# ENC_KOI8_R (Russian) 187# ENC_KOI8_U (Ukrainian) 188# ENC_ROMAN8 (Roman8) 189# 190# This is equivalent to the use of the '-r' option. 191# 192# Note that this is not normally needed, since 'pcal' will automatically 193# assign the proper character encoding (if any) depending on the language 194# selected. 195# 196# D_MAPFONTS = -DMAPFONTS=ENC_KOI8_R 197 198# redefine title, date, and notes font/pointsize ('-t', '-d', '-n') 199# D_TITLEFONT = '-DTITLEFONT="Helvetica-Bold/48"' 200# D_DATEFONT = '-DDATEFONT="Helvetica-Bold/28"' 201# D_NOTESFONT = '-DNOTESFONT="Helvetica/8"' 202 203# redefine shading (dates/fillboxes) ('-s') 204# D_SHADING = '-DSHADING="0.6/0.99"' 205 206# specify American (USA_DATES) or European (EUR_DATES) date parsing ('-A', '-E') 207# D_DATE_STYLE = -DDATE_STYLE=USA_DATES 208 209# specify first (leftmost) weekday on calendar ('-F') 210# D_FIRST_DAY = -DFIRST_DAY=MON 211 212# 213# Specify the timezone ('-z') for determining the correct day when 214# calculating the moon phases: 215# 216# "0" = UTC/GMT (default) 217# "5" = New York EST 218# "-3" = Moscow 219# "-5.5" = India 220# 221# D_TIMEZONE = '-DTIMEZONE="5 [New York EST]"' 222# D_TIMEZONE = '-DTIMEZONE="4 [New York EDT]"' 223# D_TIMEZONE = '-DTIMEZONE="8 [Los Angeles PST]"' 224# D_TIMEZONE = '-DTIMEZONE="7 [Los Angeles PDT]"' 225# D_TIMEZONE = '-DTIMEZONE="-3 [Moscow]"' 226# D_TIMEZONE = '-DTIMEZONE="-5.5 [India]"' 227 228# 229# This flag controls the generation of EPS-like PostScript Document 230# Structuring Conventions (DSC) so that the output contains enhanced comments 231# ('%%Page:', etc.) that are necessary for programs like 'psnup' to do useful 232# things with the generated calendars. These comments also allow PostScript 233# previewer applications to page up to the previous page. 234# 235D_EPS_DSC = -DEPS_DSC 236 237# specify default language 238# D_LANGUAGE = -DLANG_DEFAULT=LANG_ENGLISH 239 240# customize HTML output 241# D_BGCOLOR = '-DBGCOLOR="ffffff"' 242# D_BACKGROUND = -DBACKGROUND=NULL 243# D_TEXT = -DTEXT=NULL 244# D_LINK = -DLINK=NULL 245# D_ALINK = -DALINK=NULL 246# D_VLINK = -DVLINK=NULL 247# D_HOLIDAY_PRE = '-DHOLIDAY_PRE="<font color=\"ff0000\"><b>"' 248# D_HOLIDAY_POST = '-DHOLIDAY_POST="</b></font>"' 249# D_BLANK_STYLE = '-DDIVIDE_BLANK_SPACE=0' 250 251# 252# This flag controls whether 'pcal' will search for the calendar 253# control/options file ('calendar') in the directory where the 'pcal' 254# executable code resides. Disabling this flag (by enabling the line below) 255# prevents the search, thereby avoiding a potential conflict with any program 256# named 'calendar' which has also been installed there. Note that the 257# 'pcaldefs.h' source code file enables this search by default, unless it has 258# been overridden here. 259# 260D_SEARCH_PCAL_DIR = '-DSEARCH_PCAL_DIR=0' 261 262# ------------------------------------------------------------------ 263 264COPTS = $(D_MAPFONTS) $(D_TITLEFONT) $(D_DATEFONT) $(D_NOTESFONT) \ 265 $(D_SHADING) $(D_DATE_STYLE) $(D_FIRST_DAY) $(D_TIMEZONE) \ 266 $(D_EPS_DSC) $(D_LANGUAGE) $(D_BGCOLOR) $(D_BACKGROUND) \ 267 $(D_TEXT) $(D_LINK) $(D_ALINK) $(D_VLINK) \ 268 $(D_HOLIDAY_PRE) $(D_HOLIDAY_POST) $(D_BLANK_STYLE) \ 269 $(D_SEARCH_PCAL_DIR) $(D_BUILD_ENV) 270 271# 272# Depending on whether we're compiling for Unix/Linux or DOS+DJGPP, use 273# appropriate values as flags for the C compiler. 274# 275# '-O2' enables a 2nd-level code optimization 276# '-Wall' enables many compile-time warning messages 277# '-W' enables some additional compile-time warning messages 278# 279ifeq ($(OS),DJGPP) # DOS+DJGPP 280 CFLAGS = -Wall -W 281else # Unix 282 CFLAGS = -O2 -Wall -W 283endif 284 285$(EXECDIR)/$(PCAL): $(OBJECTS) 286 $(CC) $(LDFLAGS) -o $(EXECDIR)/$(PCAL) $(OBJECTS) -lm 287 @ echo Build of $(PCAL) for $(OS_NAME) completed. 288 289$(OBJDIR)/encvec.o: $(SRCDIR)/encvec.c 290 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/encvec.c 291 292$(OBJDIR)/exprpars.o: $(SRCDIR)/exprpars.c $(SRCDIR)/pcaldefs.h \ 293 $(SRCDIR)/protos.h 294 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/exprpars.c 295 296$(OBJDIR)/moonphas.o: $(SRCDIR)/moonphas.c $(SRCDIR)/pcaldefs.h \ 297 $(SRCDIR)/pcallang.h \ 298 $(SRCDIR)/protos.h 299 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/moonphas.c 300 301$(OBJDIR)/pcal.o: $(SRCDIR)/pcal.c $(SRCDIR)/pcaldefs.h \ 302 $(SRCDIR)/pcallang.h \ 303 $(SRCDIR)/protos.h 304 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/pcal.c 305 306$(OBJDIR)/pcallang.o: $(SRCDIR)/pcallang.c $(SRCDIR)/pcallang.h \ 307 $(SRCDIR)/pcaldefs.h 308 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/pcallang.c 309 310$(OBJDIR)/pcalutil.o: $(SRCDIR)/pcalutil.c $(SRCDIR)/pcaldefs.h \ 311 $(SRCDIR)/pcallang.h \ 312 $(SRCDIR)/protos.h 313 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/pcalutil.c 314 315$(OBJDIR)/readfile.o: $(SRCDIR)/readfile.c $(SRCDIR)/pcaldefs.h \ 316 $(SRCDIR)/pcallang.h \ 317 $(SRCDIR)/protos.h 318 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/readfile.c 319 320$(OBJDIR)/writefil.o: $(SRCDIR)/writefil.c $(SRCDIR)/pcaldefs.h \ 321 $(SRCDIR)/pcallang.h \ 322 $(SRCDIR)/protos.h 323 $(CC) $(CFLAGS) $(COPTS) -o $@ -c $(SRCDIR)/writefil.c 324 325# 326# This target will delete everything except the 'pcal' executable. 327# 328clean: 329 rm -f $(OBJECTS) \ 330 $(DOCDIR)/pcal.cat $(DOCDIR)/pcal-help.ps \ 331 $(DOCDIR)/pcal-help.html $(DOCDIR)/pcal-help.txt 332 333# 334# This target will delete everything, including the 'pcal' executable. 335# 336clobber: clean 337 rm -f $(EXECDIR)/$(PCAL) 338 339# 340# This target will delete everything and rebuild 'pcal' from scratch. 341# 342fresh: clobber $(PCAL) 343 344man: $(DOCDIR)/pcal.man 345 nroff -man $(DOCDIR)/pcal.man > $(DOCDIR)/pcal.cat 346 groff -man -Tps $(DOCDIR)/pcal.man >$(DOCDIR)/pcal-help.ps 347 groff -man -Thtml $(DOCDIR)/pcal.man >$(DOCDIR)/pcal-help.html 348 groff -man -Tascii $(DOCDIR)/pcal.man >$(DOCDIR)/pcal-help.txt 349 350install: $(EXECDIR)/$(PCAL) man 351 mkdir -p $(DESTDIR)/$(BINDIR) 352 mkdir -p $(DESTDIR)/$(MANDIR) 353 mkdir -p $(DESTDIR)/$(CATDIR) 354 cp $(EXECDIR)/$(PCAL) $(DESTDIR)/$(BINDIR) 355 cp $(DOCDIR)/pcal.man $(DESTDIR)/$(MANDIR)/pcal.1 356 $(PACK) $(DESTDIR)/$(MANDIR)/pcal.1 357 cp $(DOCDIR)/pcal.cat $(DESTDIR)/$(CATDIR)/pcal.1 358 $(PACK) $(DESTDIR)/$(CATDIR)/pcal.1 359