|
Packit |
78deda |
# This is a make file inclusion, to be included in all the
|
|
Packit |
78deda |
# Netpbm make files.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# This file is meant to contain rules that are substantially the same
|
|
Packit |
78deda |
# in each of the pbm, pgm, ppm, and pnm subdirectory makes, to avoid
|
|
Packit |
78deda |
# duplication of effort.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# The following variables must be set in any make file that uses these
|
|
Packit |
78deda |
# rules:
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# SRCDIR: The top level directory of Netpbm source code.
|
|
Packit |
78deda |
# BUILDDIR: The top level directory into which Netpbm is built (built,
|
|
Packit |
78deda |
# not installed).
|
|
Packit |
78deda |
# SUBDIR: The directory, relative to BUILDDIR, of the current directory.
|
|
Packit |
78deda |
# It is also the directory, relative to SRCDIR, of source directory that
|
|
Packit |
78deda |
# corresponds to the current directory. Note that you build in the
|
|
Packit |
78deda |
# current directory, using files from the source directory.
|
|
Packit |
78deda |
# SUBDIRS: list of subdirectories in which certain targets (e.g. 'clean')
|
|
Packit |
78deda |
# should be made recursively.
|
|
Packit |
78deda |
# PKGDIR_DEFAULT: The place to put the packaged stuff for 'make package'
|
|
Packit |
78deda |
# if the user doesn't put "pkgdir=" on the Make command line.
|
|
Packit |
78deda |
# PKGMANDIR: The subdirectory (e.g. "man" or "share/man" of the package
|
|
Packit |
78deda |
# directory root in which man pages should be packaged.
|
|
Packit |
78deda |
# OBJECTS: .o files to be built from .c files with the standard rule.
|
|
Packit |
78deda |
# PORTBINARIES: list of conventional executables to be built with the standard
|
|
Packit |
78deda |
# rule
|
|
Packit |
78deda |
# MATHBINARIES: obsolete.
|
|
Packit |
78deda |
# DATAFILES: list of files that should be installed in the "data" directory.
|
|
Packit |
78deda |
# NETPBMLIBSUFFIX: the suffix, e.g. "so" for the main libraries we build,
|
|
Packit |
78deda |
# whatever type they may be.
|
|
Packit |
78deda |
# STATICLIBSUFFIX: the suffix, e.g. "a" on a static library. This need
|
|
Packit |
78deda |
# not be defined if the user doesn't want to build a static libraries in
|
|
Packit |
78deda |
# addition to the main libraries.
|
|
Packit |
78deda |
# BINARIES: list of all the executables that need to be installed.
|
|
Packit |
78deda |
# INSTALL: command to use to copy files to where they belong
|
|
Packit |
78deda |
# INSTALL_PERM_BIN: file permissions for installed binaries
|
|
Packit |
78deda |
# INSTALL_PERM_LIB: ...same for libraries
|
|
Packit |
78deda |
# INSTALL_PERM_MAN: ...same for man pages
|
|
Packit |
78deda |
# MERGE_OBJECTS: list of object files that go into the merged executable
|
|
Packit |
78deda |
# from the current directory (not subdirectories). All of these are to
|
|
Packit |
78deda |
# be built with the standard rule for merged objects. These names are
|
|
Packit |
78deda |
# relative to the current make directory (must not start with / ).
|
|
Packit |
78deda |
# MERGEBINARIES: list of the programs that, in a merge build, are invoked
|
|
Packit |
78deda |
# via the merged Netpbm program
|
|
Packit |
78deda |
# CC: C compiler command
|
|
Packit |
78deda |
# CFLAGS_CONFIG: C compiler options from config.mk.
|
|
Packit |
78deda |
# CFLAGS_TARGET: C compiler options for a particular target
|
|
Packit |
78deda |
# LD: linker command
|
|
Packit |
78deda |
# LINKERISCOMPILER: 'Y' if the linker invoked by LD is actually a compiler
|
|
Packit |
78deda |
# front end, so takes linker options in a different format
|
|
Packit |
78deda |
# LIBS or LOADLIBES: names of libraries to be added to all links
|
|
Packit |
78deda |
# COMP_INCLUDES: Compiler option string to establish the search path for
|
|
Packit |
78deda |
# component-specific include files when compiling things or computing
|
|
Packit |
78deda |
# dependencies (make dep). Header files from this part of the search
|
|
Packit |
78deda |
# path take precedence over general Netpbm header files and external
|
|
Packit |
78deda |
# library header files.
|
|
Packit |
78deda |
# EXTERN_INCLUDES: Like COMP_INCLUDES, but for external libraries, e.g.
|
|
Packit |
78deda |
# libjpeg. All header files from the Netpbm source tree take precedence
|
|
Packit |
78deda |
# over these.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# In addition, there is CADD, which is extra C compilation options and
|
|
Packit |
78deda |
# is intended to be set on a make command line (e.g. 'make CADD=-g')
|
|
Packit |
78deda |
# for options that apply just to a particular build.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# In addition, there is CFLAGS, which is extra C compilation options and is
|
|
Packit |
78deda |
# expected to be set via the make command line for a particular build.
|
|
Packit |
78deda |
# Likewise, LDFLAGS for link-edit options.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# In addition, there is CFLAGS_PERSONAL, which is extra C
|
|
Packit |
78deda |
# compilation options and is expected to be set via environment variable
|
|
Packit |
78deda |
# for options that are particular to the person doing the build and not
|
|
Packit |
78deda |
# specific to Netpbm.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
include $(SRCDIR)/version.mk
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# .DELETE_ON_ERROR is a special predefined Make target that says to delete
|
|
Packit |
78deda |
# the target if a command in the rule for it fails. That's important,
|
|
Packit |
78deda |
# because we don't want a half-made target sitting around looking like it's
|
|
Packit |
78deda |
# fully made.
|
|
Packit |
78deda |
.DELETE_ON_ERROR:
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# -I importinc/netpbm is a backward compatibility thing. Really, the source
|
|
Packit |
78deda |
# file should refer to e.g. "netpbm/pam.h" but for historical reasons, most
|
|
Packit |
78deda |
# refer to "pam.h" and we'll probably never have the energy to convert them
|
|
Packit |
78deda |
# all. The reason the file exists as importinc/netpbm/pam.h rather than just
|
|
Packit |
78deda |
# importinc/pam.h (as it did originally) is that it lives on a user's system
|
|
Packit |
78deda |
# as <netpbm/pam.h>, and therefore all _exported_ header files do say
|
|
Packit |
78deda |
# "<netpbm/pam.h>.
|
|
Packit |
78deda |
ifneq ($(ALL_INTERNAL_HEADER_FILES_ARE_QUALIFIED),Y)
|
|
Packit |
78deda |
LEGACY_NETPBM_INCLUDE = -Iimportinc/netpbm
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
LEGACY_NETPBM_INCLUDE =
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
NETPBM_INCLUDES := -Iimportinc $(LEGACY_NETPBM_INCLUDE) -I$(SRCDIR)/$(SUBDIR)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# -I. is needed when builddir != srcdir
|
|
Packit |
78deda |
INCLUDES = -I. $(COMP_INCLUDES) $(NETPBM_INCLUDES) $(EXTERN_INCLUDES)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifeq ($(NETPBMLIBTYPE),unixstatic)
|
|
Packit |
78deda |
NETPBMLIBFNAME = libnetpbm.$(STATICLIBSUFFIX)
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
NETPBMLIBFNAME = $(NETPBMSHLIBPREFIX)netpbm$(DLLVER).$(NETPBMLIBSUFFIX)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
NETPBMLIB = $(BUILDDIR)/lib/$(NETPBMLIBFNAME)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
BUNDLED_URTLIB = $(BUILDDIR)/urt/librle.a
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# LIBS and LOADLIBES are commonly set as environment variables.
|
|
Packit |
78deda |
# LOADLIBES is used by GNU Make's implicit .c->.o rule. LIBS is used by
|
|
Packit |
78deda |
# GNU Autoconf.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
LDLIBS = $(LOADLIBES) $(LIBS)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# 'pkgdir' is meant to be set on the make command line. Results are
|
|
Packit |
78deda |
# disastrous if PKGDIR is a relative directory, and I don't know any
|
|
Packit |
78deda |
# way to detect that case and fail, so I just add a '/' to the front
|
|
Packit |
78deda |
# if it isn't already there.
|
|
Packit |
78deda |
ifneq ($(pkgdir)x,x)
|
|
Packit |
78deda |
PKGDIR = $(patsubst //%,/%, /$(pkgdir))
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
PKGDIR = $(PKGDIR_DEFAULT)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# 'resultdir', like 'pkgdir' is meant to be supplied from the make
|
|
Packit |
78deda |
# command line. Unlike 'pkgdir' we allow relative paths.
|
|
Packit |
78deda |
ifneq ($(resultdir)x,x)
|
|
Packit |
78deda |
RESULTDIR = $(resultdir)
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
RESULTDIR = $(RESULTDIR_DEFAULT)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
#===========================================================================
|
|
Packit |
78deda |
# We build a directory full of symbolic links to the intra-Netpbm public
|
|
Packit |
78deda |
# header files just so the compile commands don't have to be littered
|
|
Packit |
78deda |
# with long -I's.
|
|
Packit |
78deda |
#===========================================================================
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Note that the "root" headers are in the root of the build tree, not
|
|
Packit |
78deda |
# the source tree. All generated headers are in the root directory and
|
|
Packit |
78deda |
# all root directory headers are generated.
|
|
Packit |
78deda |
IMPORTINC_ROOT_HEADERS := pm_config.h inttypes_netpbm.h version.h
|
|
Packit |
78deda |
|
|
Packit |
78deda |
IMPORTINC_LIB_HEADERS := \
|
|
Packit |
78deda |
pm.h pbm.h pgm.h ppm.h pnm.h pam.h pbmfont.h ppmcmap.h \
|
|
Packit |
78deda |
pammap.h colorname.h ppmfloyd.h ppmdraw.h pm_system.h ppmdfont.h \
|
|
Packit |
78deda |
pm_gamma.h lum.h dithers.h pamdraw.h
|
|
Packit |
78deda |
|
|
Packit |
78deda |
IMPORTINC_LIB_UTIL_HEADERS := \
|
|
Packit |
78deda |
bitarith.h bitio.h bitreverse.h filename.h intcode.h floatcode.h io.h \
|
|
Packit |
78deda |
matrix.h mallocvar.h \
|
|
Packit |
78deda |
nsleep.h nstring.h pm_c_util.h runlength.h shhopt.h token.h
|
|
Packit |
78deda |
|
|
Packit |
78deda |
IMPORTINC_HEADERS := \
|
|
Packit |
78deda |
$(IMPORTINC_ROOT_HEADERS) \
|
|
Packit |
78deda |
$(IMPORTINC_LIB_HEADERS) \
|
|
Packit |
78deda |
$(IMPORTINC_LIB_UTIL_HEADERS)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
IMPORTINC_ROOT_FILES := $(IMPORTINC_ROOT_HEADERS:%=importinc/netpbm/%)
|
|
Packit |
78deda |
IMPORTINC_LIB_FILES := $(IMPORTINC_LIB_HEADERS:%=importinc/netpbm/%)
|
|
Packit |
78deda |
IMPORTINC_LIB_UTIL_FILES := $(IMPORTINC_LIB_UTIL_HEADERS:%=importinc/netpbm/%)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
importinc: \
|
|
Packit |
78deda |
$(IMPORTINC_ROOT_FILES) \
|
|
Packit |
78deda |
$(IMPORTINC_LIB_FILES) \
|
|
Packit |
78deda |
$(IMPORTINC_LIB_UTIL_FILES) \
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# The reason we mkdir importinc/netpbm every time instead of just having
|
|
Packit |
78deda |
# importinc depend on it and a rule to make it is that as a dependency, it
|
|
Packit |
78deda |
# would force importinc to rebuild when importinc/netpbm has a more recent
|
|
Packit |
78deda |
# modification date, which it sometimes would.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(IMPORTINC_ROOT_FILES):importinc/netpbm/%:$(BUILDDIR)/%
|
|
Packit |
78deda |
mkdir -p importinc/netpbm
|
|
Packit |
78deda |
rm -f $@
|
|
Packit |
78deda |
$(SYMLINK) $< $@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(IMPORTINC_LIB_FILES):importinc/netpbm/%:$(SRCDIR)/lib/%
|
|
Packit |
78deda |
mkdir -p importinc/netpbm
|
|
Packit |
78deda |
rm -f $@
|
|
Packit |
78deda |
$(SYMLINK) $< $@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(IMPORTINC_LIB_UTIL_FILES):importinc/netpbm/%:$(SRCDIR)/lib/util/%
|
|
Packit |
78deda |
mkdir -p importinc/netpbm
|
|
Packit |
78deda |
rm -f $@
|
|
Packit |
78deda |
$(SYMLINK) $< $@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# We build the symbolic links to header files in the current directory
|
|
Packit |
78deda |
# just so the compile commands don't have to be littered with -I's.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
bmp.h tga.h:%:$(SRCDIR)/converter/%
|
|
Packit |
78deda |
rm -f $@
|
|
Packit |
78deda |
$(SYMLINK) $< $@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(OMIT_VERSION_H_RULE),1)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(BUILDDIR)/version.h:
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) $(notdir $@)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(OMIT_CONFIG_RULE),1)
|
|
Packit |
78deda |
$(BUILDDIR)/config.mk: $(SRCDIR)/config.mk.in
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) $(notdir $@)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(BUILDDIR)/pm_config.h:
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) $(notdir $@)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(OMIT_INTTYPES_RULE),1)
|
|
Packit |
78deda |
$(BUILDDIR)/inttypes_netpbm.h:
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/GNUmakefile $(notdir $@)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Note that any time you do a make on a fresh Netpbm source tree,
|
|
Packit |
78deda |
# Make notices that 'config.mk', which the make files include, does not
|
|
Packit |
78deda |
# exist and runs the "config.mk" target, which runs Configure.
|
|
Packit |
78deda |
# If the "config" target were to run Configure as well, it would get run
|
|
Packit |
78deda |
# twice in a row if you did a 'make config' on a fresh Netpbm source tree.
|
|
Packit |
78deda |
# But we don't want to make "config" just a no-op, because someone might
|
|
Packit |
78deda |
# try it after config.mk already exists, in order to make a new
|
|
Packit |
78deda |
# config.mk. Issuing a message as follows seems to make sense in
|
|
Packit |
78deda |
# both cases.
|
|
Packit |
78deda |
.PHONY: config
|
|
Packit |
78deda |
config:
|
|
Packit |
78deda |
@echo "To reconfigure the build, run 'configure'"
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Rule to make C source from lex source.
|
|
Packit |
78deda |
%.c:%.l
|
|
Packit |
78deda |
$(LEX) -t $< >$(notdir $@)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Rule to make regular object files, e.g. pnmtojpeg.o.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# The NDEBUG macro says to build code that assumes there are no bugs.
|
|
Packit |
78deda |
# This makes the code go faster. The main thing it does is tell the C library
|
|
Packit |
78deda |
# to make assert() a no-op as opposed to generating code to check the
|
|
Packit |
78deda |
# assertion and crash the program if it isn't really true. You can add
|
|
Packit |
78deda |
# -UNDEBUG (in any of various ways) to override this.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
CFLAGS_ALL = \
|
|
Packit |
78deda |
-DNDEBUG $(CPPFLAGS) $(CFLAGS_CONFIG) $(CFLAGS_TARGET) $(CFLAGS_PERSONAL) $(CFLAGS) $(CADD)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifeq ($(WANT_SSE),Y)
|
|
Packit |
78deda |
# The only two compilers we've seen that have the SSE capabilities that
|
|
Packit |
78deda |
# WANT_SSE requests are GCC and Clang, and they both have these options and
|
|
Packit |
78deda |
# require them in order for <emmintrin.h> to compile. On some systems
|
|
Packit |
78deda |
# (x86_64, in our experience), these options are default, but on more
|
|
Packit |
78deda |
# traditional systems, they are not. Note: __SSE2__ macro tells whether
|
|
Packit |
78deda |
# -msse2 is in effect.
|
|
Packit |
78deda |
CFLAGS_SSE = -msse -msse2
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
CFLAGS_SSE =
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(OBJECTS): %.o: %.c importinc
|
|
Packit |
78deda |
#############################################################################
|
|
Packit |
78deda |
# Note that the user may have configured -I options into CFLAGS or CPPFLAGS.
|
|
Packit |
78deda |
# Note about -o: There used to be systems that couldn't handle a space
|
|
Packit |
78deda |
# between flag and value. But we found a Solaris gcc on 2003.09.02 that
|
|
Packit |
78deda |
# actually fails _without_ the space (it invokes Solaris 'as' with the
|
|
Packit |
78deda |
# following command, which generates a "no input filename" error:
|
|
Packit |
78deda |
# '/usr/ccs/bin/as -V -Qy -s -o/tmp/hello.o /var/tmp/ccpiNnia.s')
|
|
Packit |
78deda |
# This rule has had the space since way before that, so it looks like
|
|
Packit |
78deda |
# the space is no longer a problem for anyone.
|
|
Packit |
78deda |
#############################################################################
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# We have to get this all on one line to make make messages neat
|
|
Packit |
78deda |
$(CC) -c $(INCLUDES) $(CFLAGS_ALL) -o $@ $<
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# libopt is a utility program used in the make file below.
|
|
Packit |
78deda |
LIBOPT = $(BUILDDIR)/buildtools/libopt
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(OMIT_BUILDTOOL_RULE),1)
|
|
Packit |
78deda |
$(LIBOPT) $(TYPEGEN): $(BUILDDIR)/buildtools FORCE
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/buildtools/Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(OMIT_LIBRARY_RULE),1)
|
|
Packit |
78deda |
$(NETPBMLIB): $(BUILDDIR)/lib FORCE
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(OMIT_URT_RULE),1)
|
|
Packit |
78deda |
$(BUNDLED_URTLIB): $(BUILDDIR)/urt FORCE
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/urt/Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(BUILDDIR)/icon/netpbm.o: $(BUILDDIR)/icon FORCE
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/icon/Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Here are some notes from Nelson H. F. Beebe on April 16, 2002:
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# There are at least three incompatible kinds of command-line options
|
|
Packit |
78deda |
# that tell the compiler to instruct the linker to save library paths in
|
|
Packit |
78deda |
# the executable:
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# -Wl,-rpath,/path/to/dir gcc, g++, FreeBSD, SGI, Sun compilers
|
|
Packit |
78deda |
# -rpath /path/to/dir Compaq/DEC, SGI compilers
|
|
Packit |
78deda |
# -Rdir:dir:dir Portland Group, Sun compilers
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# Notice that SGI and Sun support two such flavors.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# Plus, Scott Schwartz observed on March 25, 2003 that while his
|
|
Packit |
78deda |
# compiler understands -Wl, his linker does not understand -rpath.
|
|
Packit |
78deda |
# His compiler is "Sun WorkShop 6 update 2 C 5.3 2001/05/15".
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# Plus, Mike Saunders found in December 2003 that his Solaris 8 system
|
|
Packit |
78deda |
# (uname -a says 'SunOS cannonball.method.cx 5.8 Generic_108528-14
|
|
Packit |
78deda |
# sun4u sparc SUNW,Ultra-1') with Gcc 2.95.3 requires the syntax
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# -Wl,-R,/path/to/dir
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# This is apparently because Gcc invokes this linker for Saunders:
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# ld: Software Generation Utilities - Solaris Link Editors: 5.8-1.273
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# I'd say there are also Solaris systems where Gcc invokes the GNU linker
|
|
Packit |
78deda |
# and then the option would be -Wl,-rpath...
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# The Sun Ld fails in a weird way when you pass it -rpath instead of -R:
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# ld: Software Generation Utilities - Solaris Link Editors: 5.9-1.382
|
|
Packit |
78deda |
# ld: fatal: option -dn and -P are incompatible
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# On IA32 Linux, at least, GNU ld takes -rpath. It also has a -R option,
|
|
Packit |
78deda |
# but it is something else.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# Alan Fry and Snowcrash demonstrated in 2006.11 that neither -rpath
|
|
Packit |
78deda |
# nor -R are recognized options on Mac OS X 'ld'.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# http://developer.apple.com/releasenotes/DeveloperTools/RN-dyld/index.html
|
|
Packit |
78deda |
# says that on Mac OS X, libraries aren't searched for in directories,
|
|
Packit |
78deda |
# but rather specified by full name, so that rpath doesn't make any
|
|
Packit |
78deda |
# sense. On Mac OS X, you use -install_name when you linkedit shared
|
|
Packit |
78deda |
# library S to give the complete installed name of S. This goes into
|
|
Packit |
78deda |
# S so that when something linkedits with S, the complete installed
|
|
Packit |
78deda |
# name of S goes into the object that uses S.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifeq ($(NEED_RUNTIME_PATH),Y)
|
|
Packit |
78deda |
ifneq ($(NETPBMLIB_RUNTIME_PATH)x,x)
|
|
Packit |
78deda |
ifeq ($(LINKERISCOMPILER),Y)
|
|
Packit |
78deda |
# Before Netpbm 10.14 (March 2003), it looks like we used -R
|
|
Packit |
78deda |
# instead of -Wl,-rpath on all but a few selected platforms as configured
|
|
Packit |
78deda |
# by Configure. But that doesn't make sense, because we also used
|
|
Packit |
78deda |
# LD=$(CC) always. Beebe's notes and Saunders' observation above
|
|
Packit |
78deda |
# above indicate that we need
|
|
Packit |
78deda |
# -Wl,... everywhere that a compiler is used, whether native or GNU,
|
|
Packit |
78deda |
# to link.
|
|
Packit |
78deda |
RPATH = -Wl,$(RPATHOPTNAME),$(NETPBMLIB_RUNTIME_PATH)
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
RPATH = $(RPATHOPTNAME)$(NETPBMLIB_RUNTIME_PATH)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
# Rules for conventional single-object file executables
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Before Netpbm 10.21 (March 2004), we kept separate lists of binaries
|
|
Packit |
78deda |
# that require the math library and those that don't, so the binaries
|
|
Packit |
78deda |
# that don't need it wouldn't have to link it. But now libnetpbm
|
|
Packit |
78deda |
# contains gamma correction routines, so it needs the math library,
|
|
Packit |
78deda |
# and that means every Netpbm binary needs the math library, whether
|
|
Packit |
78deda |
# it calls those routines or not. So we will phase out the separate
|
|
Packit |
78deda |
# lists, and for now we treat them identically.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Note that GNU C library sometimes defines math functions as inline
|
|
Packit |
78deda |
# functions, so linking the math library isn't really necessary. Late
|
|
Packit |
78deda |
# model GNU C libraries do this only if you specify the -ffast-math
|
|
Packit |
78deda |
# Gcc option (as told by the __FAST_MATH__ preprocessor macro).
|
|
Packit |
78deda |
# Earlier ones do it regardless of __FAST_MATH__.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
MATHLIB ?= -lm
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Note that LDFLAGS might contain -L options, so order is important.
|
|
Packit |
78deda |
# LDFLAGS is commonly set as an environment variable.
|
|
Packit |
78deda |
# Some of the target-specific libraries are internal Netpbm libraries
|
|
Packit |
78deda |
# (such as libfiasco), which use Libnetpbm. So we put $(NETPBMLIB)
|
|
Packit |
78deda |
# after LDFLAGS_TARGET.
|
|
Packit |
78deda |
LDFLAGS_ALL = $(WINICON_OBJECT) \
|
|
Packit |
78deda |
$(LDFLAGS_TARGET) $(shell $(LIBOPT) $(NETPBMLIB)) \
|
|
Packit |
78deda |
$(LDFLAGS) $(LDLIBS) $(MATHLIB) $(RPATH) $(LADD)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(PORTBINARIES) $(MATHBINARIES): %: %.o \
|
|
Packit |
78deda |
$(NETPBMLIB) $(LIBOPT) $(WINICON_OBJECT)
|
|
Packit |
78deda |
$(LD) -o $@$(EXE) $@.o $(ADDL_OBJECTS) $(LDFLAGS_ALL)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# MERGE STUFF
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# .o2 is our suffix for an object file that has had it's main() changed
|
|
Packit |
78deda |
# to e.g. main_pamcut(). We use them for the merge build.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
%.o2: %.c importinc
|
|
Packit |
78deda |
# Note that the user may have configured -I options into CFLAGS.
|
|
Packit |
78deda |
$(CC) -c $(INCLUDES) -DNDEBUG $(CPPFLAGS) $(CFLAGS) \
|
|
Packit |
78deda |
"-Dmain=main_$*" \
|
|
Packit |
78deda |
$(CFLAGS_MERGE) $(CFLAGS_PERSONAL) $(CADD) -o $@ $<
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# The "merge try list" is a file full of TRY macro invocations, one for
|
|
Packit |
78deda |
# each Netpbm program in this directory or any subdirectory that can be
|
|
Packit |
78deda |
# invoked via the merged Netpbm program. You will find it #included in
|
|
Packit |
78deda |
# netpbm.c.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
mergetrylist: $(SUBDIRS:%=%/mergetrylist)
|
|
Packit |
78deda |
cat /dev/null $(SUBDIRS:%=%/mergetrylist) >$@
|
|
Packit |
78deda |
$(SRCDIR)/buildtools/make_merge.sh $(MERGEBINARIES) >>$@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# The "merge list" is a list of all the object files from this directory and
|
|
Packit |
78deda |
# any subdirectories that have to be linked into the merged Netpbm program.
|
|
Packit |
78deda |
# They are absolute paths.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
mergelist: $(SUBDIRS:%=%/mergelist) $(MERGE_OBJECTS)
|
|
Packit |
78deda |
cat /dev/null $(SUBDIRS:%=%/mergelist) >$@
|
|
Packit |
78deda |
echo $(MERGE_OBJECTS:%=$(CURDIR)/%) >>$@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# merge.o is the object file that contains all the code in this directory
|
|
Packit |
78deda |
# that needs to be linked into the merged Netpbm program. This is not used
|
|
Packit |
78deda |
# today, but some day it will be used instead of mergelist (above).
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifeq ($(MERGE_OBJECTS),)
|
|
Packit |
78deda |
MERGE_O_OBJECTS = empty.o
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
MERGE_O_OBJECTS = $(MERGE_OBJECTS)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
merge.o: $(SUBDIRS:%=%/merge.o) $(MERGE_O_OBJECTS)
|
|
Packit |
78deda |
$(LDRELOC) -o $@ $^
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# empty.o is useful in doing a merge build. Every directory must be able to
|
|
Packit |
78deda |
# produce a merge.o file, but not every directory has anything to contribute
|
|
Packit |
78deda |
# to the merge.
|
|
Packit |
78deda |
empty.o: %.o: %.c
|
|
Packit |
78deda |
$(CC) -c $(CFLAGS_PERSONAL) $(CADD) $< -o $@
|
|
Packit |
78deda |
empty.c:
|
|
Packit |
78deda |
cat /dev/null >empty.c
|
|
Packit |
78deda |
|
|
Packit |
78deda |
###########################################################################
|
|
Packit |
78deda |
# PACKAGING / INSTALLING
|
|
Packit |
78deda |
###########################################################################
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Some maintenance notes about $(INSTALL): Some install programs can
|
|
Packit |
78deda |
# install multiple files in one shot; others can take only one file at
|
|
Packit |
78deda |
# a time. Some have a -c option; others ignore -c. Some can take
|
|
Packit |
78deda |
# permissions in mnemonic form (u=rwx,go=rx); others can't, but all
|
|
Packit |
78deda |
# take the encoded form (755). Some have a -d option to install
|
|
Packit |
78deda |
# directories and never install them implicitly. Others create
|
|
Packit |
78deda |
# directories only implicitly. Installbsd and OSF1 Install need a
|
|
Packit |
78deda |
# space in "-m 755". Others don't care. 2000.05.17. OSF1 Install
|
|
Packit |
78deda |
# takes only one parameter: the source file. It picks a destination
|
|
Packit |
78deda |
# directory by default, or you can specify it with a -f option.
|
|
Packit |
78deda |
# 2000.06.15
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# DJGPP can do SYMKINKs for programs but not for ordinary files, so
|
|
Packit |
78deda |
# it define SYMLINKEXE, other system don't need it
|
|
Packit |
78deda |
ifeq ($(SYMLINKEXE)x,x)
|
|
Packit |
78deda |
SYMLINKEXE := $(SYMLINK)
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# An implicit rule for $(PKGDIR)/% does not work because it causes Make
|
|
Packit |
78deda |
# sometimes to believe the directory it creates from this rule is an unneeded
|
|
Packit |
78deda |
# intermediate file and try to delete it later. So we explicitly list the
|
|
Packit |
78deda |
# possible directories under $(PKGDIR):
|
|
Packit |
78deda |
|
|
Packit |
78deda |
PKGMANSUBDIRS = man1 man3 man5 web
|
|
Packit |
78deda |
|
|
Packit |
78deda |
PKGSUBDIRS = bin include include/netpbm lib link misc \
|
|
Packit |
78deda |
$(PKGMANSUBDIRS:%=$(PKGMANDIR)/%)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(PKGSUBDIRS:%=$(PKGDIR)/%):
|
|
Packit |
78deda |
$(SRCDIR)/buildtools/mkinstalldirs $@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: install.merge
|
|
Packit |
78deda |
install.merge: $(NOMERGEBINARIES:%=%_installbin) $(SCRIPTS:%=%_installscript) \
|
|
Packit |
78deda |
$(MERGEBINARIES:%=%_installmerge) $(SUBDIRS:%=%/install.merge)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
%_installmerge: $(PKGDIR)/bin
|
|
Packit |
78deda |
cd $(PKGDIR)/bin ; rm -f $(@:%_installmerge=%)
|
|
Packit |
78deda |
cd $(PKGDIR)/bin ; $(SYMLINKEXE) netpbm$(EXE) $(@:%_installmerge=%)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: install.bin
|
|
Packit |
78deda |
install.bin: $(BINARIES:%=%_installbin) $(SCRIPTS:%=%_installscript) \
|
|
Packit |
78deda |
$(SUBDIRS:%=%/install.bin)
|
|
Packit |
78deda |
# Note that on Cygwin, the executables are actually pbmmake.exe, etc.
|
|
Packit |
78deda |
# Make and Install know that pbmmake.exe counts as pbmmake.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
INSTALLBIN_TARGETS = $(BINARIES:%=%_installbin) netpbm_installbin
|
|
Packit |
78deda |
.PHONY: $(INSTALLBIN_TARGETS)
|
|
Packit |
78deda |
$(INSTALLBIN_TARGETS): $(PKGDIR)/bin
|
|
Packit |
78deda |
$(INSTALL) -c $(STRIPFLAG) -m $(INSTALL_PERM_BIN) \
|
|
Packit |
78deda |
$(@:%_installbin=%) $<
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(SCRIPTS:%=%_installscript): $(PKGDIR)/bin
|
|
Packit |
78deda |
$(INSTALL) -c -m $(INSTALL_PERM_BIN) \
|
|
Packit |
78deda |
$(SRCDIR)/$(SUBDIR)/$(@:%_installscript=%) $<
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: install.data
|
|
Packit |
78deda |
install.data: $(DATAFILES:%=%_installdata) $(SUBDIRS:%=%/install.data)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: $(DATAFILES:%=%_installdata)
|
|
Packit |
78deda |
$(DATAFILES:%=%_installdata): $(PKGDIR)/misc
|
|
Packit |
78deda |
$(INSTALL) -c -m $(INSTALL_PERM_DATA) \
|
|
Packit |
78deda |
$(SRCDIR)/$(SUBDIR)/$(@:%_installdata=%) $<
|
|
Packit |
78deda |
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: clean
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(EXE)x,x)
|
|
Packit |
78deda |
EXEPATTERN = *$(EXE)
|
|
Packit |
78deda |
else
|
|
Packit |
78deda |
EXEPATTERN =
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
clean: $(SUBDIRS:%=%/clean) thisdirclean
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: thisdirclean
|
|
Packit |
78deda |
thisdirclean:
|
|
Packit |
78deda |
-rm -f *.o *.o2 *.a *.so *.so.* *.dll *.dylib *.cat *~ *.i *.s \
|
|
Packit |
78deda |
$(EXEPATTERN) *.def *.lnk \
|
|
Packit |
78deda |
core *.core mergelist mergetrylist *.c1 empty.c \
|
|
Packit |
78deda |
$(BINARIES) pm_types.h
|
|
Packit |
78deda |
-rm -rf importinc
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: distclean
|
|
Packit |
78deda |
distclean: $(SUBDIRS:%=%/distclean) thisdirclean
|
|
Packit |
78deda |
rm -f depend.mk
|
|
Packit |
78deda |
|
|
Packit |
78deda |
DEP_SOURCES = $(wildcard *.c *.cpp *.cc)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
.PHONY: dep
|
|
Packit |
78deda |
dep: $(SUBDIRS:%=%/dep) importinc
|
|
Packit |
78deda |
# We use -MG here because of compile.h and version.h. They need not exist
|
|
Packit |
78deda |
# before the first make after a clean.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(DEP_SOURCES)x,x)
|
|
Packit |
78deda |
$(CC) -MM -MG $(INCLUDES) $(DEP_SOURCES) >depend.mk
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Note: if I stack all these subdirectory targets into one rule, I get
|
|
Packit |
78deda |
# weird behavior where e.g. make install-nonmerge causes all the
|
|
Packit |
78deda |
# %/install.bin makes to happen recursively, but then lib/install.lib
|
|
Packit |
78deda |
# is considered up to date and doesn't get rebuilt.
|
|
Packit |
78deda |
%/install.bin:
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
%/install.lib:
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
%/install.data:
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
%/install.merge:
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
$(SUBDIRS:%=%/all): %/all: $(CURDIR)/%
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
$(SUBDIRS:%=%/mergetrylist): %/mergetrylist: $(CURDIR)/% FORCE
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
$(SUBDIRS:%=%/mergelist): %/mergelist: $(CURDIR)/% FORCE
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
$(SUBDIRS:%=%/merge.o): %/merge.o: $(CURDIR)/% FORCE
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
$(SUBDIRS:%=%/clean): %/clean: $(CURDIR)/%
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
$(SUBDIRS:%=%/distclean): %/distclean: $(CURDIR)/%
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
$(SUBDIRS:%=%/dep): %/dep: $(CURDIR)/%
|
|
Packit |
78deda |
$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
|
|
Packit |
78deda |
SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@)
|
|
Packit |
78deda |
|
|
Packit |
78deda |
#Here is the rule to create the subdirectories. If you're building in the
|
|
Packit |
78deda |
#source tree, they already exist, but in a separate build directory, they may
|
|
Packit |
78deda |
#not.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
ifneq ($(SUBDIR)x,x)
|
|
Packit |
78deda |
# This hack stops us from having a warning due to the same target twice
|
|
Packit |
78deda |
# when we're in the top level directory (because buildtools, etc are in
|
|
Packit |
78deda |
# SUBDIRS).
|
|
Packit |
78deda |
DIRS2 = $(BUILDDIR)/buildtools $(BUILDDIR)/lib $(BUILDDIR)/urt
|
|
Packit |
78deda |
endif
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$(SUBDIRS:%=$(CURDIR)/%) $(DIRS2):
|
|
Packit |
78deda |
mkdir $@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# The automatic dependency generation is a pain in the butt and
|
|
Packit |
78deda |
# totally unnecessary for people just installing the distributed code,
|
|
Packit |
78deda |
# so to avoid needless failures in the field and a complex build, the
|
|
Packit |
78deda |
# rule to generate depend.mk automatically simply creates an
|
|
Packit |
78deda |
# empty file. A developer may do 'make dep' to create a
|
|
Packit |
78deda |
# depend.mk full of real dependencies.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
depend.mk:
|
|
Packit |
78deda |
cat /dev/null >$@
|
|
Packit |
78deda |
|
|
Packit |
78deda |
include depend.mk
|
|
Packit |
78deda |
|
|
Packit |
78deda |
FORCE:
|