2 # Makefile.djgpp.common
3 # shared make information for all builds
6 # Usage: Not designed for direct invocation.
7 # Please use a Makefile.djgpp instead, which will include this file
11 # A Makefile should define some basics, be in the right directory, then
12 # include this Makefile.djgpp.common
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
26 MAKE := $(MAKE) -f Makefile.djgpp
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
33 # These are the source files that need make depends handling.
36 SOURCES = $(wildcard *.c) $(wildcard *.s)
39 # This define is for convenience only, should individual makefiles find
40 # it useful to have a list of possible object files.
42 # ALL_OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) \
43 # $(patsubst %.s,%.o,$(wildcard *.s))
44 ALL_OBJS = $(addsuffix .o,$(basename $(SOURCES)))
46 # These are the directories where built things should end up.
48 DESTINC = DEST/include
49 DESTINCAFS = DEST/include/afs
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.
56 #DEBUGFLAGS = #-g #-pg
58 DEBUGFLAGS = -g -DDEBUG
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
68 # global flags: These are constructed from other defines.
69 # Redefine global flags in individual makefiles if needed.
71 CFLAGS = $(DEBUGFLAGS) $(OPTIMIZEFLAGS) $(DEFINES) $(INCLUDES)
72 CFLAGS2 = $(DEBUGFLAGS) $(OPTIMIZEFLAGS) $(DEFINES) $(INCLUDES2)
73 LDFLAGS = $(DEBUGFLAGS) $(OPTIMIZEFLAGS) $(LIBDIRS)
75 # We are cross-compiling, so some defaults change...
79 MAKEDEPEND = $(CC) $(CFLAGS) -M
80 CPP = $(CC) $(CFLAGS) -E
84 RANLIB = $(AR) -s # GNU-ranlib = GNU-ar -s
87 # RULES FOR ESSENTIAL TARGETS
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
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.
109 # Updates dependencies for all source files
110 # Must be run by hand whenever dependencies change, or before
111 # the very first build
114 $(MAKEDEPEND) $(SOURCES) > Makefile.djgpp.depends
117 # Removes all built files
120 -$(RM) -f $(TARGETS) *.o *.ss core
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.
131 [ -d $(DESTLIB) ] || $(MKDIR) $(DESTLIB)
133 #$(DESTLIB2)/%.a : %.a
134 # [ -d $(DESTLIB2) ] || $(MKDIR) $(DESTLIB2)
137 [ -d $(DESTINC) ] || $(MKDIR) $(DESTINC)
139 $(DESTINCAFS)/%.h : %.h
140 [ -d $(DESTINC) ] || $(MKDIR) $(DESTINC)
141 [ -d $(DESTINCAFS) ] || $(MKDIR) $(DESTINCAFS)
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)/
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.
154 $(CPP) $(CPPFLAGS) -P -x c-header $< $(OUTPUT_OPTION)
156 $(AS) $(ASFLAGS) $< $(OUTPUT_OPTION)
158 # new implicit rule to create libraries
165 # new implicit rule to create executables
166 # $(LD) $(LDFLAGS) $^ -o $(basename $@)
168 $(CC) $(LDFLAGS) -Wl,-\( $^ -Wl,-\) -o $(basename $@)
172 # DEPENDENCY INFORMATION
175 # always request a local dependency list
177 ifeq ($(MAKECMDGOALS),depends)
180 ifeq ($(MAKECMDGOALS),includes)
184 include Makefile.djgpp.depends
185 # ensure a build process breaks if Makefile.djgpp.depends does not exist
187 Makefile.djgpp.depends :
188 @echo Please run \"$(MAKE) depends\" to generate dependency information.