Skip to content

Commit 05590c6

Browse files
committed
Reorganize build system to support -mfastcall capable compilers
This also now puts all libraries & code into the build directory. Empty directories lib, lib020 etc. can safely be removed
1 parent 2fac25c commit 05590c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+146
-405
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,4 @@ unix/test-vfork
158158
*.a
159159
*~
160160
*.exe
161+
build

.scripts/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# -x: Display expanded script commands
55

66
make SHELL=/bin/bash
7-
make SHELL=/bin/bash prefix="${INSTALL_DIR}" install
7+
make SHELL=/bin/bash DESTDIR="${INSTALL_DIR}" install
88

99
find "${INSTALL_DIR}" -type f -perm -a=x -exec m68k-atari-mint-strip -s {} \;
1010
find "${INSTALL_DIR}" -type f \( -name '*.a' -o -name '*.o' \) -exec m68k-atari-mint-strip -S -X -w -N '.L[0-9]*' {} \;

Makefile

+93-26
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,37 @@ endif
2323

2424
SUBDIRS = include syscall startup argp conf crypt dirent gmp login mintlib \
2525
misc multibyte posix pwdgrp shadow signal socket stdiio stdio stdlib \
26-
string sysvipc termios time unix lib tz sunrpc
27-
DIST_SUBDIRS = argp conf crypt dirent gmp include lib \
26+
string sysvipc termios time unix
27+
DIST_SUBDIRS = argp conf crypt dirent gmp include \
2828
login mintlib misc multibyte posix pwdgrp shadow signal socket startup \
2929
stdiio stdio stdlib string sunrpc syscall sysvipc termios time tz unix
3030
TEST_SUBDIRS = argp crypt dirent login mintlib misc posix pwdgrp shadow signal \
3131
socket startup stdiio stdio stdlib string time tz unix
3232

33-
ifeq ($(WITH_PROFILE_LIB), yes)
34-
SUBDIRS += lib_p
35-
DIST_SUBDIRS += lib_p
33+
BASE_FLAVOURS = m68000
34+
ifeq ($(WITH_020_LIB), yes)
35+
BASE_FLAVOURS += m68020
36+
endif
37+
ifeq ($(WITH_V4E_LIB), yes)
38+
BASE_FLAVOURS += coldfire
3639
endif
40+
FLAVOURS = $(BASE_FLAVOURS)
3741

42+
ifeq ($(WITH_PROFILE_LIB), yes)
43+
FLAVOURS += $(addsuffix -profile,$(BASE_FLAVOURS))
44+
endif
3845
ifeq ($(WITH_DEBUG_LIB), yes)
39-
SUBDIRS += lib_g
40-
DIST_SUBDIRS += lib_g
46+
FLAVOURS += $(addsuffix -debug,$(BASE_FLAVOURS))
4147
endif
42-
43-
ifeq ($(WITH_020_LIB), yes)
44-
SUBDIRS += lib020
45-
DIST_SUBDIRS += lib020
46-
ifeq ($(WITH_DEBUG_LIB), yes)
47-
SUBDIRS += lib020_g
48-
DIST_SUBDIRS += lib020_g
49-
endif
48+
ifeq ($(WITH_FASTCALL), yes)
49+
FLAVOURS += $(addsuffix -fastcall,$(BASE_FLAVOURS))
5050
endif
5151

52-
ifeq ($(WITH_V4E_LIB), yes)
53-
SUBDIRS += libv4e
54-
DIST_SUBDIRS += libv4e
55-
ifeq ($(WITH_DEBUG_LIB), yes)
56-
SUBDIRS += libv4e_g
57-
DIST_SUBDIRS += libv4e_g
58-
endif
59-
endif
52+
LIBDIRS += $(addprefix build/,$(FLAVOURS))
53+
54+
SUBDIRS += $(LIBDIRS)
55+
# must come after lib dirs, since it needs the just-built library
56+
SUBDIRS += tz sunrpc
6057

6158
include $(srcdir)/BINFILES
6259
include $(srcdir)/SRCFILES
@@ -69,7 +66,64 @@ include phony
6966

7067
all: all-here all-recursive
7168

