📄 makefile
字号:
# -lposix4 = Solaris 2.5 and 2.6 library for sched_yield.
# -lresolv = Resolver functions.
# -lrt = Solaris 2.7 and above realtime library for sched_yield().
# -lthread = pthreads support. Note that this generally has to be linked
# as late as possible (and in particular after the implied -lc)
# because libpthread overrides non-thread-safe and stub functions
# in libraries linked earlier on with thread-safe alternatives.
# -lw = Widechar support.
#
# The OS-specific linking is handled through multiple levels of indirection.
# At the top level we specify the target and library to link with (static or
# shared). We pass this down to test_link, which sorts out the OS-specific
# linker options, and then finally passes the whole lot down to link, which
# performs the actual link.
#
# After the shared stuff is built, you can test it with:
#
# /sbin/ldconfig . >& /dev/null
# LD_LIBRARY_PATH=.
# ldd ./testlib
#
# BeOS uses LIBRARY_PATH instead, and needs to have it pointed to . to find
# the shared lib, otherwise it fails with a "Missing library" error without
# indicating which library is missing.
LDFLAGS_AIX = -lc_r -lpthreads
LDFLAGS_BEOS =
LDFLAGS_BEOS_BONE = -lbind -lsocket
LDFLAGS_BSDI = -lgcc
LDFLAGS_CYGWIN =
LDFLAGS_FREEBSD = -lc_r
LDFLAGS_HPUX10 =
LDFLAGS_HPUX11 = -lpthread
LDFLAGS_IRIX = -lw
LDFLAGS_LINUX = -lpthread -lresolv
LDFLAGS_MPRAS = -K xpg42 -lnsl -lsocket -lc89
LDFLAGS_SCO = -lsocket -Kthread
LDFLAGS_SUNOS = -ldl -lnsl -lposix4
LDFLAGS_SOLARIS5 = -lw -lsocket -lkstat -lthread -lnsl -lposix4
LDFLAGS_SOLARIS7 = -lw -lsocket -lkstat -lthread -lrt -lnsl
link: $(TESTOBJS)
@$(LD) -o $(OUT) $(LDFLAGS) $(TESTOBJS) -L. $(LIB) $(OS_LDFLAGS) $(TESTLIBS)
test_link: $(TESTOBJS)
@case $(OSNAME) in \
'AIX') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_AIX)" ;; \
'BeOS') \
if [ -f /system/lib/libbind.so ] ; then \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_BEOS_BONE)" ; \
else \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_BEOS)" ; \
fi ;; \
'BSD/OS') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_BSDI)" ;; \
'CYGWIN_NT-5.0') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_CYGWIN)" ;; \
'FreeBSD') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_FREEBSD)" ;; \
'HP-UX') \
case `uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'` in \
10) \
if gcc -v > /dev/null 2>&1; then \
make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_HPUX10)" ; \
else \
make link LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_HPUX10)" ; \
fi ;; \
11) \
if gcc -v > /dev/null 2>&1; then \
make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_HPUX11)" ; \
else \
make link LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_HPUX11)" ; \
fi ;; \
esac ;; \
'IRIX'|'IRIX64') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_IRIX)" ;; \
'Linux'|'OSF1') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_LINUX)" ;; \
'SunOS') \
case `uname -r | cut -f 1 -d '.'` in \
4) \
make link LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_SUNOS)" ;; \
5) \
if [ `which $(LD) | grep -c ucb/cc` = '1' ] && \
[ `which ucbcc | grep -c ucbcc` = '0' ] ; then \
make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_SOLARIS5)" ; \
else \
make link LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_SOLARIS5)" ; \
fi ;; \
6|7|8|9) \
if [ `which $(LD) | grep -c ucb/cc` = '1' ] && \
[ `which ucbcc | grep -c ucbcc` = '0' ] ; then \
make link LD=gcc LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_SOLARIS7)" ; \
else \
make link LIB=$(LIB) OUT=$(OUT) \
OS_LDFLAGS="$(LDFLAGS_SOLARIS7)" ; \
fi ;; \
esac ;; \
'UNIX_SV') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_MPRAS)" ;; \
'UnixWare') \
make link LIB=$(LIB) OUT=$(OUT) OS_LDFLAGS="$(LDFLAGS_SCO)" ;; \
*) \
make link LIB=$(LIB) OUT=$(OUT) ;; \
esac
testlib: $(TESTOBJS)
@make test_link OUT=testlib LIB=-l$(PROJ)
stestlib: $(TESTOBJS)
@make test_link OUT=stestlib LIB=$(SLIBNAME)
certinst: $(LIBNAME) certinst.o
@make test_link OUT=certinst LIB=-l$(PROJ)
#****************************************************************************
#* *
#* Defines for each variation of Unix *
#* *
#****************************************************************************
# Aches: A vaguely Unix-compatible OS designed by IBM. The maxmem option
# is to give the optimizer more headroom, it's not really needed
# but avoids millions of informational messages telling you to
# increase it from the default 2048. The roconst puts const data
# into read-only memory (this may happen anyway on some versions of
# the compiler).
AIX:
@if [ -f /usr/include/stdint.h ] ; then \
make $(DEFINES) CFLAGS="$(CFLAGS) -O2 -qmaxmem=-1 -qroconst -DHAS_STDINT_H -D_REENTRANT" ; \
else \
make $(DEFINES) CFLAGS="$(CFLAGS) -O2 -qmaxmem=-1 -qroconst -D_REENTRANT" ; \
fi
# Apollo: Yeah, this makefile has been around for awhile. Why do you ask?
Apollo:
@make $(DEFINES) CFLAGS="$(CFLAGS) -O4"
# AUX: su root; rm -rf /; echo "Now install MkLinux"
A/UX:
@make $(DEFINES) CFLAGS="$(CFLAGS) -O4"
# Millions of Intel BSD's (many are really BSE's, with incredibly archaic
# development tools and libs, although it's slowly getting better):
# cc is gcc except when it isn't. Most are still using a.out,
# although some are slowly going to ELF, which we can autodetect by
# checking whether the compiler defines __ELF__. If the compiler
# check doesn't work then [ `uname -r | cut -f 1` -ge 4 ] (for
# FreeBSD) and -ge 2 (for OpenBSD) should usually work.
#
# NetBSD for many years (up until around 1999-2000) used an
# incredibly old version of as that didn't handle 486 opcodes (!!),
# so the asm code was disabled by default. In addition it used an
# equally archaic version of gcc, requiring manual fiddling with
# the compiler type and options.
BSD386:
@make asm_out OBJPATH=$(OBJPATH)
@make $(DEFINES) EXTRAOBJS="$(ASMOBJS)" CFLAGS="$(CFLAGS) -DUSE_ASM \
-fomit-frame-pointer -O3 -mcpu=pentium"
iBSD:
@make asm_out OBJPATH=$(OBJPATH)
@make $(DEFINES) EXTRAOBJS="$(ASMOBJS)" CFLAGS="$(CFLAGS) -DUSE_ASM \
-fomit-frame-pointer -O3 -mcpu=pentium"
BSD/OS:
@if test "`echo __ELF__ | $(CC) -E - | grep __ELF__`" = "" ; then \
make asm_elf OBJPATH=$(OBJPATH) ; \
else \
make asm_out OBJPATH=$(OBJPATH) ; \
fi
@make $(DEFINES) CC=gcc EXTRAOBJS="$(ASMOBJS)" CFLAGS="$(CFLAGS) -DUSE_ASM \
-fomit-frame-pointer -O3 -mcpu=pentium"
FreeBSD:
@if test "`echo __ELF__ | $(CC) -E - | grep __ELF__`" = "" ; then \
make asm_elf OBJPATH=$(OBJPATH) ; \
else \
make asm_out OBJPATH=$(OBJPATH) ; \
fi
@make $(DEFINES) EXTRAOBJS="$(ASMOBJS)" CFLAGS="$(CFLAGS) -DUSE_ASM \
-fomit-frame-pointer -O3 -mcpu=pentium"
OpenBSD:
@if test "`echo __ELF__ | $(CC) -E - | grep __ELF__`" = "" ; then \
make asm_elf OBJPATH=$(OBJPATH) ; \
else \
make asm_out OBJPATH=$(OBJPATH) ; \
fi
@make $(DEFINES) EXTRAOBJS="$(ASMOBJS)" CFLAGS="$(CFLAGS) -DUSE_ASM \
-fomit-frame-pointer -O3 -mcpu=pentium"
# Convex:
Convex:
@make $(DEFINES) CFLAGS="$(CFLAGS) -O4"
# Cygwin32: cc is gcc
CYGWIN_NT-5.0:
@make CC=gcc $(DEFINES) CFLAGS="$(CFLAGS) -O3 -mcpu=pentium -D__CYGWIN__ -I/usr/local/include"
# DGUX: cc is a modified gcc.
dgux:
@make $(DEFINES) CFLAGS="$(CFLAGS) -ansi -fomit-frame-pointer -O3"
# PHUX: A SYSVR2 layer with a SYSVR3 glaze on top of an adapted BSD 4.2
# kernel. Use cc, the exact incantation varies somewhat depending on
# which version of PHUX you're running. For 9.x you need to use
# '-Aa -D_HPUX_SOURCE' to get the compiler into ANSI mode, in 10.x this
# changed to just '-Ae', and after 10.30 -Ae was the default mode.
# With PA-RISC 2 you should probably also define +DD64 to compile in
# 64-bit mode under PHUX 11.x, under even newer versions this becomes
# +DA2.0w (note that building 64-bit versions of anything will probably
# cause various build problems arising from the compiler and linker
# because although the CPU may be 64 bit the software development tools
# really, really want to give you 32-bit versions of everything and it
# takes quite some cajoling to actually get them to spit out a 64-bit
# result). In addition the PHUX compilers don't recognise -On like the
# rest of the universe but use +On instead so if you're using gcc
# instead of cc/c89 you'll need to change things to use the standard gcc
# options. Finally, we only build the asm code under 11 since it
# doesn't like 10.x and earlier systems.
#
# Newer compilers can use +Oall to apply all optimisations (even the
# dodgy ones). Typically going from +O2 -> +O3 -> +O4 gives a ~10-15%
# improvement at each step. Finally, when making the shared lib you
# can only use +O2, not +O3, because it gives the compiler the speed
# wobbles. In theory we could also use +ESlit to force const data
# into a read-only segment, but this is defeated by a compiler bug
# that doesn't initialise non-explicitly-initialised struct elements
# to zero any more when this option is enabled (this is a double-bug
# that violates two C rules because if there are insufficient
# initialisers the remaining elements should be set to zero, and for
# static objects they should be set to zero even if there are no
# initialisers).
#
# Note that the PHUX compilers (especially the earlier ones) are
# horribly broken and will produce all sorts of of bogus warnings of
# non-problems, eg:
#
# /usr/ccs/bin/ld: (Warning) Quadrant change in relocatable
# expression in subspace $CODE$
#
# (translation: Klingons off the starboard bow!). The code contains
# workarounds for non-errors (for example applying a cast to anything
# magically turns it into an rvalue), but it's not worth fixing the
# warnings for an OS as broken as this.
#
# This PHUX compiler bugs comment is really starting to give the SCO
# one a run for its money.
HP-UX:
@if [ `uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'` -eq 11 ] ; then \
make asm_phux OBJPATH=$(OBJPATH) || exit 1 ; \
make $(DEFINES) CFLAGS="$(CFLAGS) +O3 -D_REENTRANT" ; \
elif [ `uname -r | sed 's/^[A-Z].//' | cut -f 1 -d '.'` -eq 10 ] ; then \
if [ $(CC) = "gcc" ] ; then \
make $(DEFINES) CFLAGS="$(CFLAGS) -O3" ; \
else \
make $(DEFINES) CFLAGS="$(CFLAGS) -Ae +O3" ; \
fi ; \
else \
make $(DEFINES) CFLAGS="$(CFLAGS) -Aa -D_HPUX_SOURCE +O3" ; \
fi
# Irix: Use cc
IRIX:
@make asm_mips OBJPATH=$(OBJPATH)
@make $(DEFINES) CFLAGS="$(CFLAGS) -O3"
IRIX64:
@make asm_mips OBJPATH=$(OBJPATH)
@make $(DEFINES) CFLAGS="$(CFLAGS) -O3"
# ISC Unix: Use gcc
ISC:
@make asm_out OBJPATH=$(OBJPATH)
@make $(DEFINES) CC=gcc CFLAGS="$(CFLAGS) -fomit-frame-pointer -O3 -mcpu=pentium"
# Linux: cc is gcc. The 1e-5 users with rather old versions of x86 Linux
# will need to make the asm targets with ASMFLAGS=OUT to build the
# a.out version of the asm core routines.
Linux:
@if uname -m | grep "i[3,4,5,6]86" > /dev/null; then \
make asm_elf OBJPATH=$(OBJPATH) ; \
make $(DEFINES) EXTRAOBJS="$(ASMOBJS)" CFLAGS="$(CFLAGS) -DUSE_ASM \
-fomit-frame-pointer -O3 -mcpu=pentium -D_REENTRANT"; \
else \
make $(DEFINES) CFLAGS="$(CFLAGS) -fomit-frame-pointer -O3 -D_REENTRANT"; \
fi
# Mac OS X: BSD variant.
Darwin:
@make $(DEFINES) CFLAGS="$(CFLAGS) -fomit-frame-pointer -O3" \
LDFLAGS="-object -s"
# NCR MP-RAS 3.02: Using the NCR High Performance C Compiler R3.0c
# The options below don't use threads. To use threads,
# remove the cryptlib define
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -