1#ident "@(#)rules1.top 1.63 21/07/14 " 2########################################################################### 3# Written 1996-2021 by J. Schilling 4########################################################################### 5# 6# Rules that should be included at top of every Makefile 7# Do not include this file directly; this is the language independent 8# version that may be included in special purpose versions. 9# 10########################################################################### 11# Copyright (c) J. Schilling 12########################################################################### 13# The contents of this file are subject to the terms of the 14# Common Development and Distribution License, Version 1.0 only 15# (the "License"). You may not use this file except in compliance 16# with the License. 17# 18# See the file CDDL.Schily.txt in this distribution for details. 19# A copy of the CDDL is also available via the Internet at 20# http://www.opensource.org/licenses/cddl1.txt 21# 22# When distributing Covered Code, include this CDDL HEADER in each 23# file and include the License file CDDL.Schily.txt from this distribution. 24########################################################################### 25# 26# Global definitions: 27# 28# Define magic unique cookie 29# 30########################################################################### 31_UNIQ= .XxZzy- 32 33########################################################################### 34# 35# Make sure this becomes the default target 36# 37########################################################################### 38all: 39 40########################################################################### 41# 42# Build a macro $(SRCROOTSL) that allows to use file name 43# $(SRCROOTSL)incs/Dcc.$(PARCH)$(-O_ARCH) instead of using 44# the file name $(SRCROOT)/incs/Dcc.$(PARCH)$(-O_ARCH) 45# 46# This is needed because of a serious bug in SunPRO make. We need to do some 47# tricks in order to make code working that depends on including files where 48# the file name is a macro and the file may be built as a result of a make 49# rule. 50# 51# SunPRO make inconsistsently shortens rules that start with "./" 52# and thus will not find existing rules for a file to be included. 53# We use pattern matching macro expansions to consistently shorten the 54# name if it starts with "./". This allows to use the same textual 55# string for both the rule and the include statement. 56# 57# Note that Thus bug has been reported to Sun in 1998 but Sun seems not 58# interested to fix the bug. 59# 60########################################################################### 61_SRCROOTSL= $(SRCROOT)/ 62SRCROOTSL= $(_SRCROOTSL:./%=%) 63 64########################################################################### 65# 66# Global handler for failed inludes 67# 68########################################################################### 69.INCLUDE_FAILED: 70 $(NOECHO)echo " ==> AUTOMAKING \"$^\""; sh $(SRCROOTSL)conf/makeinc $^ 71 72########################################################################### 73# 74# Legacy support for old smake programs ... 75# 76########################################################################### 77.INCLUDEFAILED: 78 $(NOECHO)echo " ==> AUTOMAKING \"$^\""; sh $(SRCROOTSL)conf/makeinc $^ 79 80########################################################################### 81# 82# Some global constants or pre-definitions 83# 84########################################################################### 85_LCONFIG= $(_UNIQ)$(LCONFIG) 86__LCONFIG= $(_LCONFIG:$(_UNIQ)=ldummy.cnf) 87LOCAL_CNF= $(__LCONFIG:$(_UNIQ)%=%) 88########################################################################### 89 90########################################################################### 91# 92# Standard (automatic) makeprog identification 93# 94# Each make program should define a macro: MAKE_NAME for identification. 95# MAKE_NAME in this case is a built in macro like MAKE or MAKEFLAGS. 96# Currently only 'smake' implements this feature. 97# 98########################################################################### 99_MAKEPROG= $(_UNIQ)$(MAKE_NAME) 100__MAKEPROG= $(_MAKEPROG:$(_UNIQ)=$(MAKEPROG)) 101_XMAKEPROG= $(__MAKEPROG:$(_UNIQ)%=%) 102 103# gmake defines a macro MAKE_COMMAND. If neither MAKE_NAME is defined by 104# the make program, nor MAKEPROG is set, try this to recognize gmake. 105# 106_GMAKE_COMMAND= $(_UNIQ)$(MAKE_COMMAND) 107__GMAKE_COMMAND= $(_GMAKE_COMMAND:%make=gmake) 108___GMAKE_COMMAND= $(__GMAKE_COMMAND:$(_UNIQ)%=) 109 110# bmake defined a macro .MAKE. If neither MAKE_NAME is defined by 111# the make program, nor MAKEPROG is set, try this to recognize bmake. 112# 113_BMAKE_COMMAND= $(_UNIQ)$(.MAKE) 114__BMAKE_COMMAND= $(_BMAKE_COMMAND:%make=bsdmake) 115___BMAKE_COMMAND= $(__BMAKE_COMMAND:$(_UNIQ)%=) 116 117__XMAKEPROG= $(_UNIQ)$(_XMAKEPROG) 118___XMAKEPROG= $(__XMAKEPROG:$(_UNIQ)=$(___GMAKE_COMMAND)$(___BMAKE_COMMAND)) 119XMAKEPROG= $(___XMAKEPROG:$(_UNIQ)%=%) 120 121include $(SRCROOT)/$(RULESDIR)/mk-$(XMAKEPROG).id 122 123########################################################################### 124# 125# $(GMAKE_ONLY) is empty for gmake and contains no-$(MAKEPROG)/ for 126# other make programs. 127# 128########################################################################### 129_GMAKE_ONLY= $(_UNIQ)$(MAKEPROG) 130__GMAKE_ONLY= $(_GMAKE_ONLY:$(_UNIQ)gmake=) 131GMAKE_ONLY= $(__GMAKE_ONLY:$(_UNIQ)%=no-%/) 132 133########################################################################### 134# 135# Standard (automatic) os identification 136# 137########################################################################### 138include $(SRCROOT)/$(RULESDIR)/os-$(OSNAME).id 139 140########################################################################### 141# 142# Global os definitions 143# 144########################################################################### 145include $(SRCROOT)/$(RULESDIR)/os-$(O_ARCH).def 146 147########################################################################### 148# 149# Some global project definitions that may be overwritten in 'Defaults' 150# 151########################################################################### 152CWARNOPTS= $(CWOPTS) 153 154########################################################################### 155# 156# Global project definitions 157# 158########################################################################### 159DEF_ROOT= $(SRCROOT) 160DEF_DIR= DEFAULTS 161 162_DEFAULTSROOT= $(_UNIQ)$(DEFAULTSROOT) 163__DEFAULTSROOT= $(_DEFAULTSROOT:$(_UNIQ)=$(DEF_ROOT)) 164DEFLTSROOT= $(__DEFAULTSROOT:$(_UNIQ)%=%) 165 166_DEFAULTSDIR= $(_UNIQ)$(DEFAULTSDIR) 167__DEFAULTSDIR= $(_DEFAULTSDIR:$(_UNIQ)=$(DEF_DIR)) 168DEFLTSDIR= $(__DEFAULTSDIR:$(_UNIQ)%=%) 169 170include $(DEFLTSROOT)/$(DEFLTSDIR)/Defaults 171 172########################################################################### 173# 174# Set DEST_DIR 175# We use "DESTDIR" as external visible name to be compatible to other sw. 176# 177########################################################################### 178DEST_DIR= $(DESTDIR:%/=%) 179 180########################################################################### 181# 182# Set INSBASE 183# 184########################################################################### 185INSBASE= $(INS_BASE:%/=%) 186 187########################################################################### 188# 189# Standard default man install base 190# 191########################################################################### 192DEFMANBASE_DEF= share 193 194_MANBASE= $(_UNIQ)$(DEFMANBASE) 195__MANBASE= $(_MANBASE:$(_UNIQ)=$(DEFMANBASE_DEF)) 196MANBASE= $(__MANBASE:$(_UNIQ)%=%) 197 198########################################################################### 199# 200# Get curent directory name 201# 202########################################################################### 203_DIRNAME= $(_UNIQ)$(DIRNAME) 204__DIRNAME= $(_DIRNAME:$(_UNIQ)=...) 205CURWDIR= $(__DIRNAME:$(_UNIQ)%=%) 206 207########################################################################### 208# 209# Standard UNIX compiler name for use as architecture name. 210# 211# (this is not necessarily the name the compiler is called by) 212# This is now defined in $(DEFAULTSROOT)/Defaults 213# If not ... use 'cc' 214# 215########################################################################### 216DEFCCOM_DEF= cc 217 218_DEFCCOM= $(_UNIQ)$(DEFCCOM) 219__DEFCCOM= $(_DEFCCOM:$(_UNIQ)=$(DEFCCOM_DEF)) 220CCOM_DEF= $(__DEFCCOM:$(_UNIQ)%=%) 221 222_CCOM= $(_UNIQ)$(CCOM) 223__CCOM= $(_CCOM:$(_UNIQ)=$(CCOM_DEF)) 224C_ARCH= $(__CCOM:$(_UNIQ)%=%) 225 226########################################################################### 227# 228# Standard default include directories 229# 230########################################################################### 231DEFINCDIRS_DEF= $(SRCROOT)/include 232 233_INCDIRS= $(_UNIQ)$(DEFINCDIRS) 234__INCDIRS= $(_INCDIRS:$(_UNIQ)=$(DEFINCDIRS_DEF)) 235INCDIRS= $(__INCDIRS:$(_UNIQ)%=%) 236 237DEFOSINCDIRS_DEF= # 238 239_OSINCDIRS= $(_UNIQ)$(DEFOSINCDIRS) 240__OSINCDIRS= $(_OSINCDIRS:$(_UNIQ)=$(DEFOSINCDIRS_DEF)) 241OSINCDIRS= $(__OSINCDIRS:$(_UNIQ)%=%) 242 243########################################################################### 244# 245# Prepare come macros needed to build $(ARCHDIR) 246# 247# Build macros for: 248# - processor type 249# - operating system 250# - compiler identification 251# 252########################################################################### 253KARCH_DEF= $(K_ARCH) 254MARCH_DEF= $(M_ARCH) 255PARCH_DEF= $(P_ARCH) 256 257KARCH= K_ARCH 258 259_MARCH= $(_UNIQ)$(ARCH) 260__MARCH= $(_MARCH:$(_UNIQ)=$(MARCH_DEF)) 261MARCH= $(__MARCH:$(_UNIQ)%=%) 262 263_PARCH= $(_UNIQ)$(ARCH) 264__PARCH= $(_PARCH:$(_UNIQ)=$(PARCH_DEF)) 265PARCH= $(__PARCH:$(_UNIQ)%=%) 266 267########################################################################### 268# 269# Now include the file $(SRCROOT)/incs/Dcc.$(PARCH)$(-O_ARCH) 270# which is needed if the C-complier from the manual default configutration 271# is not present on the current system. We try to use GCC as fallback 272# in this case. 273# 274# Due to a serious bug in SunPRO make we need to do some tricks to make 275# the following code working. 276# 277# See notes about $(SRCROOT)/ vs. $(SRCROOTSL) above. 278# 279########################################################################### 280include $(SRCROOT)/$(RULESDIR)/rules.prg 281 282$(SRCROOTSL)incs: 283 $(MKDIR_SH) -p $@ 284 285$(SRCROOTSL)incs/Dnull: $(SRCROOTSL)incs 286 $(NOECHO)if [ ! -f $@ ]; then \ 287 echo > $@; \ 288 else \ 289 : work around v7 shell bug; \ 290 fi 291 292include $(SRCROOTSL)incs/Dnull 293 294_DCC= $(SRCROOTSL)incs/Dcc.$(PARCH)$(-O_ARCH) 295 296$(_DCC): 297 sh $(SRCROOTSL)conf/cc-config.sh $(C_ARCH:%64=%) $(CCOM_DEF) $@ 298 299include $(_DCC) 300 301########################################################################### 302# 303# Build $(ARCHDIR) which occupies a central role in the whole 304# make file system. ARCHDIR is used as a sub directory name to keep 305# platform dependent files on different places. 306# 307# It is built from: 308# - processor type 309# - operating system 310# - compiler identification 311# 312# A possible name could be: 313# mc68020-sunos4-cc 314# 315########################################################################### 316#OARCH= $(MARCH)$(-O_ARCH)-$(C_ARCH) 317OARCH= $(PARCH)$(-O_ARCH)-$(C_ARCH) 318XARCH= $(K_ARCH)$(-O_ARCH)-$(C_ARCH) 319.print: 320 echo $(XP_ARCH) $(P_ARCH) $(OARCH) $(XARCH) 321 322########################################################################### 323# 324# All generated files are placed directly into this subdirectory. 325# This includes e.g. yacc output (.c & .h files). 326# SUBARCH is used if a object is conditional compiled in multiple ways. 327# 328########################################################################### 329OARCHDIR= OBJ/$(OARCH) 330ARCHDIR= OBJ/$(OARCH)$(SUBARCHDIR)$(SUBARCH) 331 332########################################################################### 333# 334# See notes about $(SRCROOT)/ vs. $(SRCROOTSL) above. 335# 336########################################################################### 337OLIBSDIRR= libs/$(OARCH)$(SUBARCHDIR)$(SUBARCH)$(SHLDIR) 338OLIBSDIR= $(SRCROOTSL)libs/$(OARCH)$(SUBARCHDIR)$(SUBARCH)$(SHLDIR) 339OLIBSDIR_STATICR= libs/$(OARCH)$(SUBARCHDIR)$(SUBARCH) 340OLIBSDIR_STATIC=$(SRCROOTSL)libs/$(OARCH)$(SUBARCHDIR)$(SUBARCH) 341OINCSDIRR= incs/$(OARCH) 342OINCSDIR= $(SRCROOTSL)incs/$(OARCH) 343 344########################################################################### 345# Location for targets: 346# 347# - all : see appropriate rules 348# - man installman : rules.man 349# - lint : rules.lnt 350# - clean, clobber, distclean, relink, rmtarget : rules.clr 351# - rel : rules.rel 352# - install, ibins, uninstall : rules.ins 353# - html, htmlx, htmlxn : rules.htm & sub.htm 354# - tarpkg tarpkg1 tarpkg2 : rules.sps 355# - depend, rmdep : rules.dep 356# - config : rules.cnf 357# - tags, TAGS : rules.tag 358# - .help : rules.hlp 359# - .version : rules.hlp 360# - tests : rules.tst 361# - tinfo : rules.dir/rules.rdi 362# - cstyle : rules.cst 363# 364# We do not put '.help', '.version' and 'tinfo' into 'ALLTARGETS' because: 365# 366# .help is not recursive 367# .version is not recursive 368# tinfo is handeled separately in rules1.dir 369# 370# If we would add .help and tinfo, we would get multiple defined target 371# messages. 372# 373# Use ALLTARGETS=$(ALLTARGETS_NT) if there should be no directory descend 374# for e.g. the "test" target. 375########################################################################### 376ALLTARGETS= all man lint clean clobber cstyle distclean ibins depend rmdep \ 377 localize config TAGS tags tests rmtarget relink rel \ 378 $(INSTALLTARGETS) $(UNINSTALLTARGETS) $(MANTARGETS) $(PKGTARGETS) 379 380ALLTARGETS_NT= all man lint clean clobber cstyle distclean ibins depend rmdep \ 381 localize config TAGS tags rmtarget relink rel \ 382 $(INSTALLTARGETS) $(UNINSTALLTARGETS) $(MANTARGETS) $(PKGTARGETS) 383 384INSTALLTARGETS= install installman 385UNINSTALLTARGETS= uninstall uninstallman 386MANTARGETS= html htmlx htmlxn 387PKGTARGETS= tarpkg tarpkg1 tarpkg2 388MAN= man 389 390.PHONY: $(ALLTARGETS) .help tinfo shell 391 392########################################################################### 393# Historic SunPro Make does not understand .PHONY: - use FRC 394# SunPro Make from Schilytools supports .PHONY: and sets MAKE_NAME=sunpro 395# $(MAKEPROG) is derived from $(SRCROOT)/$(RULESDIR)/mk-$(XMAKEPROG).id 396# 397# Make $(FRC) empty for all make programs (that usually support .PHONY) 398# except for the unfixed old SunPro Make from Sun. 399########################################################################### 400_FRC= $(_UNIQ)$(MAKEPROG) 401__FRC= $(_FRC:$(_UNIQ)make=FRC) 402FRC= $(__FRC:$(_UNIQ)%=) 403 404$(ALLTARGETS) .help tinfo shell: $(FRC) 405 406FRC: 407 408########################################################################### 409# Allow to call "make tests" even for commands that do not provide tests 410########################################################################### 411tests: all 412 413########################################################################### 414# Allow to start a shell in order to check the environment 415########################################################################### 416shell: 417 $(SHELL) 418 419########################################################################### 420# Include a target definition for all official targets so calling 421# 'make' with a target that is not defined in the current makefiles 422# will cause the target to be ignored. 423########################################################################### 424$(ALLTARGETS): 425 426include $(SRCROOT)/$(RULESDIR)/version 427