1# This is a make file inclusion, to be included in all the 2# Netpbm make files. 3 4# This file is meant to contain rules that are substantially the same 5# in each of the pbm, pgm, ppm, and pnm subdirectory makes, to avoid 6# duplication of effort. 7 8# The following variables must be set in any make file that uses these 9# rules: 10# 11# SRCDIR: The top level directory of Netpbm source code. 12# BUILDDIR: The top level directory into which Netpbm is built (built, 13# not installed). 14# SUBDIR: The directory, relative to BUILDDIR, of the current directory. 15# It is also the directory, relative to SRCDIR, of source directory that 16# corresponds to the current directory. Note that you build in the 17# current directory, using files from the source directory. 18# SUBDIRS: list of subdirectories in which certain targets (e.g. 'clean') 19# should be made recursively. 20# PKGDIR_DEFAULT: The place to put the packaged stuff for 'make package' 21# if the user doesn't put "pkgdir=" on the Make command line. 22# PKGMANDIR: The subdirectory (e.g. "man" or "share/man" of the package 23# directory root in which man pages should be packaged. 24# OBJECTS: .o files to be built from .c files with the standard rule. 25# PORTBINARIES: list of conventional executables to be built with the standard 26# rule 27# MATHBINARIES: obsolete. 28# DATAFILES: list of files that should be installed in the "data" directory. 29# NETPBMLIBSUFFIX: the suffix, e.g. "so" for the main libraries we build, 30# whatever type they may be. 31# STATICLIBSUFFIX: the suffix, e.g. "a" on a static library. This need 32# not be defined if the user doesn't want to build a static libraries in 33# addition to the main libraries. 34# BINARIES: list of all the executables that need to be installed. 35# INSTALL: command to use to copy files to where they belong 36# INSTALL_PERM_BIN: file permissions for installed binaries 37# INSTALL_PERM_LIB: ...same for libraries 38# INSTALL_PERM_MAN: ...same for man pages 39# MERGE_OBJECTS: list of object files that go into the merged executable 40# from the current directory (not subdirectories). All of these are to 41# be built with the standard rule for merged objects. These names are 42# relative to the current make directory (must not start with / ). 43# MERGEBINARIES: list of the programs that, in a merge build, are invoked 44# via the merged Netpbm program 45# CC: C compiler command 46# CFLAGS_CONFIG: C compiler options from config.mk. 47# CFLAGS_TARGET: C compiler options for a particular target 48# LD: linker command 49# LINKERISCOMPILER: 'Y' if the linker invoked by LD is actually a compiler 50# front end, so takes linker options in a different format 51# LIBS or LOADLIBES: names of libraries to be added to all links 52# COMP_INCLUDES: Compiler option string to establish the search path for 53# component-specific include files when compiling things or computing 54# dependencies (make dep). Header files from this part of the search 55# path take precedence over general Netpbm header files and external 56# library header files. 57# EXTERN_INCLUDES: Like COMP_INCLUDES, but for external libraries, e.g. 58# libjpeg. All header files from the Netpbm source tree take precedence 59# over these. 60 61# In addition, there is CADD, which is extra C compilation options and 62# is intended to be set on a make command line (e.g. 'make CADD=-g') 63# for options that apply just to a particular build. 64 65# In addition, there is CFLAGS, which is extra C compilation options and is 66# expected to be set via the make command line for a particular build. 67# Likewise, LDFLAGS for link-edit options. 68 69# In addition, there is CFLAGS_PERSONAL, which is extra C 70# compilation options and is expected to be set via environment variable 71# for options that are particular to the person doing the build and not 72# specific to Netpbm. 73 74include $(SRCDIR)/version.mk 75 76# .DELETE_ON_ERROR is a special predefined Make target that says to delete 77# the target if a command in the rule for it fails. That's important, 78# because we don't want a half-made target sitting around looking like it's 79# fully made. 80.DELETE_ON_ERROR: 81 82# -I importinc/netpbm is a backward compatibility thing. Really, the source 83# file should refer to e.g. "netpbm/pam.h" but for historical reasons, most 84# refer to "pam.h" and we'll probably never have the energy to convert them 85# all. The reason the file exists as importinc/netpbm/pam.h rather than just 86# importinc/pam.h (as it did originally) is that it lives on a user's system 87# as <netpbm/pam.h>, and therefore all _exported_ header files do say 88# "<netpbm/pam.h>. 89ifneq ($(ALL_INTERNAL_HEADER_FILES_ARE_QUALIFIED),Y) 90 LEGACY_NETPBM_INCLUDE = -Iimportinc/netpbm 91else 92 LEGACY_NETPBM_INCLUDE = 93endif 94 95NETPBM_INCLUDES := -Iimportinc $(LEGACY_NETPBM_INCLUDE) -I$(SRCDIR)/$(SUBDIR) 96 97# -I. is needed when builddir != srcdir 98INCLUDES = -I. $(COMP_INCLUDES) $(NETPBM_INCLUDES) $(EXTERN_INCLUDES) 99 100ifeq ($(NETPBMLIBTYPE),unixstatic) 101 NETPBMLIBFNAME = libnetpbm.$(STATICLIBSUFFIX) 102else 103 NETPBMLIBFNAME = $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).$(NETPBMLIBSUFFIX) 104endif 105NETPBMLIB = $(BUILDDIR)/lib/$(NETPBMLIBFNAME) 106 107BUNDLED_URTLIB = $(BUILDDIR)/urt/librle.a 108 109# LIBS and LOADLIBES are commonly set as environment variables. 110# LOADLIBES is used by GNU Make's implicit .c->.o rule. LIBS is used by 111# GNU Autoconf. 112 113LDLIBS = $(LOADLIBES) $(LIBS) 114 115# 'pkgdir' is meant to be set on the make command line. Results are 116# disastrous if PKGDIR is a relative directory, and I don't know any 117# way to detect that case and fail, so I just add a '/' to the front 118# if it isn't already there. 119ifneq ($(pkgdir)x,x) 120 PKGDIR = $(patsubst //%,/%, /$(pkgdir)) 121else 122 PKGDIR = $(PKGDIR_DEFAULT) 123endif 124 125 126# 'resultdir', like 'pkgdir' is meant to be supplied from the make 127# command line. Unlike 'pkgdir' we allow relative paths. 128ifneq ($(resultdir)x,x) 129 RESULTDIR = $(resultdir) 130else 131 RESULTDIR = $(RESULTDIR_DEFAULT) 132endif 133 134#=========================================================================== 135# We build a directory full of symbolic links to the intra-Netpbm public 136# header files just so the compile commands don't have to be littered 137# with long -I's. 138#=========================================================================== 139 140# Note that the "root" headers are in the root of the build tree, not 141# the source tree. All generated headers are in the root directory and 142# all root directory headers are generated. 143IMPORTINC_ROOT_HEADERS := pm_config.h inttypes_netpbm.h version.h 144 145IMPORTINC_LIB_HEADERS := \ 146 pm.h pbm.h pgm.h ppm.h pnm.h pam.h pbmfont.h ppmcmap.h \ 147 pammap.h colorname.h ppmfloyd.h ppmdraw.h pm_system.h ppmdfont.h \ 148 pm_gamma.h lum.h dithers.h pamdraw.h 149 150IMPORTINC_LIB_UTIL_HEADERS := \ 151 bitarith.h bitio.h bitreverse.h filename.h intcode.h floatcode.h io.h \ 152 matrix.h mallocvar.h \ 153 nsleep.h nstring.h pm_c_util.h runlength.h shhopt.h token.h 154 155IMPORTINC_HEADERS := \ 156 $(IMPORTINC_ROOT_HEADERS) \ 157 $(IMPORTINC_LIB_HEADERS) \ 158 $(IMPORTINC_LIB_UTIL_HEADERS) 159 160IMPORTINC_ROOT_FILES := $(IMPORTINC_ROOT_HEADERS:%=importinc/netpbm/%) 161IMPORTINC_LIB_FILES := $(IMPORTINC_LIB_HEADERS:%=importinc/netpbm/%) 162IMPORTINC_LIB_UTIL_FILES := $(IMPORTINC_LIB_UTIL_HEADERS:%=importinc/netpbm/%) 163 164importinc: \ 165 $(IMPORTINC_ROOT_FILES) \ 166 $(IMPORTINC_LIB_FILES) \ 167 $(IMPORTINC_LIB_UTIL_FILES) \ 168 169# The reason we mkdir importinc/netpbm every time instead of just having 170# importinc depend on it and a rule to make it is that as a dependency, it 171# would force importinc to rebuild when importinc/netpbm has a more recent 172# modification date, which it sometimes would. 173 174$(IMPORTINC_ROOT_FILES):importinc/netpbm/%:$(BUILDDIR)/% 175 mkdir -p importinc/netpbm 176 rm -f $@ 177 $(SYMLINK) $< $@ 178 179$(IMPORTINC_LIB_FILES):importinc/netpbm/%:$(SRCDIR)/lib/% 180 mkdir -p importinc/netpbm 181 rm -f $@ 182 $(SYMLINK) $< $@ 183 184$(IMPORTINC_LIB_UTIL_FILES):importinc/netpbm/%:$(SRCDIR)/lib/util/% 185 mkdir -p importinc/netpbm 186 rm -f $@ 187 $(SYMLINK) $< $@ 188 189 190# We build the symbolic links to header files in the current directory 191# just so the compile commands don't have to be littered with -I's. 192 193bmp.h tga.h:%:$(SRCDIR)/converter/% 194 rm -f $@ 195 $(SYMLINK) $< $@ 196 197ifneq ($(OMIT_VERSION_H_RULE),1) 198 199$(BUILDDIR)/version.h: 200 $(MAKE) -C $(dir $@) $(notdir $@) 201endif 202 203ifneq ($(OMIT_CONFIG_RULE),1) 204$(BUILDDIR)/config.mk: $(SRCDIR)/config.mk.in 205 $(MAKE) -C $(dir $@) $(notdir $@) 206 207$(BUILDDIR)/pm_config.h: 208 $(MAKE) -C $(dir $@) $(notdir $@) 209endif 210 211ifneq ($(OMIT_INTTYPES_RULE),1) 212$(BUILDDIR)/inttypes_netpbm.h: 213 $(MAKE) -C $(dir $@) -f $(SRCDIR)/GNUmakefile $(notdir $@) 214endif 215 216# Note that any time you do a make on a fresh Netpbm source tree, 217# Make notices that 'config.mk', which the make files include, does not 218# exist and runs the "config.mk" target, which runs Configure. 219# If the "config" target were to run Configure as well, it would get run 220# twice in a row if you did a 'make config' on a fresh Netpbm source tree. 221# But we don't want to make "config" just a no-op, because someone might 222# try it after config.mk already exists, in order to make a new 223# config.mk. Issuing a message as follows seems to make sense in 224# both cases. 225.PHONY: config 226config: 227 @echo "To reconfigure the build, run 'configure'" 228 229# Rule to make C source from lex source. 230%.c:%.l 231 $(LEX) -t $< >$(notdir $@) 232 233# Rule to make regular object files, e.g. pnmtojpeg.o. 234 235# The NDEBUG macro says to build code that assumes there are no bugs. 236# This makes the code go faster. The main thing it does is tell the C library 237# to make assert() a no-op as opposed to generating code to check the 238# assertion and crash the program if it isn't really true. You can add 239# -UNDEBUG (in any of various ways) to override this. 240# 241CFLAGS_ALL = \ 242 -DNDEBUG $(CPPFLAGS) $(CFLAGS_CONFIG) $(CFLAGS_TARGET) $(CFLAGS_PERSONAL) $(CFLAGS) $(CADD) 243 244ifeq ($(WANT_SSE),Y) 245 # The only two compilers we've seen that have the SSE capabilities that 246 # WANT_SSE requests are GCC and Clang, and they both have these options and 247 # require them in order for <emmintrin.h> to compile. On some systems 248 # (x86_64, in our experience), these options are default, but on more 249 # traditional systems, they are not. Note: __SSE2__ macro tells whether 250 # -msse2 is in effect. 251 CFLAGS_SSE = -msse -msse2 252else 253 CFLAGS_SSE = 254endif 255 256$(OBJECTS): %.o: %.c importinc 257############################################################################# 258# Note that the user may have configured -I options into CFLAGS or CPPFLAGS. 259# Note about -o: There used to be systems that couldn't handle a space 260# between flag and value. But we found a Solaris gcc on 2003.09.02 that 261# actually fails _without_ the space (it invokes Solaris 'as' with the 262# following command, which generates a "no input filename" error: 263# '/usr/ccs/bin/as -V -Qy -s -o/tmp/hello.o /var/tmp/ccpiNnia.s') 264# This rule has had the space since way before that, so it looks like 265# the space is no longer a problem for anyone. 266############################################################################# 267# 268# We have to get this all on one line to make make messages neat 269 $(CC) -c $(INCLUDES) $(CFLAGS_ALL) -o $@ $< 270 271# libopt is a utility program used in the make file below. 272LIBOPT = $(BUILDDIR)/buildtools/libopt 273 274ifneq ($(OMIT_BUILDTOOL_RULE),1) 275$(LIBOPT) $(TYPEGEN): $(BUILDDIR)/buildtools FORCE 276 $(MAKE) -C $(dir $@) -f $(SRCDIR)/buildtools/Makefile \ 277 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 278endif 279 280ifneq ($(OMIT_LIBRARY_RULE),1) 281$(NETPBMLIB): $(BUILDDIR)/lib FORCE 282 $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/Makefile \ 283 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 284endif 285 286ifneq ($(OMIT_URT_RULE),1) 287$(BUNDLED_URTLIB): $(BUILDDIR)/urt FORCE 288 $(MAKE) -C $(dir $@) -f $(SRCDIR)/urt/Makefile \ 289 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 290endif 291 292$(BUILDDIR)/icon/netpbm.o: $(BUILDDIR)/icon FORCE 293 $(MAKE) -C $(dir $@) -f $(SRCDIR)/icon/Makefile \ 294 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 295 296# Here are some notes from Nelson H. F. Beebe on April 16, 2002: 297# 298# There are at least three incompatible kinds of command-line options 299# that tell the compiler to instruct the linker to save library paths in 300# the executable: 301# 302# -Wl,-rpath,/path/to/dir gcc, g++, FreeBSD, SGI, Sun compilers 303# -rpath /path/to/dir Compaq/DEC, SGI compilers 304# -Rdir:dir:dir Portland Group, Sun compilers 305# 306# Notice that SGI and Sun support two such flavors. 307# 308# Plus, Scott Schwartz observed on March 25, 2003 that while his 309# compiler understands -Wl, his linker does not understand -rpath. 310# His compiler is "Sun WorkShop 6 update 2 C 5.3 2001/05/15". 311# 312# Plus, Mike Saunders found in December 2003 that his Solaris 8 system 313# (uname -a says 'SunOS cannonball.method.cx 5.8 Generic_108528-14 314# sun4u sparc SUNW,Ultra-1') with Gcc 2.95.3 requires the syntax 315# 316# -Wl,-R,/path/to/dir 317# 318# This is apparently because Gcc invokes this linker for Saunders: 319# 320# ld: Software Generation Utilities - Solaris Link Editors: 5.8-1.273 321# 322# I'd say there are also Solaris systems where Gcc invokes the GNU linker 323# and then the option would be -Wl,-rpath... 324# 325# The Sun Ld fails in a weird way when you pass it -rpath instead of -R: 326# 327# ld: Software Generation Utilities - Solaris Link Editors: 5.9-1.382 328# ld: fatal: option -dn and -P are incompatible 329# 330# On IA32 Linux, at least, GNU ld takes -rpath. It also has a -R option, 331# but it is something else. 332# 333# Alan Fry and Snowcrash demonstrated in 2006.11 that neither -rpath 334# nor -R are recognized options on Mac OS X 'ld'. 335# 336# http://developer.apple.com/releasenotes/DeveloperTools/RN-dyld/index.html 337# says that on Mac OS X, libraries aren't searched for in directories, 338# but rather specified by full name, so that rpath doesn't make any 339# sense. On Mac OS X, you use -install_name when you linkedit shared 340# library S to give the complete installed name of S. This goes into 341# S so that when something linkedits with S, the complete installed 342# name of S goes into the object that uses S. 343 344ifeq ($(NEED_RUNTIME_PATH),Y) 345 ifneq ($(NETPBMLIB_RUNTIME_PATH)x,x) 346 ifeq ($(LINKERISCOMPILER),Y) 347 # Before Netpbm 10.14 (March 2003), it looks like we used -R 348 # instead of -Wl,-rpath on all but a few selected platforms as configured 349 # by Configure. But that doesn't make sense, because we also used 350 # LD=$(CC) always. Beebe's notes and Saunders' observation above 351 # above indicate that we need 352 # -Wl,... everywhere that a compiler is used, whether native or GNU, 353 # to link. 354 RPATH = -Wl,$(RPATHOPTNAME),$(NETPBMLIB_RUNTIME_PATH) 355 else 356 RPATH = $(RPATHOPTNAME)$(NETPBMLIB_RUNTIME_PATH) 357 endif 358 endif 359endif 360# Rules for conventional single-object file executables 361 362# Before Netpbm 10.21 (March 2004), we kept separate lists of binaries 363# that require the math library and those that don't, so the binaries 364# that don't need it wouldn't have to link it. But now libnetpbm 365# contains gamma correction routines, so it needs the math library, 366# and that means every Netpbm binary needs the math library, whether 367# it calls those routines or not. So we will phase out the separate 368# lists, and for now we treat them identically. 369 370# Note that GNU C library sometimes defines math functions as inline 371# functions, so linking the math library isn't really necessary. Late 372# model GNU C libraries do this only if you specify the -ffast-math 373# Gcc option (as told by the __FAST_MATH__ preprocessor macro). 374# Earlier ones do it regardless of __FAST_MATH__. 375 376MATHLIB ?= -lm 377 378# Note that LDFLAGS might contain -L options, so order is important. 379# LDFLAGS is commonly set as an environment variable. 380# Some of the target-specific libraries are internal Netpbm libraries 381# (such as libfiasco), which use Libnetpbm. So we put $(NETPBMLIB) 382# after LDFLAGS_TARGET. 383LDFLAGS_ALL = $(WINICON_OBJECT) \ 384 $(LDFLAGS_TARGET) $(shell $(LIBOPT) $(NETPBMLIB)) \ 385 $(LDFLAGS) $(LDLIBS) $(MATHLIB) $(RPATH) $(LADD) 386 387$(PORTBINARIES) $(MATHBINARIES): %: %.o \ 388 $(NETPBMLIB) $(LIBOPT) $(WINICON_OBJECT) 389 $(LD) -o $@$(EXE) $@.o $(ADDL_OBJECTS) $(LDFLAGS_ALL) 390 391 392# MERGE STUFF 393 394# .o2 is our suffix for an object file that has had it's main() changed 395# to e.g. main_pamcut(). We use them for the merge build. 396 397%.o2: %.c importinc 398# Note that the user may have configured -I options into CFLAGS. 399 $(CC) -c $(INCLUDES) -DNDEBUG $(CPPFLAGS) $(CFLAGS) \ 400 "-Dmain=main_$*" \ 401 $(CFLAGS_MERGE) $(CFLAGS_PERSONAL) $(CADD) -o $@ $< 402 403# The "merge try list" is a file full of TRY macro invocations, one for each 404# Netpbm program in this directory or any subdirectory that can be invoked via 405# the merged Netpbm program. There are additional TRYs for backward 406# compatility program names (e.g. 'pnmcomp' for 'pamcomp'). You will find the 407# merge try list #included in netpbm.c. 408 409# The file 'mergecomptrylist' contains the backward compatibility TRYs for the 410# current directory. Just the current directory itself - not subdirectories. 411# Only directories that contain programs with backward compatibility names 412# have a 'mergecomptrylist'. The make file for a directory that has 413# 'mergecomptrylist' sets make variable HAVE_MERGE_COMPAT to "YES". 414 415ifeq ($(HAVE_MERGE_COMPAT),YES) 416mergetrylist: mergecomptrylist 417endif 418 419mergetrylist: $(SUBDIRS:%=%/mergetrylist) 420 cat /dev/null $(SUBDIRS:%=%/mergetrylist) >$@ 421 $(SRCDIR)/buildtools/make_merge.sh $(MERGEBINARIES) >>$@ 422ifeq ($(HAVE_MERGE_COMPAT),YES) 423 echo "/* Backward compatibility names from mergecomptrylist: */" >>$@ 424 cat mergecomptrylist >>$@ 425endif 426 427# The "merge list" is a list of all the object files from this directory and 428# any subdirectories that have to be linked into the merged Netpbm program. 429# They are absolute paths. 430 431mergelist: $(SUBDIRS:%=%/mergelist) $(MERGE_OBJECTS) 432 cat /dev/null $(SUBDIRS:%=%/mergelist) >$@ 433 echo $(MERGE_OBJECTS:%=$(CURDIR)/%) >>$@ 434 435# merge.o is the object file that contains all the code in this directory 436# that needs to be linked into the merged Netpbm program. This is not used 437# today, but some day it will be used instead of mergelist (above). 438 439ifeq ($(MERGE_OBJECTS),) 440 MERGE_O_OBJECTS = empty.o 441else 442 MERGE_O_OBJECTS = $(MERGE_OBJECTS) 443endif 444 445merge.o: $(SUBDIRS:%=%/merge.o) $(MERGE_O_OBJECTS) 446 $(LDRELOC) -o $@ $^ 447 448# empty.o is useful in doing a merge build. Every directory must be able to 449# produce a merge.o file, but not every directory has anything to contribute 450# to the merge. 451empty.o: %.o: %.c 452 $(CC) -c $(CFLAGS_PERSONAL) $(CADD) $< -o $@ 453empty.c: 454 cat /dev/null >empty.c 455 456########################################################################### 457# PACKAGING / INSTALLING 458########################################################################### 459 460# Some maintenance notes about $(INSTALL): Some install programs can 461# install multiple files in one shot; others can take only one file at 462# a time. Some have a -c option; others ignore -c. Some can take 463# permissions in mnemonic form (u=rwx,go=rx); others can't, but all 464# take the encoded form (755). Some have a -d option to install 465# directories and never install them implicitly. Others create 466# directories only implicitly. Installbsd and OSF1 Install need a 467# space in "-m 755". Others don't care. 2000.05.17. OSF1 Install 468# takes only one parameter: the source file. It picks a destination 469# directory by default, or you can specify it with a -f option. 470# 2000.06.15 471 472# DJGPP can do SYMKINKs for programs but not for ordinary files, so 473# it define SYMLINKEXE, other system don't need it 474ifeq ($(SYMLINKEXE)x,x) 475 SYMLINKEXE := $(SYMLINK) 476endif 477 478# An implicit rule for $(PKGDIR)/% does not work because it causes Make 479# sometimes to believe the directory it creates from this rule is an unneeded 480# intermediate file and try to delete it later. So we explicitly list the 481# possible directories under $(PKGDIR): 482 483PKGMANSUBDIRS = man1 man3 man5 web 484 485PKGSUBDIRS = bin include include/netpbm lib sharedlink staticlink share/netpbm \ 486 $(PKGMANSUBDIRS:%=$(PKGMANDIR)/%) 487 488$(PKGSUBDIRS:%=$(PKGDIR)/%): 489 $(SRCDIR)/buildtools/mkinstalldirs $@ 490 491.PHONY: install.merge 492install.merge: $(NOMERGEBINARIES:%=%_installbin) $(SCRIPTS:%=%_installscript) \ 493 $(MERGEBINARIES:%=%_installmerge) $(SUBDIRS:%=%/install.merge) 494 495%_installmerge: $(PKGDIR)/bin 496 cd $(PKGDIR)/bin ; rm -f $(@:%_installmerge=%) 497 cd $(PKGDIR)/bin ; $(SYMLINKEXE) netpbm$(EXE) $(@:%_installmerge=%) 498 499.PHONY: install.bin 500install.bin: $(BINARIES:%=%_installbin) $(SCRIPTS:%=%_installscript) \ 501 $(SUBDIRS:%=%/install.bin) 502# Note that on Cygwin, the executables are actually pbmmake.exe, etc. 503# Make and Install know that pbmmake.exe counts as pbmmake. 504 505INSTALLBIN_TARGETS = $(BINARIES:%=%_installbin) netpbm_installbin 506.PHONY: $(INSTALLBIN_TARGETS) 507$(INSTALLBIN_TARGETS): $(PKGDIR)/bin 508 $(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_BIN) \ 509 $(@:%_installbin=%) $< 510 511$(SCRIPTS:%=%_installscript): $(PKGDIR)/bin 512 $(INSTALL) -c -m $(INSTALL_PERM_BIN) \ 513 $(SRCDIR)/$(SUBDIR)/$(@:%_installscript=%) $< 514 515.PHONY: install.data 516install.data: $(DATAFILES:%=%_installdata) $(SUBDIRS:%=%/install.data) 517 518.PHONY: $(DATAFILES:%=%_installdata) 519$(DATAFILES:%=%_installdata): $(PKGDIR)/share/netpbm 520 $(INSTALL) -c -m $(INSTALL_PERM_DATA) \ 521 $(SRCDIR)/$(SUBDIR)/$(@:%_installdata=%) $< 522 523 524.PHONY: clean 525 526ifneq ($(EXE)x,x) 527EXEPATTERN = *$(EXE) 528else 529EXEPATTERN = 530endif 531clean: $(SUBDIRS:%=%/clean) thisdirclean 532 533.PHONY: thisdirclean 534thisdirclean: 535 -rm -f *.o *.o2 *.a *.so *.so.* *.dll *.dylib *.cat *~ *.i *.s \ 536 $(EXEPATTERN) *.def *.lnk \ 537 core *.core mergelist mergetrylist *.c1 empty.c \ 538 $(BINARIES) pm_types.h 539 -rm -rf importinc 540 541.PHONY: distclean 542distclean: $(SUBDIRS:%=%/distclean) thisdirclean 543 rm -f depend.mk 544 545DEP_SOURCES = $(wildcard *.c *.cpp *.cc) 546 547.PHONY: dep 548dep: $(SUBDIRS:%=%/dep) importinc 549# We use -MG here because of compile.h and version.h. They need not exist 550# before the first make after a clean. 551 552ifneq ($(DEP_SOURCES)x,x) 553 $(CC) -MM -MG $(INCLUDES) $(DEP_SOURCES) >depend.mk 554endif 555 556# Note: if I stack all these subdirectory targets into one rule, I get 557# weird behavior where e.g. make install-nonmerge causes all the 558# %/install.bin makes to happen recursively, but then lib/install.lib 559# is considered up to date and doesn't get rebuilt. 560%/install.bin: 561 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 562 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 563%/install.lib: 564 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 565 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 566%/install.data: 567 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 568 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 569%/install.merge: 570 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 571 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 572$(SUBDIRS:%=%/all): %/all: $(CURDIR)/% 573 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 574 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 575$(SUBDIRS:%=%/mergetrylist): %/mergetrylist: $(CURDIR)/% FORCE 576 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 577 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 578$(SUBDIRS:%=%/mergelist): %/mergelist: $(CURDIR)/% FORCE 579 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 580 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 581$(SUBDIRS:%=%/merge.o): %/merge.o: $(CURDIR)/% FORCE 582 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 583 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 584$(SUBDIRS:%=%/clean): %/clean: $(CURDIR)/% 585 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 586 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 587$(SUBDIRS:%=%/distclean): %/distclean: $(CURDIR)/% 588 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 589 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 590$(SUBDIRS:%=%/dep): %/dep: $(CURDIR)/% 591 $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \ 592 SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 593 594#Here is the rule to create the subdirectories. If you're building in the 595#source tree, they already exist, but in a separate build directory, they may 596#not. 597 598ifneq ($(SUBDIR)x,x) 599# This hack stops us from having a warning due to the same target twice 600# when we're in the top level directory (because buildtools, etc are in 601# SUBDIRS). 602 DIRS2 = $(BUILDDIR)/buildtools $(BUILDDIR)/lib $(BUILDDIR)/urt 603endif 604 605$(SUBDIRS:%=$(CURDIR)/%) $(DIRS2): 606 mkdir $@ 607 608 609# The automatic dependency generation is a pain in the butt and 610# totally unnecessary for people just installing the distributed code, 611# so to avoid needless failures in the field and a complex build, the 612# rule to generate depend.mk automatically simply creates an 613# empty file. A developer may do 'make dep' to create a 614# depend.mk full of real dependencies. 615 616depend.mk: 617 cat /dev/null >$@ 618 619include depend.mk 620 621FORCE: 622