Skip to content

Commit

Permalink
build ok in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
vintagewang committed Jun 14, 2012
1 parent 197a2e7 commit d73aef5
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bin/jwrapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<javahome>${JAVA_HOME}</javahome>

<jvmtype>client</jvmtype>
<jvmtype>server</jvmtype>

<mainclass>com.github.vintage.wang.jwrapper.sample.NiceServer</mainclass>

Expand Down
6 changes: 6 additions & 0 deletions project/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export LWPR_ENV_RELEASE=1
export LWPR_ENV_ARCH=64

make clean all
23 changes: 23 additions & 0 deletions project/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SHELL = /bin/sh

TOPDIR := $(shell pwd)/..

TARGETS_DIR = \
$(TOPDIR)/src \

all::
@-mkdir $(TOPDIR)/include
@-mkdir $(TOPDIR)/bin
@-mkdir $(TOPDIR)/lib
@for tsubdir in $(TARGETS_DIR); \
do \
echo "making $${tsubdir}"; \
( cd $${tsubdir} && $(MAKE) ) || exit 1; \
done

clean::
@for tsubdir in $(TARGETS_DIR); \
do \
echo "clean $${tsubdir}"; \
( cd $${tsubdir} && $(MAKE) clean ) || exit 1; \
done
133 changes: 133 additions & 0 deletions project/makstand
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#
# $Id: makstand 120 2011-03-09 13:16:17Z vintage $
#
# Envionment Variables
# LWPR_ENV_RELEASE
# LWPR_ENV_ARCH=32/64
#
CC = g++
LD = g++
AR = ar rvuc
RM = rm -f
CP = cp
ECHO = @echo

OSBIT =
DEBUG = -g

DLLFIX = .so
SLBFIX = .a

EXEDIR = $(TOPDIR)/bin
DLLDIR = $(TOPDIR)/lib
SLBDIR = $(TOPDIR)/lib

TAREXE = $(EXEDIR)/$(APPNAME)
TARDLL = $(DLLDIR)/lib$(APPNAME)$(OSBIT)$(DLLFIX)
TARSLB = $(SLBDIR)/lib$(APPNAME)$(OSBIT)$(SLBFIX)

INCDIRS = -I. -I$(TOPDIR)/include
LIBDIRS = -L$(TOPDIR)/lib

DEFAULT_LIBS = -ldl -lpthread

ifeq ($(LWPR_ENV_ARCH),64)
CMP_ARCH = -m64
DEF_ARCH = -DARCH64
else
CMP_ARCH = -m32
DEF_ARCH = -DARCH32
endif

ifdef LWPR_ENV_RELEASE
DEBUG = -O
DEF_FLAGS = -DLINUX -D_REENTRANT $(DEF_ARCH) -DNDEBUG
else
DEBUG = -g
DEF_FLAGS = -DLINUX -D_REENTRANT $(DEF_ARCH)
endif

################### cpp program #############################
EXE_COMPILE = $(DEBUG) -Wall -Wno-format-y2k $(CMP_ARCH) $(DEF_FLAGS) $(INCDIRS)
EXE_LINK = $(DEBUG) -Wall -Wno-format-y2k $(CMP_ARCH) $(LIBDIRS) $(DEFAULT_LIBS)
SLB_COMPILE = $(EXE_COMPILE)
SLB_LINK = $(CMP_ARCH)
DLL_COMPILE = $(DEBUG) -fPIC -Wall -Wno-format-y2k $(CMP_ARCH) $(DEF_FLAGS) $(INCDIRS)
DLL_LINK = $(DEBUG) -fPIC $(CMP_ARCH) -shared $(LIBDIRS) $(DEFAULT_LIBS)

ifeq ($(APP_BUILDTYPE),bldexe)
CMP_FLGS = $(EXE_COMPILE)
TAR_NAME = $(TAREXE)
endif

ifeq ($(APP_BUILDTYPE),blddll)
CMP_FLGS = $(DLL_COMPILE)
TAR_NAME = $(TARDLL)
endif

ifeq ($(APP_BUILDTYPE),bldslb)
CMP_FLGS = $(SLB_COMPILE)
TAR_NAME = $(TARSLB)
endif

################### c program #############################
EXE_COMPILE_C = $(DEBUG) -fPIC -O2 -Wall -fno-strict-aliasing $(DEF_FLAGS) $(INCDIRS)
EXE_LINK_C = $(DEBUG) -fPIC -O2 -Wall -fno-strict-aliasing $(LIBDIRS) $(DEFAULT_LIBS)
SLB_COMPILE_C = $(EXE_COMPILE_C)
SLB_LINK_C =
DLL_COMPILE_C = $(EXE_COMPILE_C)
DLL_LINK_C = $(DEBUG) -fPIC -shared $(DEFAULT_LIBS)

ifeq ($(APP_BUILDTYPE),bldexe_c)
CC = gcc
LD = gcc
CMP_FLGS = $(EXE_COMPILE_C)
TAR_NAME = $(TAREXE)
endif

ifeq ($(APP_BUILDTYPE),blddll_c)
CC = gcc
LD = gcc
CMP_FLGS = $(DLL_COMPILE_C)
TAR_NAME = $(TARDLL)
endif

ifeq ($(APP_BUILDTYPE),bldslb_c)
CC = gcc
LD = gcc
CMP_FLGS = $(SLB_COMPILE_C)
TAR_NAME = $(TARSLB)
endif

bldexe: $(TAREXE)
blddll: $(TARDLL)
bldslb: $(TARSLB)

bldexe_c: $(TAREXE)
blddll_c: $(TARDLL)
bldslb_c: $(TARSLB)

