public/sample_ext/Makefile
author David Anderson <dvander@alliedmods.net>
Wed Feb 25 20:07:12 2009 -0500 (2009-02-25)
changeset 2607 f3b8bbe17f85
parent 2471 194be299b700
child 2479 44e8e76d4e53
permissions -rw-r--r--
Backed out changeset fa286305bd3f
ds@1977
     1
# (C)2004-2008 SourceMod Development Team
ds@1952
     2
# Makefile written by David "BAILOPAN" Anderson
dvander@354
     3
dvander@354
     4
SMSDK = ../..
ds@1977
     5
SRCDS_BASE = ~/srcds
ds@1952
     6
HL2SDK_ORIG = ../../../hl2sdk
ds@1952
     7
HL2SDK_OB = ../../../hl2sdk-ob
ds@2426
     8
MMSOURCE17 = ../../../mmsource-1.7
dvander@354
     9
dvander@354
    10
#####################################
dvander@354
    11
### EDIT BELOW FOR OTHER PROJECTS ###
dvander@354
    12
#####################################
dvander@354
    13
dvander@354
    14
PROJECT = sample
dvander@354
    15
ds@1957
    16
#Uncomment for Metamod: Source enabled extension
ds@1957
    17
#USEMETA = true
ds@1957
    18
ds@757
    19
OBJECTS = sdk/smsdk_ext.cpp extension.cpp
dvander@354
    20
dvander@354
    21
##############################################
dvander@354
    22
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
dvander@354
    23
##############################################
dvander@354
    24
ds@2047
    25
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
ds@1957
    26
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
ds@1977
    27
C_GCC4_FLAGS = -fvisibility=hidden
ds@1977
    28
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
dvander@2471
    29
CPP = gcc
dvander@354
    30
ds@1957
    31
override ENGSET = false
ds@1952
    32
ifeq "$(ENGINE)" "original"
ds@1952
    33
	HL2SDK = $(HL2SDK_ORIG)
ds@1952
    34
	HL2PUB = $(HL2SDK_ORIG)/public
ds@1952
    35
	HL2LIB = $(HL2SDK_ORIG)/linux_sdk
ds@2426
    36
	METAMOD = $(MMSOURCE17)/core-legacy
ds@1952
    37
	INCLUDE += -I$(HL2SDK)/public/dlls
ds@1952
    38
	SRCDS = $(SRCDS_BASE)
ds@1957
    39
	override ENGSET = true
ds@1952
    40
endif
ds@1952
    41
ifeq "$(ENGINE)" "orangebox"
ds@1952
    42
	HL2SDK = $(HL2SDK_OB)
ds@1952
    43
	HL2PUB = $(HL2SDK_OB)/public
ds@2201
    44
	HL2LIB = $(HL2SDK_OB)/lib/linux
ds@1952
    45
	CFLAGS += -DORANGEBOX_BUILD
ds@2426
    46
	METAMOD = $(MMSOURCE17)/core
ds@1977
    47
	INCLUDE += -I$(HL2SDK)/public/game/server
ds@1952
    48
	SRCDS = $(SRCDS_BASE)/orangebox
ds@1957
    49
	override ENGSET = true
ds@1952
    50
endif
dvander@354
    51
ds@1957
    52
ifeq "$(USEMETA)" "true"
ds@1957
    53
	LINK_HL2 = $(HL2LIB)/tier1_i486.a vstdlib_i486.so tier0_i486.so
ds@1952
    54
ds@1957
    55
	LINK += $(LINK_HL2)
dvander@354
    56
ds@1957
    57
	INCLUDE += -I. -I.. -Isdk -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 \
ds@2426
    58
		-I$(METAMOD) -I$(METAMOD)/sourcehook -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn 
ds@1957
    59
else
ds@1977
    60
	INCLUDE += -I. -I.. -Isdk -I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
ds@1957
    61
endif
ds@1952
    62
dvander@2471
    63
LINK += -m32 -lm -ldl
ds@1957
    64
ds@1957
    65
CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
ds@1952
    66
	-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror -Wno-switch \
ds@1952
    67
	-Wno-unused -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -m32
ds@1977
    68
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti
dvander@354
    69
dvander@354
    70
################################################
dvander@354
    71
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
dvander@354
    72
################################################
dvander@354
    73
dvander@354
    74
ifeq "$(DEBUG)" "true"
dvander@354
    75
	BIN_DIR = Debug
dvander@358
    76
	CFLAGS += $(C_DEBUG_FLAGS)
dvander@354
    77
else
dvander@354
    78
	BIN_DIR = Release
dvander@358
    79
	CFLAGS += $(C_OPT_FLAGS)
dvander@354
    80
endif
dvander@354
    81
ds@1957
    82
ifeq "$(USEMETA)" "true"
ds@1957
    83
	BIN_DIR := $(BIN_DIR).$(ENGINE)
ds@1957
    84
endif
dvander@354
    85
dvander@2471
    86
OS := $(shell uname -s)
dvander@2471
    87
ifeq "$(OS)" "Darwin"
dvander@2471
    88
	LINK += -dynamiclib
dvander@2471
    89
	BINARY = $(PROJECT).ext.dylib
dvander@2471
    90
else
dvander@2471
    91
	LINK += -static-libgcc -shared
dvander@2471
    92
	BINARY = $(PROJECT).ext.so
dvander@2471
    93
endif
dvander@2471
    94
dvander@354
    95
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
dvander@354
    96
ifeq "$(GCC_VERSION)" "4"
ds@1977
    97
	CFLAGS += $(C_GCC4_FLAGS)
dvander@354
    98
	CPPFLAGS += $(CPP_GCC4_FLAGS)
dvander@354
    99
endif
dvander@354
   100
dvander@354
   101
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
dvander@354
   102
dvander@354
   103
$(BIN_DIR)/%.o: %.cpp
dvander@354
   104
	$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
dvander@354
   105
ds@1957
   106
all: check
ds@757
   107
	mkdir -p $(BIN_DIR)/sdk
ds@2458
   108
	if [ "$(USEMETA)" = "true" ]; then \
ds@1957
   109
		ln -sf $(SRCDS)/bin/vstdlib_i486.so vstdlib_i486.so; \
ds@1957
   110
		ln -sf $(SRCDS)/bin/tier0_i486.so tier0_i486.so; \
ds@1957
   111
	fi
ds@1952
   112
	$(MAKE) -f Makefile extension
dvander@354
   113
ds@1957
   114
check:
ds@2455
   115
	if [ "$(USEMETA)" = "true" ] && [ "$(ENGSET)" = "false" ]; then \
ds@1957
   116
		echo "You must supply ENGINE=orangebox or ENGINE=original"; \
ds@1957
   117
		exit 1; \
ds@1957
   118
	fi
dvander@354
   119
ds@1957
   120
extension: check $(OBJ_LINUX)
dvander@2471
   121
	$(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -o $(BIN_DIR)/$(BINARY)
ds@1952
   122
ds@1952
   123
debug:
ds@1952
   124
	$(MAKE) -f Makefile all DEBUG=true
dvander@354
   125
dvander@354
   126
default: all
dvander@354
   127
ds@1957
   128
clean: check
ds@1952
   129
	rm -rf $(BIN_DIR)/*.o
ds@1952
   130
	rm -rf $(BIN_DIR)/sdk/*.o
ds@1952
   131
	rm -rf $(BIN_DIR)/$(BINARY)