1: #
2: # ----------------------------------------------------------------------
3: # T-Kernel 2.0 Software Package
4: #
5: # Copyright 2011 by Ken Sakamura.
6: # This software is distributed under the latest version of T-License 2.x.
7: # ----------------------------------------------------------------------
8: #
9: # Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
10: # Modified by T-Engine Forum at 2014/07/14.
11: # Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
12: #
13: # ----------------------------------------------------------------------
14: #
15:
16: #
17: # makerules
18: # for GNU make
19: #
20: # common standard rules (default rules)
21: #
22: # environment variables:
23: #
24: # mode compile mode
25: # (empty) : release version
26: # debug : debug version
27: #
28: # BD development environment base directory
29: #
30: # GNUs cross development environment tool
31: # GNU_BD GNU cross development environment tool base directory
32: #
33: # this makerules needs:
34: # * /usr/bin/make GNU make version 3.78.1
35: # * /usr/bin/perl perl version 5.005_03
36: #
37:
38: .EXPORT_ALL_VARIABLES:
39:
40: # ===== default settings ======================================================
41:
42: ### get "options" from current directory name (xxx.yyy.zzz) ###
43: _tmp_ := $(notdir $(shell pwd))
44: options := $(strip $(subst ., ,$(_tmp_)) $(options))
45:
46: ### environments ###
47: ifndef BD
48: # default base directory
49: BD := /usr/local/te
50: endif
51:
52: ifndef MACHINE
53: # target machine
54: MACHINE := $(firstword $(options))
55: endif
56:
57: ifndef TETYPE
58: # target T-Engine type
59: TETYPE := std
60: endif
61:
62: ifeq ($(origin mode), undefined)
63: # compile mode
64: mode := $(filter debug, $(options))
65: endif
66:
67: # ===== directories ===========================================================
68: #
69: # COMMONLIB common library
70: # LIB_INSTALLDIR library install directory
71: # DRIVER_INSTALLDIR driver install directory
72: # EXE_INSTALLDIR executable install directory
73:
74: SUFFIX_LIB =
75: SUFFIX_INST =
76:
77: COMMONLIB = $(BD)/lib/build/$(TETYPE)_$(MACHINE)$(SUFFIX_LIB)
78: LIB_INSTALLDIR = $(COMMONLIB)
79: DRIVER_INSTALLDIR = $(BD)/driver/$(TETYPE)_$(MACHINE)/build
80: EXE_INSTALLDIR = $(BD)/bin/$(TETYPE)_$(MACHINE)$(SUFFIX_INST)
81:
82: # ===== common definition =====================================================
83:
84: # CROSS_ARCH
85: # SunOS-sparc Solaris Ultra
86: # SunOS-i386 Solaris x86
87: # Linux-i686 Linux x86
88: # FreeBSD-i386 FreeBSD x86
89: # Cygwin-i686 Cygwin x86
90: # unknown unknown platform
91: # CCS
92: # ccs/ : exist /usr/ccs
93: # (empty) : no exist /usr/ccs
94: #
95: CROSS_ARCH := $(shell $(BD)/etc/platform)
96: CCS := $(shell test -d /usr/ccs && echo ccs/)
97: TOOL_ORIGIN = "environment" "command line"
98:
99: ### others ###
100: ETCBIN := $(GNU_BD)/etc
101: RM = rm -f
102: CP = cp
103: PERL = perl
104: MKBTF = $(ETCBIN)/mkbtf
105:
106: ifneq ($(shell test -x $(GNU_BD)/bin/cpp && echo exist), )
107: CPP = $(GNU_BD)/bin/cpp
108: else
109: CPP =
110: endif
111:
112: ### header file ###
113: HEADER = $(BD)/include
114: DATABOX_HEADER = $(BD)/bappl/dbox
115:
116: ### install common library ###
117: $(LIB_INSTALLDIR)/%.so.$(LIB_VERSION): %.so.$(LIB_VERSION)
118: $(BD)/etc/backup_copy -t -d !OLD $< $(LIB_INSTALLDIR)
119:
120: $(LIB_INSTALLDIR)/%.map: %.map
121: $(BD)/etc/backup_copy -t -d !OLD $< $(LIB_INSTALLDIR)
122:
123: $(EXE_INSTALLDIR)/%.so.$(LIB_VERSION): %.so.$(LIB_VERSION)
124: $(EXE_INSTALL_STRIP)
125:
126: ### install driver ###
127: $(DRIVER_INSTALLDIR)/%: %
128: $(BD)/etc/backup_copy -t -d !OLD $< $(DRIVER_INSTALLDIR)
129:
130: ### install executable ###
131: $(EXE_INSTALLDIR)/%: %
132: $(BD)/etc/backup_copy -t -d !OLD $< $(EXE_INSTALLDIR)
133:
134: define EXE_INSTALL_STRIP
135: $(BD)/etc/backup_copy -t -d !OLD $< $(EXE_INSTALLDIR)
136: $(STRIP) $@
137: endef
138:
139: ### build option ###
140: CFLAGS =
141: CPPFLAGS =
142: ASFLAGS =
143: LDFLAGS =
144:
145: # ===== system-dependent ======================================================
146:
147: include $(BD)/etc/sysdepend/$(TETYPE)_$(MACHINE)/makerules.sysdepend
148:
149: # ===== common definition =====================================================
150:
151: ### install library ###
152: $(LIB_INSTALLDIR)/%.a: %.a
153: $(BD)/etc/backup_copy -t -d !OLD $< $(LIB_INSTALLDIR)
154: ifdef RANLIB
155: $(RANLIB) $@
156: endif
157:
158: $(LIB_INSTALLDIR)/%: %
159: $(BD)/etc/backup_copy -t -d !OLD $< $(LIB_INSTALLDIR)
160:
161: # =============================================================================