|
| 1 | +# |
| 2 | +# Makefile template |
| 3 | +# |
| 4 | +# This is an example Makefile that can be used by anyone who is building |
| 5 | +# his or her own PHP extensions using the PHP-CPP library. |
| 6 | +# |
| 7 | +# In the top part of this file we have included variables that can be |
| 8 | +# altered to fit your configuration, near the bottom the instructions and |
| 9 | +# dependencies for the compiler are defined. The deeper you get into this |
| 10 | +# file, the less likely it is that you will have to change anything in it. |
| 11 | +# |
| 12 | + |
| 13 | +# |
| 14 | +# Name of your extension |
| 15 | +# |
| 16 | +# This is the name of your extension. Based on this extension name, the |
| 17 | +# name of the library file (name.so) and the name of the config file (name.ini) |
| 18 | +# are automatically generated |
| 19 | +# |
| 20 | + |
| 21 | +NAME = pxjavascript |
| 22 | + |
| 23 | + |
| 24 | +# |
| 25 | +# Php.ini directories |
| 26 | +# |
| 27 | +# In the past, PHP used a single php.ini configuration file. Today, most |
| 28 | +# PHP installations use a conf.d directory that holds a set of config files, |
| 29 | +# one for each extension. Use this variable to specify this directory. |
| 30 | +# |
| 31 | + |
| 32 | +INI_DIR = /etc/php5/mods-available/ |
| 33 | + |
| 34 | + |
| 35 | +# |
| 36 | +# The extension dirs |
| 37 | +# |
| 38 | +# This is normally a directory like /usr/lib/php5/20121221 (based on the |
| 39 | +# PHP version that you use. We make use of the command line 'php-config' |
| 40 | +# instruction to find out what the extension directory is, you can override |
| 41 | +# this with a different fixed directory |
| 42 | +# |
| 43 | + |
| 44 | +EXTENSION_DIR = $(shell php-config --extension-dir) |
| 45 | + |
| 46 | + |
| 47 | +# |
| 48 | +# The name of the extension and the name of the .ini file |
| 49 | +# |
| 50 | +# These two variables are based on the name of the extension. We simply add |
| 51 | +# a certain extension to them (.so or .ini) |
| 52 | +# |
| 53 | + |
| 54 | +EXTENSION = ${NAME}.so |
| 55 | +INI = ${NAME}.ini |
| 56 | + |
| 57 | + |
| 58 | +# |
| 59 | +# Compiler |
| 60 | +# |
| 61 | +# By default, the GNU C++ compiler is used. If you want to use a different |
| 62 | +# compiler, you can change that here. You can change this for both the |
| 63 | +# compiler (the program that turns the c++ files into object files) and for |
| 64 | +# the linker (the program that links all object files into the single .so |
| 65 | +# library file. By default, g++ (the GNU C++ compiler) is used for both. |
| 66 | +# |
| 67 | + |
| 68 | +COMPILER = c++ |
| 69 | +LINKER = c++ |
| 70 | + |
| 71 | + |
| 72 | +# |
| 73 | +# Compiler and linker flags |
| 74 | +# |
| 75 | +# This variable holds the flags that are passed to the compiler. By default, |
| 76 | +# we include the -O2 flag. This flag tells the compiler to optimize the code, |
| 77 | +# but it makes debugging more difficult. So if you're debugging your application, |
| 78 | +# you probably want to remove this -O2 flag. At the same time, you can then |
| 79 | +# add the -g flag to instruct the compiler to include debug information in |
| 80 | +# the library (but this will make the final libphpcpp.so file much bigger, so |
| 81 | +# you want to leave that flag out on production servers). |
| 82 | +# |
| 83 | +# If your extension depends on other libraries (and it does at least depend on |
| 84 | +# one: the PHP-CPP library), you should update the LINKER_DEPENDENCIES variable |
| 85 | +# with a list of all flags that should be passed to the linker. |
| 86 | +# |
| 87 | + |
| 88 | +COMPILER_FLAGS = -Wall -c -O2 -std=c++11 -fpic -DVERSION="`./version.sh`" -I. -g |
| 89 | +LINKER_FLAGS = -shared |
| 90 | +LINKER_DEPENDENCIES = -lphpcpp -lv8 |
| 91 | + |
| 92 | + |
| 93 | +# |
| 94 | +# Command to remove files, copy files and create directories. |
| 95 | +# |
| 96 | +# I've never encountered a *nix environment in which these commands do not work. |
| 97 | +# So you can probably leave this as it is |
| 98 | +# |
| 99 | + |
| 100 | +RM = rm -f |
| 101 | +CP = cp -f |
| 102 | +MKDIR = mkdir -p |
| 103 | + |
| 104 | + |
| 105 | +# |
| 106 | +# All source files are simply all *.cpp files found in the current directory |
| 107 | +# |
| 108 | +# A builtin Makefile macro is used to scan the current directory and find |
| 109 | +# all source files. The object files are all compiled versions of the source |
| 110 | +# file, with the .cpp extension being replaced by .o. |
| 111 | +# |
| 112 | + |
| 113 | +SOURCES = $(wildcard *.cpp) |
| 114 | +OBJECTS = $(SOURCES:%.cpp=%.o) |
| 115 | + |
| 116 | + |
| 117 | +# |
| 118 | +# From here the build instructions start |
| 119 | +# |
| 120 | + |
| 121 | +all: ${OBJECTS} ${EXTENSION} |
| 122 | + |
| 123 | +${EXTENSION}: ${OBJECTS} |
| 124 | + ${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES} |
| 125 | + |
| 126 | +${OBJECTS}: |
| 127 | + ${COMPILER} ${COMPILER_FLAGS} -o $@ ${@:%.o=%.cpp} |
| 128 | + |
| 129 | +install: |
| 130 | + ${CP} ${EXTENSION} ${EXTENSION_DIR} |
| 131 | + ${CP} ${INI} ${INI_DIR} |
| 132 | + |
| 133 | +clean: |
| 134 | + ${RM} ${EXTENSION} ${OBJECTS} |
| 135 | + |
0 commit comments