[444] | 1 | #------------------------------------------------------------------------- |
---|
| 2 | # Source files |
---|
| 3 | #------------------------------------------------------------------------- |
---|
| 4 | |
---|
| 5 | gloss_hdrs = \ |
---|
| 6 | machine/syscall.h \ |
---|
| 7 | |
---|
| 8 | gloss_srcs = \ |
---|
| 9 | nanosleep.c \ |
---|
| 10 | sys_access.c \ |
---|
| 11 | sys_chdir.c \ |
---|
| 12 | sys_chmod.c \ |
---|
| 13 | sys_chown.c \ |
---|
| 14 | sys_close.c \ |
---|
| 15 | sys_conv_stat.c \ |
---|
| 16 | sys_execve.c \ |
---|
| 17 | sys_exit.c \ |
---|
| 18 | sys_faccessat.c \ |
---|
| 19 | sys_fork.c \ |
---|
| 20 | sys_fstatat.c \ |
---|
| 21 | sys_fstat.c \ |
---|
| 22 | sys_ftime.c \ |
---|
| 23 | sys_getcwd.c \ |
---|
| 24 | sys_getpid.c \ |
---|
| 25 | sys_gettimeofday.c \ |
---|
| 26 | sys_isatty.c \ |
---|
| 27 | sys_kill.c \ |
---|
| 28 | sys_link.c \ |
---|
| 29 | sys_lseek.c \ |
---|
| 30 | sys_lstat.c \ |
---|
| 31 | sys_openat.c \ |
---|
| 32 | sys_open.c \ |
---|
| 33 | sys_read.c \ |
---|
| 34 | sys_sbrk.c \ |
---|
| 35 | sys_stat.c \ |
---|
| 36 | sys_sysconf.c \ |
---|
| 37 | sys_times.c \ |
---|
| 38 | sys_unlink.c \ |
---|
| 39 | sys_utime.c \ |
---|
| 40 | sys_wait.c \ |
---|
| 41 | sys_write.c |
---|
| 42 | |
---|
| 43 | gloss_specs = \ |
---|
| 44 | nano.specs sim.specs |
---|
| 45 | |
---|
| 46 | # Extra files |
---|
| 47 | |
---|
| 48 | crt0_asm = crt0.S |
---|
| 49 | |
---|
| 50 | # Multilib support variables. |
---|
| 51 | # TOP is used instead of MULTI{BUILD,SRC}TOP. |
---|
| 52 | |
---|
| 53 | MULTIDIRS = |
---|
| 54 | MULTISUBDIR = |
---|
| 55 | MULTIDO = true |
---|
| 56 | MULTICLEAN = true |
---|
| 57 | |
---|
| 58 | #------------------------------------------------------------------------- |
---|
| 59 | # Basic setup |
---|
| 60 | #------------------------------------------------------------------------- |
---|
| 61 | |
---|
| 62 | # Remove all default implicit rules since they can cause subtle bugs |
---|
| 63 | # and they just make things run slower |
---|
| 64 | |
---|
| 65 | .SUFFIXES: |
---|
| 66 | % : %,v |
---|
| 67 | % : RCS/%,v |
---|
| 68 | % : RCS/% |
---|
| 69 | % : s.% |
---|
| 70 | % : SCCS/s.% |
---|
| 71 | |
---|
| 72 | # Default is to build the prereqs of the all target (defined at bottom) |
---|
| 73 | |
---|
| 74 | default : all |
---|
| 75 | .PHONY : default |
---|
| 76 | |
---|
| 77 | # Source directory |
---|
| 78 | |
---|
| 79 | obj_dir := . |
---|
| 80 | src_dir := @srcdir@ |
---|
| 81 | VPATH := $(src_dir) $(src_dir)/machine |
---|
| 82 | |
---|
| 83 | # Installation directories |
---|
| 84 | |
---|
| 85 | prefix := @prefix@ |
---|
| 86 | DESTDIR ?= $(prefix) |
---|
| 87 | |
---|
| 88 | install_hdrs_dir := $(DESTDIR)$(prefix)/$(target_alias)/include/machine |
---|
| 89 | install_libs_dir = $(DESTDIR)$(prefix)/$(target_alias)/lib${MULTISUBDIR} |
---|
| 90 | |
---|
| 91 | #------------------------------------------------------------------------- |
---|
| 92 | # Programs and flags |
---|
| 93 | #------------------------------------------------------------------------- |
---|
| 94 | |
---|
| 95 | # C compiler |
---|
| 96 | |
---|
| 97 | CC := @CC@ |
---|
| 98 | CFLAGS := @CFLAGS@ |
---|
| 99 | CPPFLAGS := -I$(obj_dir) -I$(src_dir) |
---|
| 100 | COMPILE := $(CC) -MMD -MP $(CPPFLAGS) $(CFLAGS) |
---|
| 101 | |
---|
| 102 | # Library creation |
---|
| 103 | |
---|
| 104 | AR := @AR@ |
---|
| 105 | RANLIB := @RANLIB@ |
---|
| 106 | |
---|
| 107 | # Installation |
---|
| 108 | |
---|
| 109 | INSTALL := @INSTALL@ |
---|
| 110 | INSTALL_DATA := @INSTALL_DATA@ |
---|
| 111 | |
---|
| 112 | #------------------------------------------------------------------------- |
---|
| 113 | # Build Object Files from C Source |
---|
| 114 | #------------------------------------------------------------------------- |
---|
| 115 | |
---|
| 116 | gloss_c_srcs = $(filter %.c, $(gloss_srcs)) |
---|
| 117 | gloss_c_objs = $(patsubst %.c, %.o, $(notdir $(gloss_c_srcs))) |
---|
| 118 | gloss_c_deps = $(patsubst %.c, %.d, $(notdir $(gloss_c_srcs))) |
---|
| 119 | |
---|
| 120 | $(gloss_c_objs) : %.o : %.c |
---|
| 121 | $(COMPILE) -c $< |
---|
| 122 | |
---|
| 123 | gloss_objs += $(gloss_c_objs) |
---|
| 124 | deps += $(gloss_c_deps) |
---|
| 125 | junk += $(gloss_c_deps) $(gloss_c_objs) |
---|
| 126 | |
---|
| 127 | sim_c_objs = $(patsubst %.c, sim-%.o, $(notdir $(gloss_c_srcs))) |
---|
| 128 | sim_c_deps = $(patsubst %.c, sim-%.d, $(notdir $(gloss_c_srcs))) |
---|
| 129 | |
---|
| 130 | $(sim_c_objs): sim-%.o : %.c |
---|
| 131 | $(COMPILE) -c -DUSING_SIM_SPECS -o $@ $< |
---|
| 132 | |
---|
| 133 | sim_objs += $(sim_c_objs) |
---|
| 134 | deps += $(sim_c_deps) |
---|
| 135 | junk += $(sim_c_deps) $(sim_c_objs) |
---|
| 136 | |
---|
| 137 | #------------------------------------------------------------------------- |
---|
| 138 | # Build Object Files from Assembly Source |
---|
| 139 | #------------------------------------------------------------------------- |
---|
| 140 | |
---|
| 141 | gloss_asm_srcs = $(filter %.S, $(gloss_srcs)) |
---|
| 142 | gloss_asm_objs = $(patsubst %.S, %.o, $(notdir $(gloss_asm_srcs))) |
---|
| 143 | gloss_asm_deps = $(patsubst %.S, %.d, $(notdir $(gloss_asm_srcs))) |
---|
| 144 | |
---|
| 145 | $(gloss_asm_objs) : %.o : %.S |
---|
| 146 | $(COMPILE) -c -o $@ $< |
---|
| 147 | |
---|
| 148 | gloss_objs += $(gloss_asm_objs) |
---|
| 149 | deps += $(gloss_asm_deps) |
---|
| 150 | junk += $(gloss_asm_deps) $(gloss_asm_objs) |
---|
| 151 | |
---|
| 152 | sim_asm_objs = $(patsubst %.S, sim-%.o, $(notdir $(gloss_asm_srcs))) |
---|
| 153 | sim_asm_deps = $(patsubst %.S, sim-%.d, $(notdir $(gloss_asm_srcs))) |
---|
| 154 | |
---|
| 155 | $(sim_asm_objs) : sim-%.o : %.S |
---|
| 156 | $(COMPILE) -c -DUSING_SIM_SPECS -o $@ $< |
---|
| 157 | |
---|
| 158 | sim_objs += $(sim_asm_objs) |
---|
| 159 | deps += $(sim_asm_deps) |
---|
| 160 | junk += $(sim_asm_deps) $(sim_asm_objs) |
---|
| 161 | |
---|
| 162 | #------------------------------------------------------------------------- |
---|
| 163 | # Build libgloss.a |
---|
| 164 | #------------------------------------------------------------------------- |
---|
| 165 | |
---|
| 166 | gloss_lib = libgloss.a |
---|
| 167 | $(gloss_lib) : $(gloss_objs) |
---|
| 168 | $(AR) rcv $@ $^ |
---|
| 169 | $(RANLIB) $@ |
---|
| 170 | |
---|
| 171 | junk += $(gloss_lib) |
---|
| 172 | |
---|
| 173 | install_hdrs += $(gloss_hdrs) |
---|
| 174 | install_libs += $(gloss_lib) |
---|
| 175 | install_specs += $(gloss_specs) |
---|
| 176 | |
---|
| 177 | #------------------------------------------------------------------------- |
---|
| 178 | # Build libsim.a |
---|
| 179 | #------------------------------------------------------------------------- |
---|
| 180 | |
---|
| 181 | sim_lib = libsim.a |
---|
| 182 | $(sim_lib) : $(sim_objs) |
---|
| 183 | $(AR) rcv $@ $^ |
---|
| 184 | $(RANLIB) $@ |
---|
| 185 | |
---|
| 186 | junk += $(sim_lib) |
---|
| 187 | |
---|
| 188 | install_libs += $(sim_lib) |
---|
| 189 | |
---|
| 190 | #------------------------------------------------------------------------- |
---|
| 191 | # Build crt0.o |
---|
| 192 | #------------------------------------------------------------------------- |
---|
| 193 | |
---|
| 194 | crt0_obj = $(patsubst %.S, %.o, $(crt0_asm)) |
---|
| 195 | crt0_deps = $(patsubst %.S, %.d, $(crt0_asm)) |
---|
| 196 | |
---|
| 197 | $(crt0_obj) : %.o : %.S |
---|
| 198 | $(COMPILE) -c $< |
---|
| 199 | |
---|
| 200 | deps += $(crt0_deps) |
---|
| 201 | junk += $(crt0_deps) $(crt0_obj) |
---|
| 202 | |
---|
| 203 | install_libs += $(crt0_obj) |
---|
| 204 | |
---|
| 205 | #------------------------------------------------------------------------- |
---|
| 206 | # Autodependency files |
---|
| 207 | #------------------------------------------------------------------------- |
---|
| 208 | |
---|
| 209 | -include $(deps) |
---|
| 210 | |
---|
| 211 | deps : $(deps) |
---|
| 212 | .PHONY : deps |
---|
| 213 | |
---|
| 214 | #------------------------------------------------------------------------- |
---|
| 215 | # Installation |
---|
| 216 | #------------------------------------------------------------------------- |
---|
| 217 | |
---|
| 218 | install_hdrs_wdir += $(addprefix $(src_dir)/, $(install_hdrs)) |
---|
| 219 | install-hdrs : $(install_hdrs_wdir) |
---|
| 220 | test -d $(install_hdrs_dir) || mkdir -p $(install_hdrs_dir) |
---|
| 221 | for file in $^; do \ |
---|
| 222 | $(INSTALL_DATA) $$file $(install_hdrs_dir)/; \ |
---|
| 223 | done |
---|
| 224 | |
---|
| 225 | install-libs : $(install_libs) |
---|
| 226 | test -d $(install_libs_dir) || mkdir -p $(install_libs_dir) |
---|
| 227 | for file in $^; do \ |
---|
| 228 | $(INSTALL_DATA) $$file $(install_libs_dir)/$$file; \ |
---|
| 229 | done |
---|
| 230 | |
---|
| 231 | install-specs : $(install_specs) |
---|
| 232 | test -d $(install_libs_dir) || mkdir -p $(install_libs_dir) |
---|
| 233 | for file in $^; do \ |
---|
| 234 | $(INSTALL_DATA) $$file $(install_libs_dir)/; \ |
---|
| 235 | done |
---|
| 236 | |
---|
| 237 | install : install-hdrs install-libs install-specs |
---|
| 238 | .PHONY : install install-hdrs install-libs |
---|
| 239 | |
---|
| 240 | #------------------------------------------------------------------------- |
---|
| 241 | # Regenerate configure information |
---|
| 242 | #------------------------------------------------------------------------- |
---|
| 243 | |
---|
| 244 | configure_prereq = \ |
---|
| 245 | $(src_dir)/configure.in \ |
---|
| 246 | |
---|
| 247 | $(src_dir)/configure : $(configure_prereq) |
---|
| 248 | cd $(src_dir) && autoconf |
---|
| 249 | |
---|
| 250 | config.status : $(src_dir)/configure |
---|
| 251 | ./config.status --recheck |
---|
| 252 | |
---|
| 253 | Makefile : $(src_dir)/Makefile.in config.status |
---|
| 254 | ./config.status |
---|
| 255 | |
---|
| 256 | dist_junk += config.status Makefile config.log |
---|
| 257 | |
---|
| 258 | #------------------------------------------------------------------------- |
---|
| 259 | # Default |
---|
| 260 | #------------------------------------------------------------------------- |
---|
| 261 | |
---|
| 262 | all : $(install_libs) |
---|
| 263 | .PHONY : all |
---|
| 264 | |
---|
| 265 | #------------------------------------------------------------------------- |
---|
| 266 | # Clean up junk |
---|
| 267 | #------------------------------------------------------------------------- |
---|
| 268 | |
---|
| 269 | clean : |
---|
| 270 | rm -rf *~ \#* $(junk) |
---|
| 271 | |
---|
| 272 | distclean : |
---|
| 273 | rm -rf *~ \#* $(junk) $(dist_junk) |
---|
| 274 | |
---|
| 275 | .PHONY : clean distclean |
---|