$(TAREXE): $(APPOBJS)
$(ECHO) "Linking [$@] ..."
$(LD) -o $@ $(APPOBJS) $(APP_LDDFLGS) $(EXE_LINK)
$(ECHO) "==========>> Excute File [$@] Build Done!!!"

$(TARDLL): $(APPOBJS)
$(ECHO) "Linking [$@] ..."
$(LD) -o $@ $(APPOBJS) $(APP_LDDFLGS) $(DLL_LINK)
$(ECHO) "==========>> Dynamic Library File [$@] Build Done!!!"

$(TARSLB): $(APPOBJS)
$(ECHO) "Linking [$@] ..."
$(AR) $@ $(APPOBJS) $(APP_LDDFLGS) $(SLB_LINK)
$(ECHO) "==========>> Static Library File [$@] Build Done!!!"

cleanup:
@$(RM) $(APPOBJS) $(TAR_NAME)
$(ECHO) "$(APPOBJS) $(TAR_NAME) cleaned"

%.o: %.c
$(CC) $(CMP_FLGS) $(APP_CMPFLGS) -o $@ -c $<

%.o: %.cpp
$(CC) $(CMP_FLGS) $(APP_CMPFLGS) -o $@ -c $<
1 change: 1 addition & 0 deletions src/DLL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "DLL.h"
#include <stdio.h>
#include <assert.h>

DLL::DLL(const char* file) : dll(NULL)
Expand Down
6 changes: 3 additions & 3 deletions src/JWUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/
#include "JWUtil.h"
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

#ifdef WIN32
#include <Windows.h>
#include <direct.h>
#else
#include <sys/types.h>
#include <unistd.h>
Expand Down Expand Up @@ -48,7 +48,7 @@ namespace JWUtil
#else
char proc[64] = {0};
sprintf(proc, "/proc/%d/exe", getpid());
char path[MAX_PATH + 1] = {0};
char path[PATH_MAX + 1] = {0};
readlink(proc, path, sizeof(path) - 1);
result = path;
#endif
Expand All @@ -64,7 +64,7 @@ namespace JWUtil
_getcwd(path, sizeof(path) - 1);
result = path;
#else
char path[MAX_PATH + 1] = {0};
char path[PATH_MAX + 1] = {0};
getcwd(path, sizeof(path) - 1);
result = path;
#endif
Expand Down
18 changes: 9 additions & 9 deletions src/JavaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,54 +230,54 @@ std::string JavaConfig::getJVMDllPath()
#elif defined(SOLARIS_X86)
#if defined(ARCH64)
result += this->javaHome;
result += "/jre/lib/amd64";
result += "/jre/lib/amd64/";
result += this->jvmType;
result += "/libjvm.so";
#else
result += this->javaHome;
result += "/jre/lib/i386";
result += "/jre/lib/i386/";
result += this->jvmType;
result += "/libjvm.so";
#endif
#elif defined(SOLARIS_X86)
#if defined(ARCH64)
result += this->javaHome;
result += "/jre/lib/sparcv9";
result += "/jre/lib/sparcv9/";
result += this->jvmType;
result += "/libjvm.so";
#else
result += this->javaHome;
result += "/jre/lib/sparc";
result += "/jre/lib/sparc/";
result += this->jvmType;
result += "/libjvm.so";
#endif
#elif defined(HPUX)
#if defined(ARCH64)
result += this->javaHome;
result += "/jre/lib/IA64W";
result += "/jre/lib/IA64W/";
result += this->jvmType;
result += "/libjvm.so";
#else
result += this->javaHome;
result += "/jre/lib/IA64N";
result += "/jre/lib/IA64N/";
result += this->jvmType;
result += "/libjvm.so";
#endif
#elif defined(LINUX)
#if defined(ARCH64)
result += this->javaHome;
result += "/jre/lib/amd64";
result += "/jre/lib/amd64/";
result += this->jvmType;
result += "/libjvm.so";
#else
result += this->javaHome;
result += "/jre/lib/i386";
result += "/jre/lib/i386/";
result += this->jvmType;
result += "/libjvm.so";
#endif
#elif defined(AIX)
result += this->javaHome;
result += "/jre/bin/classic";
result += "/jre/bin/classic/";
result += this->jvmType;
result += "/libjvm.a";
#endif
Expand Down
44 changes: 44 additions & 0 deletions src/jwrapper.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Copyright 2012 Wangxr, [email protected]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
TOPDIR = ..

APPNAME = jwrapper

APPOBJS = \
DLL.o \
JavaConfig.o \
JavaLauncher.o \
jwrapper.o \
JWUtil.o \

APP_CMPFLGS = -I$(BOOST_HOME) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux

APP_LDDFLGS =

# app build type: bldexe blddll bldslb bldexe_c blddll_c bldslb_c
APP_BUILDTYPE = bldexe
all: $(APP_BUILDTYPE)
clean: cleanup

bldexe blddll bldslb bldexe_c blddll_c bldslb_c cleanup:
@TOPDIR="$(TOPDIR)"; \
APPNAME="$(APPNAME)"; \
APPOBJS="$(APPOBJS)"; \
APP_CMPFLGS="$(APP_CMPFLGS)"; \
APP_LDDFLGS="$(APP_LDDFLGS)"; \
APP_BUILDTYPE="$(APP_BUILDTYPE)"; \
export TOPDIR APPNAME APPOBJS APP_CMPFLGS APP_LDDFLGS APP_BUILDTYPE; \
$(MAKE) -f $(TOPDIR)/project/makstand $@
2 changes: 2 additions & 0 deletions src/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all clean:
$(MAKE) -f jwrapper.mak $@

0 comments on commit d73aef5

Please sign in to comment.