1# 2# Makefile for Yadex 3# Copyright � Andr� Majorel 1998-2003. 4# AYM 1998-06-10 5# 6 7# ATTENTION : GNU MAKE IS REQUIRED ! This makefile uses pattern 8# rules, addprefix, addsuffix, etc. It's not named "GNUmakefile" 9# for nothing. 10 11######################################################################## 12# 13# Definitions that only hackers 14# might want to change 15# 16######################################################################## 17 18# The name of the directory where objects and 19# binaries are put. I include the output of 20# "uname -a" to make it easier for me to build 21# Yadex for different platforms from the same 22# source tree. 23SYSTEM := $(shell echo `uname -n`_`uname -a | cksum` | tr -dc '[:alnum:]._-') 24OBJDIR = obj/0 25DOBJDIR = dobj/0 26OBJPHYSDIR = obj/$(SYSTEM) 27DOBJPHYSDIR = dobj/$(SYSTEM) 28OBJDIR_ATCLIB = $(OBJDIR)/atclib 29DOBJDIR_ATCLIB = $(DOBJDIR)/atclib 30OBJPHYSDIR_ATCLIB = $(OBJPHYSDIR)/atclib 31DOBJPHYSDIR_ATCLIB = $(DOBJPHYSDIR)/atclib 32 33# Create all directories and make symlinks to 34# config.cc and config.h. Doing it at the start 35# makes things much simpler later on. 36DUMMY := $(shell \ 37 mkdir -p $(OBJPHYSDIR) $(OBJPHYSDIR_ATCLIB); \ 38 mkdir -p $(DOBJPHYSDIR) $(DOBJPHYSDIR_ATCLIB); \ 39 [ ! -h $(OBJDIR) ] || rm $(OBJDIR); \ 40 [ ! -h $(DOBJDIR) ] || rm $(DOBJDIR); \ 41 ln -s $(SYSTEM) $(OBJDIR); \ 42 ln -s $(SYSTEM) $(DOBJDIR); \ 43 ) 44 45include $(OBJDIR)/Makefile.config 46 47######################################################################## 48# 49# Definitions that end users 50# might want to change 51# 52######################################################################## 53 54# Which OS ? 55OS := $(shell uname -s | tr A-Z a-z) 56 57# Where your X11 libraries and headers reside. 58# Current rule: 59# - AIX has them in /usr/lpp/X11/{lib,include}, 60# - Solaris has them in /usr/openwin/{lib,include}, 61# - all other unices in /usr/X11R6/{lib,include}. 62ifeq ($(findstring $(OS), aix), $(OS)) 63 X11LIBDIR = /usr/lpp/X11/lib 64 X11INCLUDEDIR = /usr/lpp/X11/include 65else 66 ifeq ($(findstring $(OS), solaris sunos), $(OS)) 67 X11LIBDIR = /usr/openwin/lib 68 X11INCLUDEDIR = /usr/openwin/include 69 else 70 X11LIBDIR = $(LOCALBASE)/lib 71 X11INCLUDEDIR = $(LOCALBASE)/include 72 endif 73endif 74 75# $(CC) and $(CXX) are the C and C++ compiler respectively. They're 76# normally autodetected by ./configure and passed to make through 77# obj/0/Makefile.config. 78#CC = 79#CXX = 80 81# Options used when compiling Atclib. 82#CFLAGS = -O 83 84# Options used when compiling and linking Yadex. 85# ld is invoked through the C++ compiler so 86# LDFLAGS should not contain options that mean 87# something to the C++ compiler. 88#CXXFLAGS = -O 89#CXXFLAGS += -DWHITE_BACKGROUND 90#LDFLAGS = 91 92# Options used to compile and link the debugging 93# targets. Not used by normal end-user targets. 94# Unlike CFLAGS, CXXFLAGS and LDFLAGS, assume 95# GCC/EGCS. 96DCFLAGS = -g -O 97DCFLAGS += -Wall # GCC warnings 98DCFLAGS += -pedantic # GCC warnings 99DCFLAGS += -Wno-parentheses # GCC warnings 100DCFLAGS += -Wpointer-arith # GCC warnings 101DCFLAGS += -Wcast-qual # GCC warnings 102DCFLAGS += -Wcast-align # GCC warnings 103DCFLAGS += -Wwrite-strings # GCC warnings 104DCFLAGS += -Wmissing-declarations # GCC warnings 105DCFLAGS += -Wmissing-prototypes # GCC warnings 106DCFLAGS += -Winline # GCC warnings 107DCFLAGS += -pg # Profiling 108 109DCXXFLAGS = -g -O 110DCXXFLAGS += -Wall # GCC warnings 111DCXXFLAGS += -pedantic # GCC warnings 112DCXXFLAGS += -Wno-parentheses # GCC warnings 113DCXXFLAGS += -Wpointer-arith # GCC warnings 114DCXXFLAGS += -Wcast-qual # GCC warnings 115DCXXFLAGS += -Wcast-align # GCC warnings 116DCXXFLAGS += -Wwrite-strings # GCC warnings 117DCXXFLAGS += -Wmissing-declarations # GCC warnings 118DCXXFLAGS += -Wmissing-prototypes # GCC warnings 119#DCXXFLAGS += -Winline # GCC warnings 120DCXXFLAGS += -pg # Profiling 121 122DLDFLAGS = 123DLDFLAGS += -pg # Profiling 124#DLDFLAGS += -lefence # Electric Fence 125 126 127######################################################################## 128# 129# Definitions that only hackers 130# might want to change 131# 132######################################################################## 133 134MAKEFILE = GNUmakefile 135VERSION := $(shell cat VERSION) 136VERPREV := $(shell test -f VERPREV && cat VERPREV) 137 138# All the modules of Yadex without path or extension. 139MODULES_YADEX = \ 140 acolours aym bench bitvec \ 141 cfgfile checks colour1 colour2 \ 142 colour3 colour4 config credits \ 143 dependcy dialog disppic drawmap \ 144 edisplay editgrid editlev editloop \ 145 editobj editsave endian editzoom \ 146 entry entry2 events flats \ 147 game gcolour1 gcolour2 gcolour3 \ 148 geom gfx gfx2 gfx3 \ 149 gotoobj help1 help2 highlt \ 150 img imgscale imgspect infobar \ 151 input l_align l_centre l_flags \ 152 l_misc l_prop l_unlink l_vertices \ 153 levels lists locate lumpdir \ 154 macro memory menubar menu \ 155 mkpalette mouse names nop \ 156 objects objinfo oldmenus palview \ 157 patchdir pic2img prefer s_centre \ 158 s_door s_lift s_linedefs s_merge \ 159 s_misc s_prop s_slice s_split \ 160 s_swapf s_vertices sanity scrnshot \ 161 selbox selectn selpath selrect \ 162 serialnum spritdir sticker swapmem \ 163 t_centre t_flags t_prop t_spin \ 164 textures things trace v_centre \ 165 v_merge v_polyg vectext verbmsg \ 166 version wadfile wadlist wadnamec \ 167 wadres wads wads2 warn \ 168 windim x_centre x_exchng x_hover \ 169 x_mirror x_rotate x11 xref \ 170 yadex ytime 171 172# All the modules of Atclib without path or extension. 173MODULES_ATCLIB = \ 174 al_adigits al_aerrno al_astrerror al_fana \ 175 al_fnature al_lateol al_lcount al_lcreate \ 176 al_ldelete al_ldiscard al_lgetpos al_linsert \ 177 al_linsertl al_llength al_lpeek al_lpeekl \ 178 al_lpoke al_lpokel al_lptr al_lread \ 179 al_lreadl al_lrewind al_lseek al_lsetpos \ 180 al_lstep al_ltell al_lwrite al_lwritel \ 181 al_sapc al_saps al_scps al_scpslower \ 182 al_sdup al_sisnum al_strolc 183 184# The source files of Yadex and Atclib 185SRC_YADEX = $(addprefix src/, $(addsuffix .cc, $(MODULES_YADEX))) 186SRC_ATCLIB = $(addprefix atclib/, $(addsuffix .c, $(MODULES_ATCLIB))) 187 188# The headers of Yadex and Atclib 189HEADERS_YADEX := $(wildcard src/*.h) 190HEADERS_ATCLIB = atclib/atclib.h 191 192# All the source files, including the headers. 193SRC = $(filter-out src/config.cc, $(SRC_YADEX)) \ 194 $(filter-out src/config.h, $(HEADERS_YADEX)) \ 195 $(SRC_ATCLIB) $(HEADERS_ATCLIB) 196 197# The files on which youngest is run. 198SRC_NON_GEN = $(filter-out src/credits.cc src/prefix.cc src/version.cc, $(SRC)) 199 200# The object files 201OBJ_CONFIG =# $(OBJDIR)/config.o 202DOBJ_CONFIG =# $(DOBJDIR)/config.o 203OBJ_YADEX = $(addprefix $(OBJDIR)/, $(addsuffix .o, $(MODULES_YADEX))) 204DOBJ_YADEX = $(addprefix $(DOBJDIR)/, $(addsuffix .o, $(MODULES_YADEX))) 205OBJ_ATCLIB = $(addprefix $(OBJDIR_ATCLIB)/, $(addsuffix .o,$(MODULES_ATCLIB))) 206DOBJ_ATCLIB = $(addprefix $(DOBJDIR_ATCLIB)/, $(addsuffix .o,$(MODULES_ATCLIB))) 207 208# The game definition files. 209YGD = $(addprefix ygd/, \ 210 doom.ygd doom02.ygd doom04.ygd doom05.ygd \ 211 doom2.ygd doompr.ygd heretic.ygd hexen.ygd \ 212 strife.ygd strife10.ygd) 213 214# Files that are used with scripts/process to 215# generate files that are included in the 216# distribution archive. 217DOC1_SRC = \ 218 docsrc/README \ 219 docsrc/README.doc 220 221# Files that are used with scripts/process to 222# generate files that go in the doc/ directory 223# and are NOT included in the archive. 224DOC2_SRC_HTML = \ 225 docsrc/advanced.html \ 226 docsrc/contact.html \ 227 docsrc/credits.html \ 228 docsrc/deu_diffs.html \ 229 docsrc/editing_docs.html \ 230 docsrc/faq.html \ 231 docsrc/feedback.html \ 232 docsrc/getting_started.html \ 233 docsrc/hackers_guide.html \ 234 docsrc/help.html \ 235 docsrc/index.html \ 236 docsrc/keeping_up.html \ 237 docsrc/legal.html \ 238 docsrc/packagers_guide.html \ 239 docsrc/palette.html \ 240 docsrc/reporting.html \ 241 docsrc/tips.html \ 242 docsrc/trivia.html \ 243 docsrc/trouble.html \ 244 docsrc/users_guide.html \ 245 docsrc/wad_specs.html \ 246 docsrc/ygd.html 247 248DOC2_SRC_MISC = \ 249 docsrc/yadex.6 \ 250# docsrc/yadex.lsm\ 251 252# Files that must be put in the distribution 253# archive. Most (but not all) are generated from 254# $(DOC1_SRC_*) into the base directory. 255DOC1 = FAQ README doc/README 256 257# Files that go in the doc/ directory and must 258# NOT be put in the distribution archive. Most 259# are either generated from $(DOC2_SRC_*) or 260# symlinked for docsrc/*.png. 261DOC2 = $(addprefix doc/, $(PIX) $(notdir $(DOC2_SRC_HTML) $(DOC2_SRC_MISC))) 262 263# Misc. other files that must be put in the 264# distribution archive. 265MISC_FILES = \ 266 boost/boost/config.hpp \ 267 boost/boost/config/compiler/borland.hpp \ 268 boost/boost/config/compiler/comeau.hpp \ 269 boost/boost/config/compiler/common_edg.hpp \ 270 boost/boost/config/compiler/compaq_cxx.hpp \ 271 boost/boost/config/compiler/gcc.hpp \ 272 boost/boost/config/compiler/greenhills.hpp \ 273 boost/boost/config/compiler/hp_acc.hpp \ 274 boost/boost/config/compiler/intel.hpp \ 275 boost/boost/config/compiler/kai.hpp \ 276 boost/boost/config/compiler/metrowerks.hpp \ 277 boost/boost/config/compiler/mpw.hpp \ 278 boost/boost/config/compiler/sgi_mipspro.hpp \ 279 boost/boost/config/compiler/sunpro_cc.hpp \ 280 boost/boost/config/compiler/vacpp.hpp \ 281 boost/boost/config/compiler/visualc.hpp \ 282 boost/boost/config/platform/aix.hpp \ 283 boost/boost/config/platform/beos.hpp \ 284 boost/boost/config/platform/bsd.hpp \ 285 boost/boost/config/platform/cygwin.hpp \ 286 boost/boost/config/platform/hpux.hpp \ 287 boost/boost/config/platform/irix.hpp \ 288 boost/boost/config/platform/linux.hpp \ 289 boost/boost/config/platform/macos.hpp \ 290 boost/boost/config/platform/solaris.hpp \ 291 boost/boost/config/platform/win32.hpp \ 292 boost/boost/config/posix_features.hpp \ 293 boost/boost/config/select_compiler_config.hpp \ 294 boost/boost/config/select_platform_config.hpp \ 295 boost/boost/config/select_stdlib_config.hpp \ 296 boost/boost/config/stdlib/dinkumware.hpp \ 297 boost/boost/config/stdlib/libstdcpp3.hpp \ 298 boost/boost/config/stdlib/modena.hpp \ 299 boost/boost/config/stdlib/msl.hpp \ 300 boost/boost/config/stdlib/roguewave.hpp \ 301 boost/boost/config/stdlib/sgi.hpp \ 302 boost/boost/config/stdlib/stlport.hpp \ 303 boost/boost/config/stdlib/vacpp.hpp \ 304 boost/boost/config/suffix.hpp \ 305 boost/boost/config/user.hpp \ 306 boost/boost/smart_ptr.hpp \ 307 boost/boost/static_assert.hpp \ 308 boost/boost/utility.hpp \ 309 boost/boost/utility/base_from_member.hpp \ 310 boost/boost/utility_fwd.hpp \ 311 cache/copyright.man \ 312 cache/copyright.txt \ 313 cache/pixlist \ 314 cache/srcdate \ 315 cache/uptodate \ 316 configure \ 317 docsrc/copyright \ 318 CHANGES \ 319 COPYING \ 320 COPYING.LIB \ 321 GNUmakefile \ 322 Makefile \ 323 TODO \ 324 VERSION \ 325 yadex.cfg \ 326 yadex.dep 327 328# The images used in the HTML doc. FIXME: "<img" 329# and "src=" have to be on the same line. These 330# are symlinked into doc/ when $(DOC2) is made. 331PIX = $(shell cat cache/pixlist) 332 333# The script files. 334SCRIPTS = $(addprefix scripts/, \ 335 copyright \ 336 ftime.1 \ 337 ftime.c \ 338 install.c \ 339 mkinstalldirs \ 340 notexist.c \ 341 process \ 342 youngest) 343 344# The patches 345PATCHES = $(addprefix patches/, \ 346 README \ 347 1.5.0_gcc27.diff) 348 349# All files that must be put in the distribution archive. 350ARC_FILES = $(sort $(DOC1) $(DOC1_SRC) $(DOC2_SRC_HTML) $(DOC2_SRC_MISC)\ 351 $(MISC_FILES) $(addprefix docsrc/, $(PIX)) $(SCRIPTS) $(SRC) $(YGD)\ 352 $(PATCHES)) 353 354# The "root" directory of the archives. The 355# basename of the archives is also based on this. 356ARCHIVE := yadex-$(VERSION) 357ARCPREV := yadex-$(VERPREV) 358ARCDIFF := yadex-$(VERSION).diff 359 360# Cosmetic 361CFLAGS := $(strip $(CFLAGS)) 362DCFLAGS := $(strip $(DCFLAGS)) 363CXXFLAGS := $(strip $(CXXFLAGS)) 364DCXXFLAGS := $(strip $(DCXXFLAGS)) 365LDFLAGS := $(strip $(LDFLAGS)) 366DLDFLAGS := $(strip $(DLDFLAGS)) 367 368 369######################################################################## 370# 371# Targets for 372# end users. 373# 374######################################################################## 375 376.PHONY: all 377all: doc yadex.dep yadex $(YGD) 378 379.PHONY: yadex 380yadex: $(OBJDIR)/yadex 381 382$(OBJDIR)/yadex: $(OBJ_CONFIG) $(OBJ_YADEX) $(OBJ_ATCLIB) $(MAKEFILE) 383 @echo "** Linking Yadex" 384 $(CXX) $(OBJ_CONFIG) $(OBJ_YADEX) $(OBJ_ATCLIB) -o $@ \ 385 -L$(X11LIBDIR) -lX11 -lm -lc $(LDFLAGS) 386 387.PHONY: test 388test: 389 $(OBJDIR)/yadex $(A) 390 391.PHONY: install 392install: $(OBJDIR)/install 393 @scripts/mkinstalldirs $(DESTDIR)$(BINDIR) 394 @scripts/mkinstalldirs $(DESTDIR)$(ETCDIR) 395 @scripts/mkinstalldirs $(DESTDIR)$(MANDIR) 396 @scripts/mkinstalldirs $(DESTDIR)$(MANDIR)/man6 397 @scripts/mkinstalldirs $(DESTDIR)$(SHAREDIR) 398 rm -f $(DESTDIR)$(BINDIR)/yadex 399 $(BSD_INSTALL_PROGRAM) $(OBJDIR)/yadex $(DESTDIR)$(BINDIR) 400 rm -f $(DESTDIR)$(MANDIR)/man6/yadex.6* 401 $(BSD_INSTALL_MAN) doc/yadex.6 $(DESTDIR)$(MANDIR)/man6 402 $(BSD_INSTALL_DATA) $(YGD) $(DESTDIR)$(SHAREDIR) 403 $(BSD_INSTALL_DATA) yadex.cfg $(DESTDIR)$(ETCDIR) 404ifndef DESTDIR 405 @echo "---------------------------------------------------------------" 406 @echo " Yadex is now installed." 407 @echo 408 @echo " Before you run it, enter the paths to your iwads in" 409 @echo " $(ETCDIR)/yadex.cfg or ~/.yadex/yadex.cfg." 410 @echo " When you're done, type \"yadex\" to start." 411 @echo " If you're confused, take a look at doc/index.html." 412 @echo 413 @echo " Happy editing !" 414 @echo "---------------------------------------------------------------" 415endif 416 417.PHONY: clean 418clean: 419 rm -f $(OBJ_CONFIG) $(OBJ_YADEX) $(OBJ_ATCLIB) $(OBJDIR)/yadex 420 rm -f $(DOBJ_CONFIG) $(DOBJ_YADEX) $(DOBJ_ATCLIB) $(DOBJDIR)/yadex 421 rm -f $(OBJDIR)/ftime 422 rm -f $(OBJDIR)/install 423 rm -f $(OBJDIR)/notexist 424 rm -f $(OBJDIR) 425 rm -f $(DOBJDIR) 426 rm -rf doc 427 428.PHONY: dclean 429dclean: 430 rm -rf $(DOBJPHYSDIR) 431 rm -f $(DOBJDIR) 432 433.PHONY: doc 434doc: cache/pixlist docdirs $(DOC1) doc2 435 436# Have to put it separately because evaluation 437# of $(DOC2) requires cache/pixlist to exist. 438.PHONY: doc2 439doc2: $(DOC2) 440 441.PHONY: help 442help: 443 @echo User targets: 444 @echo "make [all] Build everything" 445 @echo "make yadex Build Yadex" 446 @echo "make test [A=args] Test Yadex" 447 @echo "make install Install everything" 448 @echo "make showconf Show current configuration" 449 @echo 450 @echo Hacker targets: 451 @echo "make dall Build debug version of everything" 452 @echo "make dyadex Build debug version of Yadex" 453 @echo "make dtest [A=args] Test debug version of Yadex" 454 @echo "make dg Run debug version of Yadex through gdb" 455 @echo "make dd Run debug version of Yadex through ddd" 456 @echo "make doc Update doc" 457 @echo "make man View man page with man" 458 @echo "make dvi View man page with xdvi" 459 @echo "make ps View man page with gv" 460 @echo "make dist Create distribution archive" 461 @echo "make save Create backup archive" 462 463 464######################################################################## 465# 466# Targets meant for 467# hackers only. 468# 469######################################################################## 470 471# d: Compile and run 472.PHONY: d 473d: dyadex dtest 474 475.PHONY: save 476save: 477 tar -cjvf yadex-$$(date '+%Y%m%d').tar.bz2 \ 478 --exclude "*.wad" \ 479 --exclude "*.zip" \ 480 --exclude "core" \ 481 --exclude "dos/*" \ 482 --exclude "obj" \ 483 --exclude "dobj" \ 484 --exclude "old/*" \ 485 --exclude "*~" \ 486 --exclude "*.bak" \ 487 --exclude "web/arc" \ 488 --exclude yadex-$$(date '+%Y%m%d').tar.bz2 \ 489 . 490 491.PHONY: dall 492dall: yadex.dep dyadex $(YGD) 493 494.PHONY: dyadex 495dyadex: $(DOBJDIR)/yadex 496 497$(DOBJDIR)/yadex: $(DOBJ_CONFIG) $(DOBJ_YADEX) $(DOBJ_ATCLIB) $(MAKEFILE) 498 @echo "** Linking Yadex" 499 $(CXX) $(DOBJ_CONFIG) $(DOBJ_YADEX) $(DOBJ_ATCLIB) -o $@ \ 500 -L$(X11LIBDIR) -lX11 -lm -lc $(DLDFLAGS) 501 502.PHONY: dtest 503dtest: 504 $(DOBJDIR)/yadex $(A) 505 gprof $(DOBJDIR)/yadex >gprof.out 506 507.PHONY: dg 508dg: 509 gdb $(DOBJDIR)/yadex 510 511.PHONY: dd 512dd: 513 ddd $(DOBJDIR)/yadex 514 515.PHONY: asm 516asm: $(addprefix $(OBJDIR)/, $(addsuffix .S, $(MODULES_YADEX))) 517 518# Generate the distribution archives. Requires GNU tar, 519# GNU cp, gzip and optionally bzip2 (if distbz2 is 520# uncommented). 521.PHONY: dist 522dist: changes distimage distgz distdiff #distbz2 523 @echo "** Removing distribution image tree $(ARCHIVE)" 524 rm -r $(ARCHIVE) 525 526.PHONY: distimage 527distimage: all $(ARC_FILES) 528 @echo "** Creating distribution image tree $(ARCHIVE)" 529 rm -rf $(ARCHIVE) 530 scripts/mkinstalldirs $(ARCHIVE) 531 @tar -cf - $(ARC_FILES) | (cd $(ARCHIVE); tar -xf -) 532 533.PHONY: distgz 534distgz: distimage 535 @echo "** Creating tar.gz distribution" 536 tar -czf $(ARCHIVE).tar.gz $(ARCHIVE) 537 538.PHONY: distbz2 539distbz2: distimage 540 @echo "** Creating .tar.bz2 distribution" 541 tar -cIf $(ARCHIVE).tar.bz2 $(ARCHIVE) 542 543.PHONY: distdiff 544TMP0 = $$HOME/tmp 545TMPPREV = $(TMP0)/$(ARCPREV) 546TMPCURR = $(TMP0)/$(ARCHIVE) 547distdiff: 548 @echo "** Building the diff distribution" 549 @echo "Creating the diff" 550 rm -rf $(TMPPREV) $(TMPCURR) $(TMPDIFF) 551 mkdir -p $(TMP0) 552 tar -xzf $(ARCHIVE).tar.gz -C $(TMP0) 553 tar -xzf ../yadex-arc/pub/$(ARCPREV).tar.gz -C $(TMP0) 554 scripts/process docsrc/README.diff >$(TMP0)/$(ARCDIFF) 555 echo >>$(TMP0)/$(ARCDIFF) 556 cd $(TMP0) && (diff -uaNr $(ARCPREV) $(ARCHIVE) >>$(ARCDIFF) || true) 557 @# KLUDGE - On my system, just "! grep" makes make choke 558 true; ! grep "^Binary files .* and .* differ" $(TMP0)/$(ARCDIFF) 559 gzip -f $(TMP0)/$(ARCDIFF) 560 @echo "Verifying the diff" 561 cd $(TMPPREV) && gzip -d <../$(ARCDIFF).gz | patch -p1 562 @# FIXME remove -N after 1.6 is done, it's there because 563 @# uptodate has been moved between 1.5 and 1.6 and since 564 @# it's empty it remains in $(ARCPREV). 565 cd $(TMP0) && diff -rP $(ARCHIVE) $(ARCPREV) 566 mv $(TMP0)/$(ARCDIFF).gz . 567 @echo "Cleaning up" 568 cd $(TMP0) && rm -rf $(ARCPREV) 569 cd $(TMP0) && rm -rf $(ARCHIVE) 570 571.PHONY: showconf 572showconf: 573 @echo "ARCHIVE \"$(ARCHIVE)\"" 574 @echo "BINDIR \"$(BINDIR)\"" 575 @echo "CC \"$(CC)\"" 576 @echo "CFLAGS \"$(CFLAGS)\"" 577 @echo "CXX \"$(CXX)\"" 578 @echo "CXXFLAGS \"$(CXXFLAGS)\"" 579 @echo "DCFLAGS \"$(DCFLAGS)\"" 580 @echo "DCXXFLAGS \"$(DCXXFLAGS)\"" 581 @echo "DLDFLAGS \"$(DLDFLAGS)\"" 582 @echo "ETCDIR \"$(ETCDIR)\"" 583 @echo "ETCDIRNV \"$(ETCDIRNV)\"" 584 @echo "HAVE_GETTIMEOFDAY \"$(HAVE_GETTIMEOFDAY)\"" 585 @echo "HAVE_NANOSLEEP \"$(HAVE_NANOSLEEP)\"" 586 @echo "HAVE_SNPRINTF \"$(HAVE_SNPRINTF)\"" 587 @echo "HAVE_USLEEP \"$(HAVE_USLEEP)\"" 588 @echo "LDFLAGS \"$(LDFLAGS)\"" 589 @echo "MANDIR \"$(MANDIR)\"" 590 @echo "OS \"$(OS)\"" 591 @echo "PREFIX \"$(PREFIX)\"" 592 @echo "SHAREDIR \"$(SHAREDIR)\"" 593 @echo "SHAREDIRNV \"$(SHAREDIRNV)\"" 594 @echo "SHELL \"$(SHELL)\"" 595 @echo "SYSTEM \"$(SYSTEM)\"" 596 @echo "VERSION \"$(VERSION)\"" 597 @echo "X11INCLUDEDIR \"$(X11INCLUDEDIR)\"" 598 @echo "X11LIBDIR \"$(X11LIBDIR)\"" 599 @echo "CXX --version \"`$(CXX) --version`\"" 600 @echo "CC --version \"`$(CC) --version`\"" 601 @echo "shell \"$$SHELL\"" 602 @echo "uname \"`uname`\"" 603 604 605######################################################################## 606# 607# Internal targets, not meant 608# to be invoked directly 609# 610######################################################################## 611 612# If Makefile.config or config.h don't exist, give a hint... 613$(OBJDIR)/Makefile.config: 614$(OBJDIR)/config.h: 615 @echo "Sorry guv'nor, but... did you run ./configure ?" >&2 616 @false 617 618$(OBJDIR)/files_etc.man: $(OBJDIR)/config.etc $(MAKEFILE) 619 sed 's/%v/$(VERSION)/g; s,.*,.B &/yadex.cfg,' $< >$@ 620 621$(OBJDIR)/files_share.man: $(OBJDIR)/config.share $(MAKEFILE) 622 sed 's/%v/$(VERSION)/g; s,.*,.BI &/ game .ygd,' $< >$@ 623 624# Dependencies of the modules of Yadex 625# -Y is here to prevent the inclusion of dependencies on 626# /usr/include/*.h etc. As a side-effect, it generates many 627# warnings, hence "2>/dev/null". 628# 629# The purpose of the awk script is to transform this input : 630# 631# src/foo.o: src/whatever.h 632# 633# into this output : 634# 635# obj/0/foo.o: src/whatever.h 636# dobj/0/foo.o: src/whatever.h 637# 638# Note: the modules of Atclib are not scanned as they all 639# depend on $(HEADERS_ATCLIB) and nothing else. 640 641yadex.dep: $(SRC_NON_GEN) src/config.h 642 @echo "Generating $@" 643 @makedepend -f- -Y -Iatclib $(SRC_NON_GEN) 2>/dev/null \ 644 | awk 'sub (/^src/, "") == 1 { \ 645 print "'$(OBJDIR)'" $$0; \ 646 print "'$(DOBJDIR)'" $$0; \ 647 next; \ 648 }' >$@ 649 650cache/copyright.man: $(MAKEFILE) scripts/copyright docsrc/copyright 651 scripts/copyright -m docsrc/copyright >$@ 652 653cache/copyright.txt: $(MAKEFILE) scripts/copyright docsrc/copyright 654 scripts/copyright -t docsrc/copyright | sed 's/^./ &/' >$@ 655 656# The YYYY-MM-DD date indicated in the parentheses after the 657# version number is the mtime of the most recent source file 658# (where "being a source file" is defined as "being listed in 659# $(SRC_NON_GEN)"). That string is the output of a perl script, 660# scripts/youngest. Since perl is not necessarily installed on 661# all machines, we cache that string in the file cache/srcdate 662# and include that file in the distribution archive. If we 663# didn't do that, people who don't have perl would be unable to 664# build Yadex. 665# 666# Conceptually, cache/srcdate depends on $(SRC_NON_GEN) and 667# doc/*.html depend on cache/srcdate. However, we can't write the 668# makefile that way because if we did, that would cause two 669# problems. Firstly every time a source file is changed, 670# scripts/youngest would be ran, most of the time for nothing 671# since its output is always the same, unless it's never been 672# run today. Secondly, cache/srcdate being just generated, it's 673# more recent than the content of the doc/ directory. The result 674# would be that the entire doc/ directory would be rebuilt every 675# time a single source file is changed, which is guaranteed to 676# have an unnerving effect on the hacker at the keyboard. 677# 678# Part of the solution is to systematically force the mtime of 679# cache/srcdate to 00:00, today. Thus, cache/srcdate always looks 680# older than the content of the doc/ directory, unless it's not 681# been refreshed yet today. 682# 683# But that's not enough because then cache/srcdate also looks 684# always older than the source files it depends on, and thus 685# make attempts to regenerate it every time make is invoked at 686# all, which would render the very existence of cache/srcdate 687# useless. That's why we have another file, cache/uptodate, that 688# we touch to keep track of the time when we last generated 689# cache/srcdate. 690# 691# If there was a such thing as _date-only_ dependencies, I could 692# get away with just this : 693# 694# cache/srcdate: scripts/youngest 695# cache/srcdate <date_dependency_operator> $(SRC_NON_GEN) 696# if perl -v >/dev/null 2>&1; then\ 697# scripts/youngest >$@;\ 698# else\ 699# blah... 700# doc/*.html <date_dependency_operator> cache/srcdate 701# blah... 702# 703# That would save two calls to "touch", one intermediary 704# dependency (cache/uptodate) and a lot of obfuscation. 705cache/srcdate: cache/uptodate 706 707cache/uptodate: scripts/youngest $(SRC_NON_GEN) 708 @mkdir -p cache 709 @if perl -v >/dev/null 2>&1; then \ 710 echo Generating cache/srcdate; \ 711 scripts/youngest $(SRC_NON_GEN) >cache/srcdate; \ 712 touch -t `date '+%m%d'`0000 cache/srcdate; \ 713 elif [ -r cache/srcdate ]; then \ 714 echo Perl not available. Keeping old cache/srcdate; \ 715 else \ 716 echo Perl not available. Creating bogus cache/srcdate; \ 717 date '+%Y-%m-%d' >cache/srcdate; \ 718 fi 719 @touch $@; 720 721# To compile the modules of Yadex 722# (normal and debugging versions) 723include yadex.dep 724 725# It's simpler to copy config.cc into src/ than to have a 726# compilation rule for just one file. 727src/config.cc: $(OBJDIR)/config.cc 728 cp -p $< $@ 729 730src/config.h: $(OBJDIR)/config.h 731 cp -p $< $@ 732 733$(OBJDIR)/%.o: src/%.cc 734 $(CXX) -c -Iatclib -Iboost -I$(X11INCLUDEDIR) $(CXXFLAGS) $< -o $@ 735 736$(DOBJDIR)/%.o: src/%.cc 737 $(CXX) -c -Iatclib -Iboost -I$(X11INCLUDEDIR) $(DCXXFLAGS) $< -o $@ 738 739# To compile the modules of Atclib 740# (normal and debugging versions) 741$(OBJDIR_ATCLIB)/%.o: atclib/%.c $(HEADERS_ATCLIB) 742 $(CC) -c $(CFLAGS) $< -o $@ 743 744$(DOBJDIR_ATCLIB)/%.o: atclib/%.c $(HEADERS_ATCLIB) 745 $(CC) -c $(DCFLAGS) $< -o $@ 746 747# To see the generated assembly code 748# for the modules of Yadex 749$(OBJDIR)/%.S: src/%.cc $(MAKEFILE) 750 $(CXX) $(CXXFLAGS) -S -fverbose-asm -Iatclib -Iboost -I$(X11INCLUDEDIR)\ 751 $< -o $@ 752 753# A source file containing the credits 754src/credits.cc: $(MAKEFILE) docsrc/copyright scripts/copyright 755 @echo Generating $@ 756 @echo '// DO NOT EDIT -- generated from docsrc/copyright' >$@ 757 scripts/copyright -c docsrc/copyright >>$@ 758 759# A source file containing just the date of the 760# most recent source file and the version number 761# (found in ./VERSION) 762src/version.cc: $(SRC_NON_GEN) VERSION cache/srcdate $(MAKEFILE) 763 @echo Generating $@ 764 @printf '// DO NOT EDIT -- generated from VERSION\n\n' >$@ 765 @printf "extern const char *const yadex_source_date = \"%s\";\n" \ 766 `cat cache/srcdate` >>$@ 767 @printf "extern const char *const yadex_version = \"%s\";\n" \ 768 "$(VERSION)" >>$@ 769 770 771# -------- Doc-related stuff -------- 772 773docdirs: 774 @if [ ! -d doc ]; then mkdir doc; fi 775 776cache/pixlist: $(DOC2_SRC_HTML) 777 @echo Generating $@ 778 @mkdir -p cache 779 @if perl -v >/dev/null 2>/dev/null; then \ 780 perl -ne '@l = m/<img\s[^>]*src="?([^\s">]+)/io; \ 781 print "@l\n" if @l;' $(DOC2_SRC_HTML) | sort | uniq >$@; \ 782 elif [ -f $@ ]; then \ 783 echo "Sorry, you need Perl to refresh $@. Keeping old $@."; \ 784 else \ 785 echo "Sorry, you need Perl to create $@. Creating empty $@."; \ 786 touch $@; \ 787 fi 788 789events.html: ev evhtml 790 evhtml -- -n $< >$@ 791 792events.txt: events.html 793 lynx -dump $< >$@ 794 795changes/changes.html: changes/*.log log2html RELEASE 796 ./log2html -- -r `cat RELEASE` -- $$(ls -r changes/*.log) >$@ 797 798# changes - update the changelog 799.PHONY: changes 800changes: changes/changes.html 801 w3m -dump -cols 72 $< >CHANGES 802 803# cns - view the changelog with Netscape 804.PHONY: cns 805cns: 806 netscape -remote "openURL(file:$$(pwd)/changes/changes.html,new-window)" 807 808# clynx - view the changelog with Lynx 809.PHONY: clynx 810clynx: 811 lynx changes/changes.html 812 813# cless - view the changelog with less 814.PHONY: cless 815cless: 816 less CHANGES 817 818# man - view the man page with man 819.PHONY: man 820man: doc/yadex.6 821 man -l $^ 822 823# dvi - view the man page with xdvi 824.PHONY: dvi 825dvi: doc/yadex.dvi 826 xdvi $^ 827 828# ps - view the man page with gv 829.PHONY: ps 830ps: doc/yadex.ps 831 gv $^ 832 833# Use docsrc/faq.html and not directly 834# doc/faq.html because we don't want FAQ to be 835# remade at first build time. 836FAQ: docsrc/faq.html 837 scripts/process $< >cache/faq.html 838 links -width 72 -dump cache/faq.html >$@ 839 rm cache/faq.html 840 841doc/yadex.dvi: doc/yadex.6 842 groff -Tdvi -man $^ >$@ 843 844doc/yadex.ps: doc/yadex.6 845 groff -Tps -man $^ >$@ 846 847 848# Generate the doc by filtering them through scripts/process 849PROCESS = \ 850 VERSION \ 851 cache/copyright.man \ 852 cache/copyright.txt \ 853 cache/srcdate \ 854 scripts/process \ 855 $(OBJDIR)/ftime \ 856 $(OBJDIR)/files_etc.man \ 857 $(OBJDIR)/files_share.man \ 858 $(OBJDIR)/notexist 859 860doc/yadex.6: docsrc/yadex.6 $(PROCESS) 861 @echo Generating $@ 862 @scripts/process $< >$@ 863 864doc/README: docsrc/README.doc $(PROCESS) 865 @echo Generating $@ 866 @scripts/process $< >$@ 867 868%: docsrc/% $(PROCESS) 869 @echo Generating $@ 870 @scripts/process $< >$@ 871 872doc/%.html: docsrc/%.html $(PROCESS) 873 @echo Generating $@ 874 @scripts/process $< >$@ 875 876# The images are just symlinked from docsrc/ to doc/ 877doc/%.png: docsrc/%.png 878 @rm -f $@ 879 @ln -s ../$< $@ 880 881$(OBJDIR)/ftime: scripts/ftime.c 882 $(CC) $< -o $@ 883 884$(OBJDIR)/install: scripts/install.c 885 $(CC) $< -o $@ 886 887$(OBJDIR)/notexist: scripts/notexist.c 888 $(CC) $< -o $@ 889 890 891