72-
all-here:
69+
# the SRCFILES, EXTRAFILES, and MISCFILES are still required by
70+
# the rules; FIXME
71+
all-here: $(top_srcdir)/includepath
72+
@for flavour in $(FLAVOURS); do \
73+
dir=build/$$flavour; \
74+
mkdir -p $$dir/.deps; \
75+
test -f $$dir/SRCFILES || touch $$dir/SRCFILES; \
76+
test -f $$dir/EXTRAFILES || touch $$dir/EXTRAFILES; \
77+
test -f $$dir/MISCFILES || touch $$dir/MISCFILES; \
78+
cflags=""; \
79+
nocflags=""; \
80+
qualifier=""; \
81+
cflags=""; \
82+
for f in `echo $$flavour | sed -e 's/-/ /g'`; do \
83+
case $$f in \
84+
profile) \
85+
qualifier=_p; \
86+
nocflags="-fomit-frame-pointer"; \
87+
cflags="$$cflags $(CFLAGS_profile)"; \
88+
;; \
89+
debug) \
90+
qualifier=_g; \
91+
nocflags="-O2 -O3 -fomit-frame-pointer -fexpensive-optimizations"; \
92+
cflags="$$cflags $(CFLAGS_debug)"; \
93+
;; \
94+
m68000) \
95+
cflags="$$cflags $(CFLAGS_m68000)"; \
96+
;; \
97+
m68020) \
98+
cflags="$$cflags $(CFLAGS_m68020)"; \
99+
;; \
100+
coldfire) \
101+
cflags="$$cflags $(CFLAGS_coldfire)"; \
102+
;; \
103+
short) \
104+
cflags="$$cflags $(CFLAGS_short)"; \
105+
;; \
106+
fastcall) \
107+
cflags="$$cflags $(CFLAGS_fastcall)"; \
108+
;; \
109+
esac; \
110+
done; \
111+
instdir=`$(CC) $$cflags -print-multi-directory`; \
112+
test -f $$dir/BINFILES || echo "BINFILES = libc$${qualifier}.a libiio$${qualifier}.a" > $$dir/BINFILES; \
113+
( echo "SHELL = /bin/sh"; \
114+
echo "srcdir = ."; \
115+
echo "top_srcdir = ../.."; \
116+
echo "subdir = $$dir"; \
117+
echo "qualifier = $$qualifier"; \
118+
echo "cflags = $$cflags"; \
119+
echo "nocflags = $$nocflags"; \
120+
echo "instdir = $$instdir"; \
121+
echo ""; \
122+
echo "default: all"; \
123+
echo ""; \
124+
echo 'include $$(top_srcdir)/buildrules'; \
125+
) > $$dir/Makefile; \
126+
done
73127

74128
install: all-here install-recursive zoneswarning
75129

@@ -84,7 +138,7 @@ install-headers: install-include-recursive
84138
install-man: all install-man-recursive
85139

86140
clean:: clean-recursive
87-
rm -rf .deps includepath CFILES
141+
rm -rf .deps includepath CFILES build
88142

89143
distclean:: distclean-recursive
90144

@@ -100,6 +154,17 @@ bindistdir = $(distdir)-bin
100154
topdistdir = $(distdir)
101155
topbindistdir = $(topdistdir)-bin
102156

157+
$(top_srcdir)/includepath: $(top_srcdir)/configvars
158+
@echo "Generating $@"; \
159+
installdir=`$(CC) --print-search-dirs | awk '{ print $$2; exit; }'`; \
160+
echo "$${installdir}include -I$${installdir}include-fixed" >$@
161+
@if [ -z "$$(<$@)" ]; then \
162+
rm $@; \
163+
echo "error: The syntax \$$(<file) is unsupported by $(SHELL)." >&2; \
164+
echo " Please use \"$(MAKE) SHELL=/bin/bash\" instead." >&2; \
165+
exit 1; \
166+
fi
167+
103168
dist-check:
104169
@echo "WARNING: This will take VERY long and will consume"
105170
@echo "VERY much diskspace!!!"
@@ -175,7 +240,9 @@ uninstall-include-recursive uninstall-man-recursive:
175240
echo "attempting to install on host; aborting" >&2; \
176241
exit 1; \
177242
fi; \
178-
list='$(SUBDIRS)'; for subdir in $$list; do \
243+
list='$(SUBDIRS)'; \
244+
if test "$@" = clean-recursive; then list='$(filter-out $(LIBDIRS),$(SUBDIRS))'; fi; \
245+
for subdir in $$list; do \
179246
target=`echo $@ | sed s/-recursive//`; \
180247
echo "Making $$target in $$subdir"; \
181248
(cd $$subdir && $(MAKE) $$target) \

