netbsd-has-long-long-20040806
[openafs.git] / src / config / Makefile.djgpp.common
1 #
2 # Makefile.djgpp.common
3 # shared make information for all builds
4 # requires gmake
5 #
6 # Usage: Not designed for direct invocation.
7 # Please use a Makefile.djgpp instead, which will include this file
8 # as a resource.
9 #
10 # Makefile.djgpp
11 # A Makefile should define some basics, be in the right directory, then
12 # include this Makefile.djgpp.common
13 # Please define
14 #       TARGETS         a list of executables the Makefile covers (with .exe)
15 #       target rules    dependencies between an executable and its object files
16 #       install target  --- to be determined ---
17 #       all target      list the exported files of the build
18
19 #
20 # VARIABLE SETUP
21 #
22
23 SHELL = /bin/sh
24 MKDIR = /bin/mkdir -p
25 CP = /bin/cp -f
26 MAKE := $(MAKE) -f Makefile.djgpp
27
28 .PHONY : install all clean depends
29 # depends is a phony target even though we have a file by that name
30 # to hold dependency information, because we want it to be refreshed every
31 # time a user invokes make depends, regardless of how up-to-date it may appear
32
33 # These are the source files that need make depends handling.
34 #
35 ifndef SOURCES
36 SOURCES = $(wildcard *.c) $(wildcard *.s)
37 endif
38
39 # This define is for convenience only, should individual makefiles find
40 # it useful to have a list of possible object files.
41 #
42 # ALL_OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) \
43 #       $(patsubst %.s,%.o,$(wildcard *.s))
44 ALL_OBJS = $(addsuffix .o,$(basename $(SOURCES)))
45
46 # These are the directories where built things should end up.
47 #
48 DESTINC = DEST/include
49 DESTINCAFS = DEST/include/afs
50 DESTLIB = DEST/lib
51 DESTBIN = DEST/bin
52
53 # global flags:  Please set or empty these global flags as needed,
54 # or append to/modify them in local makefiles for directory-specific behavior.
55 #
56 #DEBUGFLAGS = #-g #-pg
57         # -Wall
58 DEBUGFLAGS = -g -DDEBUG
59 #OPTIMIZEFLAGS = -O2
60 #OPTIMIZEFLAGS =
61 INCLUDES = -IDEST/include # -I../client_osi
62 # includes2 is for compiling components in outer directory
63 INCLUDES2 = -I../djgpp/include -I../djgpp/client_osi
64 LIBDIRS = -L$(DESTLIB)
65 DEFINES = -Dfds_bits=fd_bits
66 # -DIDRIVE_X86_ENV
67
68 # global flags:  These are constructed from other defines.
69 # Redefine global flags in individual makefiles if needed.
70 #
71 CFLAGS = $(DEBUGFLAGS) $(OPTIMIZEFLAGS) $(DEFINES) $(INCLUDES) 
72 CFLAGS2 = $(DEBUGFLAGS) $(OPTIMIZEFLAGS) $(DEFINES) $(INCLUDES2) 
73 LDFLAGS = $(DEBUGFLAGS) $(OPTIMIZEFLAGS) $(LIBDIRS)
74
75 # We are cross-compiling, so some defaults change...
76 #
77 CC = dos-gcc -bmmap
78 #CC = gcc -bmmap
79 MAKEDEPEND = $(CC) $(CFLAGS) -M
80 CPP = $(CC) $(CFLAGS) -E
81 LD = dos-ld
82 AS = dos-as
83 AR = dos-ar
84 RANLIB = $(AR) -s       # GNU-ranlib = GNU-ar -s
85
86 #
87 # RULES FOR ESSENTIAL TARGETS
88 #
89
90 # make all
91 #       Builds the files that need to be built
92 #       Actual files to be built should be listed as dependencies
93 #       in the Makefile that includes this one.
94 #       A do-nothing target is listed here to ensure it is the first
95 #       (default) target.
96 all : 
97
98 # make install
99 #       Installs the built files in the right place
100 #       Actual files in their final destinations should be listed
101 #       as dependencies in the makefile that includes this one.
102 #       For example, if install needs to copy libwidget.a to $DESTLIB,
103 #       the makefile should have a line 'install : $(DESTLIB)/libwidget.a'.
104 #       It may optionally have a body of commands that handle any
105 #       directory-specific post-processing.
106 install : all
107
108 # make depends
109 #       Updates dependencies for all source files
110 #       Must be run by hand whenever dependencies change, or before
111 #       the very first build
112 #
113 depends :
114         $(MAKEDEPEND) $(SOURCES) > Makefile.djgpp.depends
115
116 # make clean
117 #       Removes all built files
118 #
119 clean :
120         -$(RM) -f $(TARGETS) *.o *.ss core
121
122 #
123 # IMPLICIT RULES
124 #
125
126 # new implicit rules install files
127 # These come first so that the more general rule to create libraries does not
128 # trump the rule below to install libraries.
129 #
130 $(DESTLIB)/%.a : %.a
131         [ -d $(DESTLIB) ] || $(MKDIR) $(DESTLIB)
132         $(CP) $< $@
133 #$(DESTLIB2)/%.a : %.a
134 #       [ -d $(DESTLIB2) ] || $(MKDIR) $(DESTLIB2)
135 #       $(CP) $< $@
136 $(DESTINC)/%.h : %.h
137         [ -d $(DESTINC) ] || $(MKDIR) $(DESTINC)
138         $(CP) $< $@
139 $(DESTINCAFS)/%.h : %.h
140         [ -d $(DESTINC) ] || $(MKDIR) $(DESTINC)
141         [ -d $(DESTINCAFS) ] || $(MKDIR) $(DESTINCAFS)
142         $(CP) $< $@
143 # special: djgpp can make .exe and coff file pairs; copy both if possible
144 $(DESTBIN)/%.exe : %.exe
145         [ -d $(DESTBIN) ] || $(MKDIR) $(DESTBIN)
146         -[ -r $(basename $<) ] && $(CP) $(basename $<) $(DESTBIN)/
147         $(CP) $^ $@
148
149 # new implicit rules to handle assembly (.s), AFS-style
150 # AFS uses %.s -> cpp -> %.ss -> as -> %.o rather than the
151 # gmake %.S -> cpp -> %.s -> as -> %.o default. 
152 #
153 %.ss : %.s
154         $(CPP) $(CPPFLAGS) -P -x c-header $< $(OUTPUT_OPTION)
155 %.o : %.ss
156         $(AS) $(ASFLAGS) $< $(OUTPUT_OPTION)
157
158 # new implicit rule to create libraries
159 #
160 %.a :
161         -$(RM) $@
162         $(AR) crv $@ $^
163         $(RANLIB) $@
164
165 # new implicit rule to create executables
166 #       $(LD) $(LDFLAGS) $^ -o $(basename $@)
167 %.exe :
168         $(CC) $(LDFLAGS) -Wl,-\( $^ -Wl,-\) -o $(basename $@)
169         
170
171 #
172 # DEPENDENCY INFORMATION
173 #
174
175 # always request a local dependency list
176 #
177 ifeq ($(MAKECMDGOALS),depends)
178   DONTDEP=1
179 endif 
180 ifeq ($(MAKECMDGOALS),includes)
181   DONTDEP=1
182 endif 
183 ifneq ($(DONTDEP),1)
184 include Makefile.djgpp.depends
185 # ensure a build process breaks if Makefile.djgpp.depends does not exist
186 #
187 Makefile.djgpp.depends :
188         @echo Please run \"$(MAKE) depends\" to generate dependency information.
189         @exit 1
190 endif