1## BeOS Generic Makefile ## 2 3## Fill in the top section of this makefile to define exactly what sort of 4## binary you are creating, and what sources, resources and libraries are 5## needed to create it. The makefile will then determine the proper 6## platform specific options. 7 8## Fill in the top section to define the binary being created and the makefile 9## will make sure that all of the hard work is taken care of for you, for both 10## PowerPC and Intel versions of the BeOS. 11 12## Application Specific Settings --------------------------------------------- 13 14# specify the name of the binary 15NAME= mounthost 16 17# specify the type of binary 18# APP: Application 19# SHARED: Shared library or add-on 20# STATIC: Static library archive 21# DRIVER: Kernel Driver 22TYPE= APP 23 24# specify the source files to use 25# full paths or paths relative to the makefile can be included 26# all files, regardless of directory, will have their object 27# files created in the common object directory. 28# Note that this means this makefile will not work correctly 29# if two source files with the same name (source.c or source.cpp) 30# are included from different directories. Also note that spaces 31# in folder names do not work well with this makefile. 32SRCS= mounthost.cpp LoginPanel.cpp rpc.cpp 33 34# specify the resource files to use 35# full path or a relative path to the resource file can be used. 36RSRCS= 37 38#specify additional libraries to link against 39# if libName.so or libName.a is the name of the library to link against 40# then simply specify Name in the LIBS list 41# if there is another naming scheme use the full binary 42# name: my_library.so or my_lib.a 43# libroot.so never needs to be specified here, although libbe.so does 44LIBS= be net beserved 45 46 47# specify the paths to directories where additional 48# libraries are to be found. /boot/develop/lib/PLATFORM/ is 49# already set. The paths can be full or relative to this 50# makefile. The paths included may not be recursive, so 51# specify all of the needed paths explicitly 52# Directories containing source-files are automatically added. 53LIBPATHS= ../transport 54 55# specify additional directories where header files can be found 56# directories where sources are found are included automatically 57# included. 58INCPATHS= 59 60# specify the level of optimization that you desire 61# NONE, SOME, FULL 62OPTIMIZE= FULL 63 64# specify any symbols to be defined. The symbols will be 65# set to a value of 1. For example specify DEBUG if you want 66# DEBUG=1 to be set when compiling. 67DEFINES= 68 69# specify special warning levels 70# if unspecified default warnings will be used 71# NONE = supress all warnings 72# ALL = enable all warnings 73WARNINGS = 74 75# specify symbols 76# if TRUE debug symbols will be created 77SYMBOLS = 78 79 80## Generic Makefile Rules --------------------------- 81## DO NOT MODIFY BENEATH THIS LINE ----------------- 82 83# determine wheather running on x86 or ppc 84MACHINE=$(shell uname -m) 85ifeq ($(MACHINE), BePC) 86 CPU = x86 87else 88 CPU = ppc 89endif 90 91# set the directory where object files and binaries will be created 92 OBJ_DIR := obj.$(CPU) 93 94# specify that the binary should be created in the object directory 95 TARGET := $(OBJ_DIR)/$(NAME) 96 97# specify the mimeset tool 98 MIMESET := mimeset 99 100# specify the tools for adding and removing resources 101 XRES = xres 102 103# SETTING: define debug symbols if desired 104ifeq ($(SYMBOLS), TRUE) 105 CFLAGS += -g 106endif 107 108 109# platform specific settings 110 111# x86 Settings 112ifeq ($(CPU), x86) 113# set the compiler and compiler flags 114 CC = gcc 115 ##!! change next time : drivers get -no-fpic and -fpic goes away !! 116 CFLAGS += -fpic 117 118# SETTING: set the proper optimization level 119 ifeq ($(OPTIMIZE), FULL) 120 OPTIMIZER = -O3 121 else 122 ifeq ($(OPTIMIZE), SOME) 123 OPTIMIZER = -O1 124 else 125 ifeq ($(OPTIMIZE), NONE) 126 OPTIMIZER = 127 endif 128 endif 129 endif 130 131 CFLAGS += $(OPTIMIZER) 132 133# SETTING: set warning level 134 ifeq ($(WARNINGS), ALL) 135 CFLAGS += -Wall -Wno-multichar -Wno-ctor-dtor-privacy 136 else 137 ifeq ($(WARNINGS), NONE) 138 139 endif 140 endif 141 142# set the linker and linker flags 143 LD = gcc 144 LDFLAGS = 145 146# SETTING: set linker flags for each binary type 147 ifeq ($(TYPE), APP) 148 LDFLAGS += -Xlinker -soname=_APP_ 149 else 150 ifeq ($(TYPE), SHARED) 151 LDFLAGS += -addon -Xlinker -soname=$(NAME) 152 else 153 ifeq ($(TYPE), DRIVER) 154 LDFLAGS += -nostdlib /boot/develop/lib/x86/_KERNEL_ 155 endif 156 endif 157 endif 158 159else 160 161# ppc Settings 162ifeq ($(CPU), ppc) 163# set the compiler and compiler flags 164 CC = mwcc 165 CFLAGS += 166 167# SETTING: set the proper optimization level 168 ifeq ($(OPTIMIZE), FULL) 169 OPTIMIZER = -O7 170 else 171 ifeq ($(OPTIMIZE), SOME) 172 OPTIMIZER = -O3 173 else 174 ifeq ($(OPTIMIZE), NONE) 175 OPTIMIZER = 176 endif 177 endif 178 endif 179 180 CFLAGS += $(OPTIMIZER) 181 182# SETTING: set warning level 183 ifeq ($(WARNINGS), ALL) 184 CFLAGS += -w all 185 else 186 ifeq ($(WARNINGS), NONE) 187 CFLAGS += -w 0 188 endif 189 endif 190 191 # clear the standard environment variable 192 # now there are no standard libraries to link against 193 BELIBFILES= 194 195# set the linker and linker flags 196 LD = mwldppc 197 198 ifeq ($(TYPE), APP) 199 LDFLAGS += 200 else 201 ifeq ($(TYPE), SHARED) 202 LDFLAGS += -xms 203 endif 204 endif 205 206 ifeq ($(TYPE), DRIVER) 207 LDFLAGS += -nodefaults \ 208 -export all \ 209 -G \ 210 /boot/develop/lib/ppc/glue-noinit.a \ 211 /boot/develop/lib/ppc/_KERNEL_ 212 else 213 # override the standard environment variable 214 LDFLAGS += -export pragma \ 215 -init _init_routine_ \ 216 -term _term_routine_ \ 217 -lroot \ 218 /boot/develop/lib/ppc/glue-noinit.a \ 219 /boot/develop/lib/ppc/init_term_dyn.o \ 220 /boot/develop/lib/ppc/start_dyn.o 221 222 endif 223 224 225endif 226endif 227 228 229# psuedo-function for converting a list of source files in SRCS variable 230# to a corresponding list of object files in $(OBJ_DIR)/xxx.o 231# The "function" strips off the src file suffix (.ccp or .c or whatever) 232# and then strips of the directory name, leaving just the root file name. 233# It then appends the .o suffix and prepends the $(OBJ_DIR)/ path 234define SRCS_LIST_TO_OBJS 235 $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SRCS), \ 236 $(basename $(notdir $(file)))))) 237endef 238 239OBJS = $(SRCS_LIST_TO_OBJS) 240 241# create a unique list of paths to our sourcefiles 242SRC_PATHS += $(sort $(foreach file, $(SRCS), $(dir $(file)))) 243 244# add source paths to VPATH if not already present 245VPATH := 246VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SRC_PATHS)))) 247 248# add source paths and include paths to INLCUDES if not already present 249INCLUDES = $(foreach path, $(INCPATHS) $(SRC_PATHS), $(addprefix -I, $(path))) 250 251 252# SETTING: add the -L prefix to all library paths to search 253LINK_PATHS = $(foreach path, $(LIBPATHS) $(SRC_PATHS) , \ 254 $(addprefix -L, $(path))) 255 256# SETTING: add the -l prefix to all libs to be linked against 257LINK_LIBS = $(foreach lib, $(LIBS), $(addprefix -l, $(lib))) 258 259# add to the linker flags 260LDFLAGS += $(LINK_PATHS) $(LINK_LIBS) 261 262# SETTING: add the defines to the compiler flags 263CFLAGS += $(foreach define, $(DEFINES), $(addprefix -D, $(define))) 264 265# SETTING: use the archive tools if building a static library 266# otherwise use the linker 267ifeq ($(TYPE), STATIC) 268 BUILD_LINE = ar -cru $(NAME) $(OBJS) 269else 270 BUILD_LINE = $(LD) -o $@ $(OBJS) $(LDFLAGS) 271endif 272 273# create the resource instruction 274 ifeq ($(RSRCS), ) 275 DO_RSRCS := 276 else 277 DO_RSRCS := $(XRES) -o $(TARGET) $(RSRCS) 278 endif 279 280 281# define the actual work to be done 282default: $(TARGET) 283 284$(TARGET): $(OBJ_DIR) $(OBJS) $(RSRCS) 285 $(BUILD_LINE) 286 $(DO_RSRCS) 287 $(MIMESET) -f $@ 288 289 290# rule to create the object file directory if needed 291$(OBJ_DIR):: 292 @[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1 293 294$(OBJ_DIR)/%.o : %.c 295 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 296$(OBJ_DIR)/%.o : %.cpp 297 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 298$(OBJ_DIR)/%.o : %.cp 299 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 300$(OBJ_DIR)/%.o : %.C 301 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 302$(OBJ_DIR)/%.o : %.CC 303 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 304$(OBJ_DIR)/%.o : %.CPP 305 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 306 307 308# empty rule. Things that depend on this rule will always get triggered 309FORCE: 310 311# The generic clean command. Delete everything in the object folder. 312clean :: FORCE 313 -rm -rf $(OBJ_DIR) 314 315# remove just the application from the object folder 316rmapp :: 317 -rm -f $(TARGET) 318 319$(OBJ_DIR)/mounthost.o: mounthost.cpp ksocket_internal.h 320