argp/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SHELL = /bin/sh
1111

1212
srcdir = .
1313
top_srcdir = ..
14-
subdir = argp
14+
subdir = argp
1515

1616
SUBDIRS =
1717

buildrules

+15-24
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ am__v_AR_0 = @echo " AR " $@;
1616
AM_V_RANLIB = $(am__v_RANLIB_$(V))
1717
am__v_RANLIB_ = $(am__v_RANLIB_$(AM_DEFAULT_VERBOSITY))
1818
am__v_RANLIB_0 = @echo " RANLIB" $@;
19+
AM_V_STRIP = $(am__v_STRIP_$(V))
20+
am__v_STRIP_ = $(am__v_STRIP_$(AM_DEFAULT_VERBOSITY))
21+
am__v_STRIP_0 = @echo " STRIP " $@;
1922

2023
# This is the slow part of the Makefiles. Exclude it if we build
2124
# binary distributions.
2225
ifndef top_distdir
2326

27+
# qualifier is _p, _g, or empty
2428
libc := libc$(qualifier).a
2529
libiio := libiio$(qualifier).a
2630
librpcsvc := librpcsvc$(qualifier).a
@@ -108,9 +112,6 @@ SRCS := $(ARGPSRCS) $(CRYPTSRCS) $(DIRENTSRCS) $(GMPSRCS) $(LOGINSRCS) $(MINTLIB
108112
$(STRINGSRCS) $(SUNRPCSRCS) $(SYSCALLSRCS) $(SYSVIPCSRCS) $(TERMIOSSRCS) \
109113
$(TIMESRCS) $(TZSRCS) $(UNIXSRCS)
110114

111-
ifeq ($(libsize), _p)
112-
CFLAGS-_mon.S = -DPROFILING
113-
endif
114115
CFLAGS-crtinit.c = -fno-omit-frame-pointer --no-profile
115116
CFLAGS-gmon.c = -fno-omit-frame-pointer --no-profile
116117
CFLAGS-mcount.c = -fno-omit-frame-pointer --no-profile
@@ -187,29 +188,16 @@ vsscanf.o obstream.o printf.o vasprintf.o vdprintf.o vprintf.o vsnprintf.o \
187188
vsprintf.o sscanf.o fprintf.o fwprintf.o snprintf.o sprintf.o swprintf.o \
188189
vfwprintf.o vswprintf.o vwprintf.o wprintf.o
189190

190-
DEP_FILES := $(addprefix $(top_srcdir)/.deps/,$(patsubst %.o,%.P,$(OBJS)))
191+
DEP_FILES := $(addprefix .deps/,$(patsubst %.o,%.P,$(OBJS)))
191192

192193
# These are automatically remade, no need for make to worry about
193194
# them.
194195
.PHONY : $(DEP_FILES)
195196

196197
endif # not top_distdir.
197198

198-
all-here: $(top_srcdir)/CFILES $(top_srcdir)/includepath $(CRT0OBJS) $(LIBS)
199-
200-
$(top_srcdir)/includepath: $(top_srcdir)/configvars
201-
@echo "Generating $@"; \
202-
local= ; \
203-
installdir=`$(CC) --print-search-dirs | awk '{ print $$2; exit; }'`; \
204-
case $$installdir in /usr/local*) local=/local;; esac; \
205-
echo "$${installdir}include -I$${installdir}include-fixed" >$@
206-
@if [ -z "$$(<$@)" ]; then \
207-
rm $@; \
208-
echo "error: The syntax \$$(<file) is unsupported by $(SHELL)." >&2; \
209-
echo " Please use \"$(MAKE) SHELL=/bin/bash\" instead." >&2; \
210-
exit 1; \
211-
fi
212-
199+
all-here: $(top_srcdir)/CFILES $(CRT0OBJS) $(LIBS)
200+
213201
include $(top_srcdir)/bindist
214202

