summaryrefslogtreecommitdiff
path: root/data/defs.make
blob: ad2c9ed629c2503be3604cbcef5e54ec716c4350 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Common definitions for Makefiles in this directory hierarchy.
# 
# Copyright (C) 1992, 2004, 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

 
# A GNUmakefile in this hierarchy should first include this file, and
# then include either `defsprog.make' or `defslib.make', as appropriate.
# Dependencies are created by `make depend', which writes onto the file
# `M.depend'.  A Makefile should include that, also, at its end.


# These variables are used only when the top-level Makefile is not.
CC = gcc
CFLAGS = -g
LDFLAGS = $(XLDFLAGS)
LIBS = -lm
RANLIB = ranlib
srcdir = .

# Here is the rule to make `foo.o' from `foo.c'.  We want CFLAGS to be
# user-settable, so we can't use the default implicit rule.
kpathsea_srcdir = ../../kpathsea
CPPFLAGS = $(DEFS) -I$(kpathsea_parent) -I$(srcdir)/../include $(xincludedir)
%.o: %.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $<

# Here is the rule to make `foo.c' from `foo.y' using Bison.
# (GNU make's default rule assumes $(YACC) outputs y.tab.c.)
# We always use Bison, not Yacc.
BISON = bison
BISONFLAGS = -d -t
%.c %.h: %.y
	$(BISON) $(BISONFLAGS) $< -o $*.c

# Libraries to support bitmap font formats.  Defined just so the main
# Makefiles can use $(bitmap_libs), in case we ever add more formats.
bitmap_libs = gf pk

# If the caller wants our widgets, they also want the other X libraries.
# On SunOS 4.1, dynamic linking with -lXaw fails: formWidgetClass and
# the other X widgets in ../widgets are multiply defined.  I don't
# understand why the entire library file is pulled in with dynamic linking.
# 
ifneq "$(findstring widgets, $(libraries))" ""
dlsym = ../$(srcdir)/lib/dlsym.o
X_sys_libraries = -lXaw -lXmu -lXext -lXt -lX11
X_libraries = -static $(xlibdir) $(X_sys_libraries) $(dlsym) $(wlibs)
endif

# Compose the entire list of libraries from the defined `libraries'.  We
# always add `lib' at the beginning and the end, since everything uses that.
ourlibs := $(foreach lib,lib $(libraries) lib,../$(srcdir)/$(lib)/$(lib).a)

# This is what we will link with.
LOADLIBES = $(ourlibs) $(X_libraries) $(LIBS)

kpathsea_parent = ../..
kpathsea_dir = $(kpathsea_parent)/kpathsea
kpathsea = $(kpathsea_dir)/libkpathsea.a

# Make the list of object files, headers, and sources.  The headers only
# matter for tags.
sources := $(addsuffix .c, $(c_and_h) $(c_only))
headers := $(addsuffix .h, $(c_and_h) $(h_only))
objects := $(addsuffix .o, $(basename $(y) $(sources)))

# The real default target is in either defslib.make or defsprog.make.
default: all
.PHONY: default

# Make the dependency file.
# 
# We don't depend on `$(sources)' because most changes to the sources don't
# change the dependencies.
# 
# We assume at most one Bison source per directory here.  We also assume
# GCC 2 for generating the dependencies of the Bison-generated C file.
# Put the Bison stuff first in the dependency file, since typically lots
# of other files depend on the Bison .h files.
M.depend depend:
	rm -f M.depend
	test -z "$(y)" || DEPENDENCIES_OUTPUT="M.depend $(y).o" \
          gcc -x c-header -E $(CPPFLAGS) $(y).y > /dev/null
	$(CC) -M $(CPPFLAGS) $(sources) \
	  | sed -e 's,\(\.\./\)\+kpathsea/,$$(kpathsea_srcdir)/,g' \
	        -e 's,/usr[^ ]* ,,g' \
	        -e 's,/usr[^ ]*$$,,g' \
	  | grep -v '^ *\\$$' \
	>> M.depend
.PHONY: depend

# When `make dist' is called from above, we expect $(dir) to be set to
# the directory in which  we're currently making.
distdir = ../$(top_distdir)/$(dir)

# We use `find' instead of just `ln *.c *.h' here because not all
# directories have .c and .h files.
dist::
	mkdir $(distdir)
	ln ChangeLog GNUmakefile M.depend README $(distdir)
	find \( -name \*.c -o -name \*.h \) -exec ln '{}' $(distdir)/'{}' \;
.PHONY: dist

# Prevent GNU make version 3 from overflowing system V's arg limit.
.NOEXPORT:

mostlyclean::
# Remove most files.
	rm -f $(objects) *.output
.PHONY: mostlyclean

clean:: mostlyclean
# Remove all files that are made by `make all', etc.
	rm -f *.dvi *.log *.ps core
.PHONY: clean

distclean:: clean
# Delete all files that users would normally create from compilation and
# installation. 
.PHONY: distclean

extraclean:: distclean
# Delete anything likely to be found in the source directory
# that shouldn't be in the distribution.
	rm -f *.tfm *gf *pk *.bzr *~ *\#* patch* *.orig *.rej

realclean:: distclean
# Remove all files that can be remade with `make'.
	rm -f TAGS $(addsuffix .c, $(y)) $(addsuffix .h, $(y))
.PHONY: realclean