diff options
| author | ruki <[email protected]> | 2020-05-08 00:33:03 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-05-07 21:18:23 +0800 |
| commit | 223124202f2a7f619f9e55afa7b1571c64f7de54 (patch) | |
| tree | 3b4946ead8331f5a0934190043fbafd5db8b26f1 | |
| parent | 0c0867e019801e38504b34efa607b6de11677b5c (diff) | |
add bsd platform for makefile
| -rw-r--r-- | core/makefile | 14 | ||||
| -rw-r--r-- | core/plat/bsd/config.h | 22 | ||||
| -rw-r--r-- | core/plat/bsd/config.mak | 1 | ||||
| -rw-r--r-- | core/plat/bsd/prefix.mak | 129 | ||||
| -rw-r--r-- | makefile | 1 |
5 files changed, 159 insertions, 8 deletions
diff --git a/core/makefile b/core/makefile index 657ecaa14..d5acc252d 100644 --- a/core/makefile +++ b/core/makefile @@ -145,15 +145,9 @@ HOST :=$(if $(HOST),$(HOST),$(if ${shell uname | egrep -i cygwin},cygwin,)) HOST :=$(if $(HOST),$(HOST),$(if ${shell uname | egrep -i msys},msys,)) HOST :=$(if $(HOST),$(HOST),$(if ${shell uname | egrep -i mingw},msys,)) HOST :=$(if $(HOST),$(HOST),$(if ${shell uname | egrep -i windows},msys,)) -HOST :=$(if $(HOST),$(HOST),$(if ${shell uname | egrep -i freebsd},freebsd,)) +HOST :=$(if $(HOST),$(HOST),$(if ${shell uname | egrep -i bsd},bsd,)) HOST :=$(if $(HOST),$(HOST),linux) -# is *bsd host? -isbsd = -ifeq ($(HOST),freebsd) - isbsd = yes -endif - # platform PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i linux},linux,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i darwin},macosx,)) @@ -161,6 +155,7 @@ PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i cygwin},cygwin,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i msys},msys,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i mingw},msys,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i windows},windows,)) +PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i bsd},bsd,)) PLAT :=$(if $(PLAT),$(PLAT),linux) # architecture @@ -252,7 +247,7 @@ ifeq ($(HOST),macosx) SED := perl -pi -e SEDX := perl -p -e else -ifdef isbsd +ifeq ($(HOST),bsd) SED := perl -pi -e SEDX := perl -p -e else @@ -268,6 +263,9 @@ endif ifeq ($(HOST),linux) SHELL = bash endif +ifeq ($(HOST),bsd) +SHELL = bash +endif ECHO := echo -e # make upper diff --git a/core/plat/bsd/config.h b/core/plat/bsd/config.h new file mode 100644 index 000000000..e55edbc80 --- /dev/null +++ b/core/plat/bsd/config.h @@ -0,0 +1,22 @@ +#ifndef XM_CONFIG_H +#define XM_CONFIG_H + +// packages +// [packages] + +// major version +#define XM_CONFIG_VERSION_MAJOR [major] + +// minor version +#define XM_CONFIG_VERSION_MINOR [minor] + +// alter version +#define XM_CONFIG_VERSION_ALTER [alter] + +// build version +#define XM_CONFIG_VERSION_BUILD [build] + +// small +#define XM_CONFIG_SMALL [small] + +#endif diff --git a/core/plat/bsd/config.mak b/core/plat/bsd/config.mak new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/core/plat/bsd/config.mak @@ -0,0 +1 @@ + diff --git a/core/plat/bsd/prefix.mak b/core/plat/bsd/prefix.mak new file mode 100644 index 000000000..ff0c15e62 --- /dev/null +++ b/core/plat/bsd/prefix.mak @@ -0,0 +1,129 @@ +# architecture makefile configure + +# prefix & suffix +BIN_PREFIX = +BIN_SUFFIX = .b + +OBJ_PREFIX = +OBJ_SUFFIX = .o + +LIB_PREFIX = lib +LIB_SUFFIX = .a + +DLL_PREFIX = lib +DLL_SUFFIX = .so + +ASM_SUFFIX = .S + +# prefix +PRE_ := $(if $(BIN),$(BIN)/$(PRE),) + +# tool +CC := $(if $(CC),$(CC),$(PRE_)gcc) +LD := $(if $(CC),$(CC),$(PRE_)gcc) # we do not use ld directly +AR := $(if $(AR),$(AR),$(PRE_)ar) +STRIP := $(if $(STRIP),$(STRIP),$(PRE_)strip) +RANLIB := $(if $(RANLIB),$(RANLIB),$(PRE_)ranlib) +AS := $(CC) +RM = rm -f +RMDIR = rm -rf +CP = cp +CPDIR = cp -r +MKDIR = mkdir -p +MAKE = gmake -r + +# architecture flags +AHFLAGS := $(if $(AHFLAGS),$(AHFLAGS),$(if $(findstring x86_64,$(ARCH)),-m64,)) +AHFLAGS := $(if $(AHFLAGS),$(AHFLAGS),$(if $(findstring i386,$(ARCH)),-m32,)) + +# check flags for x64 or x86 +ifneq ($(AHFLAGS),) +ifeq ($(CXFLAGS_CHECK),) +CC_CHECK = ${shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } +CXFLAGS_CHECK := +export CXFLAGS_CHECK +endif + +ifeq ($(LDFLAGS_CHECK),) +LD_CHECK = ${shell if $(LD) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi } +LDFLAGS_CHECK := $(call LD_CHECK,-no-pie,) +export LDFLAGS_CHECK +endif +endif + +# cxflags: .c/.cc/.cpp files +CXFLAGS_RELEASE = +CXFLAGS_DEBUG = -g -D__tb_debug__ +CXFLAGS = $(AHFLAGS) $(CXFLAGS_CHECK) -c -Wall +CXFLAGS-I = -I +CXFLAGS-o = -o + +# suppress warning for ccache + clang bug +CXFLAGS += $(if $(findstring clang,$(CC)),-Qunused-arguments,) + +# optimization +ifeq ($(SMALL),y) +CXFLAGS_RELEASE += -Os +else +CXFLAGS_RELEASE += -O3 +endif + +# profile +ifeq ($(PROF),y) +CXFLAGS += -g -pg -fno-omit-frame-pointer +else +CXFLAGS_RELEASE += -fomit-frame-pointer +CXFLAGS_DEBUG += -fno-omit-frame-pointer +endif + +# cflags: .c files +CFLAGS_RELEASE = +CFLAGS_DEBUG = +CFLAGS := $(CFLAGS) \ + -std=gnu99 \ + -D_GNU_SOURCE=1 -D_REENTRANT \ + -fno-math-errno + +# ccflags: .cc/.cpp files +CCFLAGS_RELEASE = -fno-rtti +CCFLAGS_DEBUG = +CCFLAGS := $(CXXFLAGS) -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 + +# ldflags +LDFLAGS_RELEASE = +LDFLAGS_DEBUG = -rdynamic +LDFLAGS := $(LDFLAGS) $(AHFLAGS) $(LDFLAGS_CHECK) +LDFLAGS-L = -L +LDFLAGS-l = -l +LDFLAGS-f = +LDFLAGS-o = -o + +# prof +ifeq ($(PROF),y) +LDFLAGS += -pg +else +LDFLAGS_RELEASE += -s +LDFLAGS_DEBUG += +endif + +# asflags +ASFLAGS_RELEASE = +ASFLAGS_DEBUG = +ASFLAGS = -c $(AHFLAGS) +ASFLAGS-I = -I +ASFLAGS-o = -o + +# arflags +ARFLAGS_RELEASE = +ARFLAGS_DEBUG = +ARFLAGS = -cr +ARFLAGS-o = + +# shflags +SHFLAGS_RELEASE = -s +SHFLAGS = $(AHFLAGS) -shared -Wl,-soname + +# include sub-config +include $(PLAT_DIR)/config.mak + + @@ -29,6 +29,7 @@ PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i cygwin},cygwin,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i msys},msys,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i mingw},msys,)) PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i windows},windows,)) +PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i bsd},bsd,)) PLAT :=$(if $(PLAT),$(PLAT),linux) # architecture |