215203
install-include:
@@ -232,6 +220,7 @@ $(top_srcdir)/CFILES: $(argpdir)/SRCFILES $(cryptdir)/SRCFILES $(direntdir)/SRCF
232220
$(syscalldir)/SRCFILES $(sysvipcdir)/SRCFILES $(termiosdir)/SRCFILES \
233221
$(timedir)/SRCFILES $(tzdir)/SRCFILES $(unixdir)/SRCFILES
234222
rm -f $@
223+
ifneq (clean,$(MAKECMDGOALS))
235224
echo "# This file is a generated secondary file. Do not edit." >$@
236225
sed -e 's,^SRCFILES *=,ARGPCFILES =,g' $(argpdir)/SRCFILES >>$@
237226
sed -e 's,^SRCFILES *=,CRYPTCFILES =,g' $(cryptdir)/SRCFILES >>$@
@@ -260,6 +249,7 @@ $(top_srcdir)/CFILES: $(argpdir)/SRCFILES $(cryptdir)/SRCFILES $(direntdir)/SRCF
260249
sed -e 's,^SRCFILES *=,TIMECFILES =,g' $(timedir)/SRCFILES >>$@
261250
sed -e 's,^SRCFILES *=,TZCFILES =,g' $(tzdir)/SRCFILES >>$@
262251
sed -e 's,^SRCFILES *=,UNIXCFILES =,g' $(unixdir)/SRCFILES >>$@
252+
endif
263253

264254
vpath %.c $(srcdirs)
265255
vpath %.s $(srcdirs)
@@ -269,13 +259,13 @@ vpath %.S $(srcdirs)
269259
.SUFFIXES: .c .o .S .s
270260

271261
.c.o:
272-
$(AM_V_CC)$(COMPILE) -Wp,-MD,$(top_srcdir)/.deps/$(@:.o=.P) -c $< -o $@
262+
$(AM_V_CC)$(COMPILE) -Wp,-MD,.deps/$(@:.o=.P) -c $< -o $@
273263

274264
.S.o:
275-
$(AM_V_CC)$(COMPILE) -Wp,-MD,$(top_srcdir)/.deps/$(@:.o=.P) -c $< -o $@
265+
$(AM_V_CC)$(COMPILE) -Wp,-MD,.deps/$(@:.o=.P) -c $< -o $@
276266

277267
.s.o:
278-
$(AM_V_CC)$(COMPILE) -Wp,-MD,$(top_srcdir)/.deps/$(@:.o=.P) -c $< -o $@
268+
$(AM_V_CC)$(COMPILE) -Wp,-MD,.deps/$(@:.o=.P) -c $< -o $@
279269

280270
crt0.o: $(startupdir)/crt0.S
281271
$(AM_V_CC)$(CC) $(WARN) $(cflags) $(CFLAGS) -nostdinc -I$(top_srcdir)/include -I$(top_srcdir)/mintlib -c $< -o $@
@@ -287,16 +277,19 @@ gcrt0.o: $(startupdir)/crt0.S
287277
$(libc): $(LIBCOBJS)
288278
@rm -f $@
289279
$(AM_V_AR)$(AR) cru $@ $(LIBCOBJS)
280+
if test "$(qualifier)" = ""; then $(AM_V_STRIP)$(STRIP) -S -X -w -N '.L[0-9]*' $@; fi
290281
$(AM_V_RANLIB)$(RANLIB) $@
291282

292283
$(libiio): $(STDIIOOBJS) $(LIBIIO_ADDOBJS)
293284
@rm -f $@
294285
$(AM_V_AR)$(AR) cru $@ $(STDIIOOBJS) $(LIBIIO_ADDOBJS)
286+
if test "$(qualifier)" = ""; then $(AM_V_STRIP)$(STRIP) -S -X -w -N '.L[0-9]*' $@; fi
295287
$(AM_V_RANLIB)$(RANLIB) $@
296288

297289
$(librpcsvc): $(RPCSVCOBJS)
298290
@rm -f $@
299291
$(AM_V_AR)$(AR) cru $@ $(RPCSVCOBJS)
292+
if test "$(qualifier)" = ""; then $(AM_V_STRIP)$(STRIP) -S -X -w -N '.L[0-9]*' $@; fi
300293
$(AM_V_RANLIB)$(RANLIB) $@
301294

302295
$(LIBCOBJS) $(LIBIIO_ADDOBJS) $(RPCSVCOBJS): $(top_srcdir)/includepath
@@ -305,8 +298,6 @@ $(top_srcdir)/include/linker.h: $(top_srcdir)/include/linker.h.in \
305298
$(top_srcdir)/configvars
306299
(cd $(top_srcdir)/include && $(MAKE) linker.h)
307300

308-
DEPS_MAGIC := $(shell mkdir $(top_srcdir)/.deps > /dev/null 2>&1 || :)
309-
310301
.SECONDARY : $(DEP_FILES) $(SRCFILES)
311302

312303
-include $(DEP_FILES) /dev/null

checkrules

+12-13
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ include $(top_srcdir)/configvars
66

77
# The variable "type" will be appended to "lib" when searching for
88
# libraries. Thus, to test the library with fpu code and >=m68020,
9-
# set type to 16020. If you change this you must run "make checkclean".
10-
type=
9+
# set type to m68020. If you change this you must run "make checkclean".
10+
type=m68000
1111

1212
# These are additional CFLAGS passed to the compiler and the linker.
1313
# For fpu/m68020 libs:
1414
# cflags=-m68020-60
1515
# If you change this you must run "make checkclean".
16-
cflags=
16+
cflags=$(CFLAGS_$(type))
1717

18-
CRT0 = $(top_srcdir)/lib$(type)/crt0.o
19-
libs = $(libs-$(@F)) $(top_srcdir)/lib$(type)/libc.a
18+
CRT0 = $(top_srcdir)/build/$(type)/crt0.o
19+
libs = $(libs-$(@F)) $(top_srcdir)/build/$(type)/libc.a
2020
LIBS = -lgcc $(LIBS-$(@F)) $(libs) -lgcc
2121

2222
TESTPRGS = $(addprefix test-, $(TESTS))
23-
TESTCFILES = $(addsuffix .c, $(TESTPRGS) $(EXTRAPRGS))
23+
TESTCFILES = $(addsuffix .c,$(TESTPRGS) $(EXTRAPRGS))
2424
TESTOBJS = $(TESTCFILES:.c=.o)
25-
DEP_FILES = $(addprefix $(srcdir)/.deps/, $(patsubst %.c,%.P,$(TESTCFILES)))
25+
DEP_FILES = $(addprefix $(top_srcdir)/build/$(type)/$(subdir)/.deps/,$(patsubst %.c,%.P,$(TESTCFILES)))
2626

27-
TESTCFLAGS = $(cflags) $(EXTRACFLAGS)
27+
TESTCFLAGS = $(cflags) $(CFLAGS) $(EXTRACFLAGS)
2828
TESTLDFLAGS = $(cflags) -s -nostartfiles -nostdlib
2929
TESTDEFS = -D_GNU_SOURCE -D_REENTRANT
3030

@@ -37,8 +37,8 @@ check: check-local $(libs) $(TESTPRGS)
3737
$(top_srcdir)/do_test $(TESTS)
3838

3939
checkclean:
40-
rm -f $(srcdir)/*.o $(TESTPRGS)
41-
rm -rf $(srcdir)/.deps
40+
rm -f $(top_srcdir)/build/$(type)/$(subdir)/*.o $(TESTPRGS)
41+
rm -rf $(top_srcdir)/build/$(type)/$(subdir)/.deps
4242

4343
$(TESTPRGS) $(EXTRAPRGS): %: %.o $(libs) $(CRT0)
4444
$(CC) $(LDFLAGS) $(TESTLDFLAGS) $(CRT0) $< -o $@ $(LIBS)
@@ -48,9 +48,8 @@ $(TESTPRGS) $(EXTRAPRGS): %: %.o $(libs) $(CRT0)
4848

4949
.c.o:
5050
@echo '$(COMPILE) -c $< -o $@'; \
51-
$(COMPILE) -Wp,-MD,.deps/$(@:.o=.P) -c $< -o $@
51+
$(COMPILE) -Wp,-MD,$(top_srcdir)/build/$(type)/$(subdir)/.deps/$(@:.o=.P) -c $< -o $@
5252

53-
DEPS_MAGIC := $(shell mkdir $(srcdir)/.deps > /dev/null 2>&1 || :)
53+
DEPS_MAGIC := $(shell mkdir -p $(top_srcdir)/build/$(type)/$(subdir)/.deps > /dev/null 2>&1 || :)
5454

5555
-include $(DEP_FILES) /dev/null
56-

0 commit comments

Comments
 (0)