133 lines
3.5 KiB
Makefile
133 lines
3.5 KiB
Makefile
#### Start of system configuration section. ####
|
|
|
|
srcdir = @srcdir@
|
|
VPATH = @srcdir@
|
|
|
|
CC = @CC@
|
|
CPP = @CPP@
|
|
AS = @AS@
|
|
|
|
AR = @AR@
|
|
RANLIB = @RANLIB@
|
|
AWK = @AWK@
|
|
|
|
FD2INLINE = fd2inline
|
|
FDPATH = $(prefix)/os-lib/fd/
|
|
CLIBPATH = $(prefix)/os-include/clib/
|
|
|
|
#### End system configuration section ####
|
|
|
|
include ../../sources/amiga/filelist
|
|
|
|
CURDIR = $(shell pwd)
|
|
|
|
OPTIONS=-I$(srcdir)/../headers $(CFLAGS)
|
|
|
|
FDFILES = $(wildcard $(FDPATH)*.fd)
|
|
CLIB = $(addprefix $(CLIBPATH),$(subst _lib.fd,_protos.h,$(notdir $(fd))))
|
|
STUB = $(subst _lib.fd,,$(notdir $(fd)))
|
|
|
|
%.o: %.c
|
|
$(CC) $(OPTIONS) -c $^ -o $@ 2>&1|tee $*.err
|
|
-if test ! -s $*.err; then rm $*.err; fi
|
|
|
|
%.o: %.S
|
|
$(CC) $(OPTIONS) -c $^ -o $@ 2>&1|tee $*.err
|
|
-if test ! -s $*.err; then rm $*.err; fi
|
|
|
|
.PHONY: all clean veryclean splitinline
|
|
|
|
all: libamiga.a
|
|
|
|
clean:
|
|
-rm -rf $(SUBDIRS)
|
|
|
|
veryclean:
|
|
-rm -rf *
|
|
|
|
$(foreach f,$(SUBDIRS),$(CURDIR)/$(f)):
|
|
mkdir $@
|
|
|
|
#libamiga.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) libglue.a ../../sources/amiga/Makefile ../../sources/amiga/filelist
|
|
libamiga.a: $(foreach f,$(SUBDIRS),$(CURDIR)/$(f)) $(OBJECTS) newlibglue.a ../../sources/amiga/Makefile ../../sources/amiga/filelist
|
|
-rm -f libamiga.a
|
|
# -cp libglue.a libamiga.a
|
|
-cp newlibglue.a libamiga.a
|
|
$(AR) -q libamiga.a $(OBJECTS)
|
|
$(RANLIB) libamiga.a
|
|
|
|
libglue.a:
|
|
if [ -d tmp ] ; then rm -rf tmp ; else true ; fi
|
|
-mkdir tmp
|
|
# Build assembler stubs out of inline headers:
|
|
# * First transform all vararg #defines into real functions
|
|
# * Compile all functions with 'extern' and '__inline' disabled
|
|
# * Split resulting assembler output at function entries
|
|
# * This needs old-style inlines!
|
|
-cd tmp; \
|
|
echo "" >dummy.c; \
|
|
for file in /gg/include/inline/*.h; do \
|
|
( $(AWK) 'nf==1 { fn=$$1;nf=0 } \
|
|
/inline/ { vs="long";rs="return ";nf=1 } \
|
|
/void/ { vs="void";rs="";nf=1 } \
|
|
/\.\.\./ \
|
|
{ st=substr($$0,1,index($$0,"tags...")-1); \
|
|
st=substr(st,index(st," ")); \
|
|
st2=st;gsub(/\(/,"(long ",st2);gsub(/,/,",long ",st2); \
|
|
print "#undef" substr(st,1,index(st,"(")-1) "\n" vs st2 "tags,...)"; \
|
|
print "{ " rs fn substr(st,index(st,"(")) "&tags); }\n" \
|
|
}' $$file >vararg.c; \
|
|
( $(CC) $(CFLAGS) -w -include $$file vararg.c -S -o -; \
|
|
$(CC) -Dextern= -D__inline= -D_STRSUP_H -include $$file $(CFLAGS) dummy.c -S -o - ) | \
|
|
$(AWK) '/.even/ { next } /.comm/ { next } \
|
|
/.globl/ { if(file!="") close(file); file=$$2 ".s"; \
|
|
print "\t.even\n" $$0 >file; next; } \
|
|
{ if(file!="") print $$0 >file; }' ); done
|
|
-cd tmp;rm vararg.c dummy.c;$(CC) -c *.s
|
|
-rm libglue.a
|
|
-cd tmp;$(AR) -q ../libglue.a *.o
|
|
-rm -rf tmp
|
|
|
|
newlibglue.a: stublibs
|
|
if [ ! -f stamp-libglue ];\
|
|
then\
|
|
pwd;\
|
|
rm -f $@;\
|
|
$(foreach fd, $(FDFILES),\
|
|
echo "adding $(STUB) stubs to $@ ...";\
|
|
$(AR) -q $@ stubs/$(STUB)/*.o;)\
|
|
touch stamp-libglue;\
|
|
else\
|
|
true;\
|
|
fi;
|
|
|
|
stublibs: stubsrcs
|
|
cd stubs;\
|
|
$(foreach fd, $(FDFILES),\
|
|
if [ ! -f stamp-$(STUB)-stubs ];\
|
|
then\
|
|
echo "building $(STUB) stubs...";\
|
|
cd $(STUB);\
|
|
$(CC) $(OPTIONS) -c *.c;\
|
|
cd ..;\
|
|
touch stamp-$(STUB)-stubs;\
|
|
else\
|
|
true;\
|
|
fi;\
|
|
)
|
|
|
|
stubsrcs:
|
|
if [ ! -d stubs ] ; then mkdir stubs ; else true ; fi
|
|
cd stubs;\
|
|
$(foreach fd, $(FDFILES),\
|
|
if [ ! -f stamp-$(STUB)-srcs ];\
|
|
then\
|
|
echo "creating $(STUB) stubs sources...";\
|
|
rm -rf $(STUB);\
|
|
$(FD2INLINE) --splitstubs $(fd) $(CLIB) -o $(STUB);\
|
|
touch stamp-$(STUB)-srcs;\
|
|
else\
|
|
true;\
|
|
fi;\
|
|
)
|