mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-08-29 21:28:25 +02:00
fixes #923 converted src/common to a library
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#-*- mode: makefile; tab-width: 4; -*-
|
||||
#
|
||||
# This library provides basic initialization function used in all executables,
|
||||
# including the GUI and all compilers
|
||||
# on QT
|
||||
|
||||
include(../../qmake.inc)
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
SOURCES = init.cpp
|
||||
|
||||
HEADERS = ../../config.h commoninit.h
|
||||
|
||||
CONFIG += staticlib
|
||||
|
||||
TARGET = common
|
||||
|
||||
INSTALLS -= target
|
||||
|
||||
exists(qmake.inc):include( qmake.inc)
|
||||
+5
-76
@@ -4,29 +4,11 @@
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
#if defined(Q_OS_MACX) || defined(Q_OS_WIN32)
|
||||
# include <qsettings.h>
|
||||
# include <QDir>
|
||||
# include <QApplication>
|
||||
//# include <QCoreApplication>
|
||||
#else
|
||||
# include <limits.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QtDebug>
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h>
|
||||
# include <pwd.h>
|
||||
#else
|
||||
# include <direct.h>
|
||||
# include <stdlib.h>
|
||||
# include <io.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "fwbuilder/libfwbuilder-config.h"
|
||||
@@ -53,33 +35,15 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
|
||||
#if defined(Q_OS_WIN32) || defined(Q_OS_MACX)
|
||||
extern void init_win();
|
||||
#endif
|
||||
|
||||
void init(char * const*)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
* Note appRootDir is the path to the directory where fwbuilder binary
|
||||
* is installed (on Mac it is <wherever>/fwbuilder3.app/Contents/MacOS.
|
||||
* On Windows it is c:\FWBuilder30, on Linux it is something like
|
||||
* /usr/bin or /usr/local/bin and so on.
|
||||
*/
|
||||
#if defined(Q_OS_WIN32) || defined(Q_OS_MACX)
|
||||
if (QCoreApplication::instance()==NULL)
|
||||
{
|
||||
int ac = 0;
|
||||
char **av = { NULL };
|
||||
new QApplication( ac, av );
|
||||
}
|
||||
QDir dir(QApplication::applicationDirPath());
|
||||
appRootDir = string(dir.absolutePath().toAscii().constData());
|
||||
|
||||
/* On windows and mac we install API resources (DTD etc) in the
|
||||
* dir right above the one where we install resources for the GUI and compilers
|
||||
*/
|
||||
if (respath=="") respath = appRootDir + FS_SEPARATOR + RES_DIR;
|
||||
string::size_type n0 = respath.find_last_of("/\\");
|
||||
librespath = respath.substr(0, n0);
|
||||
init_win();
|
||||
|
||||
#else
|
||||
appRootDir = string(PREFIX) + FS_SEPARATOR + "bin";
|
||||
@@ -88,18 +52,11 @@ void init(char * const*)
|
||||
|
||||
if (respath=="") respath = RES_DIR;
|
||||
librespath = LIBFWBUILDER_TEMPLATE_DIR;
|
||||
#endif
|
||||
|
||||
|
||||
libfwbuilder::init();
|
||||
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
argv0 = appRootDir + FS_SEPARATOR + "fwbuilder.exe";
|
||||
#else
|
||||
/* need argv0 for built-in installer on unix and mac */
|
||||
argv0 = appRootDir + FS_SEPARATOR + "fwbuilder";
|
||||
#endif
|
||||
|
||||
sysfname = respath + FS_SEPARATOR + "objects_init.xml";
|
||||
tempfname = respath+ FS_SEPARATOR + "templates.xml";
|
||||
@@ -108,35 +65,7 @@ void init(char * const*)
|
||||
localepath = respath + "/locale";
|
||||
|
||||
/* default directory where the user may want to save files */
|
||||
#if defined(Q_OS_WIN32)
|
||||
userDataDir = string(getenv("USERPROFILE"))+"\\Documents";
|
||||
#elif defined(Q_OS_MACX)
|
||||
userDataDir = string(getenv("HOME"))+"/Documents";
|
||||
#else
|
||||
userDataDir = string(getenv("HOME"));
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define INFO_BUFFER_SIZE 32767
|
||||
|
||||
TCHAR infoBuf[INFO_BUFFER_SIZE];
|
||||
DWORD bufCharCount = INFO_BUFFER_SIZE;
|
||||
|
||||
bufCharCount = INFO_BUFFER_SIZE;
|
||||
if( GetUserName( infoBuf, &bufCharCount ) )
|
||||
{
|
||||
#ifdef UNICODE
|
||||
user_name = QString::fromUtf16((ushort*)infoBuf);
|
||||
#else
|
||||
user_name = QString::fromLocal8Bit(infoBuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
user_name = user_name.replace(' ','_');
|
||||
|
||||
#else
|
||||
|
||||
char *lname = getenv("LOGNAME");
|
||||
if (lname!=NULL)
|
||||
|
||||
@@ -13,5 +13,12 @@ TARGET = fwbedit
|
||||
|
||||
QMAKE_COPY = ../../install.sh -m 0755 -s
|
||||
|
||||
DEPENDPATH = ../common
|
||||
|
||||
!win32:LIBS += ../common/libcommon.a
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a
|
||||
|
||||
win32:CONFIG += console
|
||||
|
||||
win32:LIBS += ../common/libcommon.lib
|
||||
win32:PRE_TARGETDEPS = ../common/libcommon.lib
|
||||
|
||||
+12
-6
@@ -463,27 +463,33 @@ contains( HAVE_QTDBUS, 1 ):unix {
|
||||
}
|
||||
|
||||
# !macx:LIBS += -lQtDBus # workaround for QT += dbus not working with Qt < 4.4.0
|
||||
INCLUDEPATH += ../iptlib \
|
||||
INCLUDEPATH += ../common \
|
||||
../iptlib \
|
||||
../pflib \
|
||||
../cisco_lib/ \
|
||||
../compiler_lib/
|
||||
DEPENDPATH = ../iptlib \
|
||||
DEPENDPATH = ../common \
|
||||
../iptlib \
|
||||
../pflib \
|
||||
../cisco_lib/ \
|
||||
../compiler_lib
|
||||
win32:LIBS += ../iptlib/release/iptlib.lib \
|
||||
win32:LIBS += ../common/release/libcommon.lib \
|
||||
../iptlib/release/iptlib.lib \
|
||||
../pflib/release/fwbpf.lib \
|
||||
../cisco_lib/release/fwbcisco.lib \
|
||||
../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../iptlib/libiptlib.a \
|
||||
!win32:LIBS += ../common/libcommon.a \
|
||||
../iptlib/libiptlib.a \
|
||||
../pflib/libfwbpf.a \
|
||||
../cisco_lib/libfwbcisco.a \
|
||||
../compiler_lib/libcompilerdriver.a
|
||||
win32:PRE_TARGETDEPS = ../iptlib/release/iptlib.lib \
|
||||
win32:PRE_TARGETDEPS = ../common/release/libcommon.lib \
|
||||
../iptlib/release/iptlib.lib \
|
||||
../pflib/release/fwbpf.lib \
|
||||
../cisco_lib/release/fwbcisco.lib \
|
||||
../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../iptlib/libiptlib.a \
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a \
|
||||
../iptlib/libiptlib.a \
|
||||
../pflib/libfwbpf.a \
|
||||
../cisco_lib/libfwbcisco.a \
|
||||
../compiler_lib/libcompilerdriver.a
|
||||
|
||||
@@ -99,8 +99,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "../common/init.cpp"
|
||||
|
||||
#if defined(Q_WS_MAC)
|
||||
extern void connectOdocHandler();
|
||||
#endif
|
||||
|
||||
@@ -18,13 +18,13 @@ HEADERS = ../../config.h
|
||||
|
||||
win32:CONFIG += console
|
||||
|
||||
INCLUDEPATH += ../cisco_lib/ ../compiler_lib
|
||||
INCLUDEPATH += ../common ../cisco_lib/ ../compiler_lib
|
||||
|
||||
win32:LIBS += ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:LIBS += ../common/release/libcommon.lib ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../common/libcommon.a ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
win32:PRE_TARGETDEPS = ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:PRE_TARGETDEPS = ../common/release/libcommon.lib ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
|
||||
LIBS += $$LIBS_FWCOMPILER
|
||||
|
||||
+5
-5
@@ -14,14 +14,14 @@ win32:CONFIG += console
|
||||
|
||||
# unix { !macx: CONFIG -= qt }
|
||||
|
||||
INCLUDEPATH += ../pflib ../compiler_lib
|
||||
INCLUDEPATH += ../common ../pflib ../compiler_lib
|
||||
DEPENDPATH = ../pflib
|
||||
|
||||
win32:LIBS += ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:LIBS += ../common/release/libcommon.lib ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../common/libcommon.a ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
win32:PRE_TARGETDEPS = ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:PRE_TARGETDEPS = ../common/release/libcommon.lib ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
LIBS += $$LIBS_FWCOMPILER
|
||||
|
||||
|
||||
+5
-5
@@ -12,14 +12,14 @@ HEADERS = ../../config.h
|
||||
|
||||
win32:CONFIG += console
|
||||
|
||||
INCLUDEPATH += ../pflib ../compiler_lib
|
||||
INCLUDEPATH += ../common ../pflib ../compiler_lib
|
||||
DEPENDPATH = ../pflib
|
||||
|
||||
win32:LIBS += ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:LIBS += ../common/release/libcommon.lib ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../common/libcommon.a ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
win32:PRE_TARGETDEPS = ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:PRE_TARGETDEPS = ../common/release/libcommon.lib ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
|
||||
LIBS += $$LIBS_FWCOMPILER
|
||||
|
||||
+6
-6
@@ -14,14 +14,14 @@ win32: CONFIG += console
|
||||
|
||||
LIBS += $$LIBS_FWCOMPILER
|
||||
|
||||
INCLUDEPATH += ../iptlib ../compiler_lib/
|
||||
DEPENDPATH = ../iptlib ../compiler_lib
|
||||
INCLUDEPATH += ../common ../iptlib ../compiler_lib/
|
||||
DEPENDPATH = ../common ../iptlib ../compiler_lib
|
||||
|
||||
win32:LIBS += ../iptlib/release/iptlib.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../iptlib/libiptlib.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:LIBS += ../common/release/libcommon.lib ../iptlib/release/iptlib.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../common/libcommon.a ../iptlib/libiptlib.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
win32:PRE_TARGETDEPS = ../iptlib/release/iptlib.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../iptlib/libiptlib.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:PRE_TARGETDEPS = ../common/release/libcommon.lib ../iptlib/release/iptlib.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a ../iptlib/libiptlib.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
TARGET = fwb_ipt
|
||||
|
||||
|
||||
+5
-5
@@ -12,14 +12,14 @@ HEADERS = ../../config.h
|
||||
|
||||
win32:CONFIG += console
|
||||
|
||||
INCLUDEPATH += ../pflib ../compiler_lib
|
||||
INCLUDEPATH += ../common ../pflib ../compiler_lib
|
||||
DEPENDPATH = ../pflib
|
||||
|
||||
win32:LIBS += ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:LIBS += ../common/release/libcommon.lib ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../common/libcommon.a ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
win32:PRE_TARGETDEPS = ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:PRE_TARGETDEPS = ../common/release/libcommon.lib ../pflib/release/fwbpf.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a ../pflib/libfwbpf.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
|
||||
LIBS += $$LIBS_FWCOMPILER
|
||||
|
||||
+5
-5
@@ -12,13 +12,13 @@ HEADERS = ../../config.h
|
||||
|
||||
win32:CONFIG += console
|
||||
|
||||
INCLUDEPATH += ../cisco_lib/ ../compiler_lib
|
||||
INCLUDEPATH += ../common ../cisco_lib/ ../compiler_lib
|
||||
|
||||
win32:LIBS += ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:LIBS += ../common/release/libcommon.lib ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:LIBS += ../common/libcommon.a ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
win32:PRE_TARGETDEPS = ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
win32:PRE_TARGETDEPS = ../common/release/libcommon.lib ../cisco_lib/release/fwbcisco.lib ../compiler_lib/release/compilerdriver.lib
|
||||
!win32:PRE_TARGETDEPS = ../common/libcommon.a ../cisco_lib/libfwbcisco.a ../compiler_lib/libcompilerdriver.a
|
||||
|
||||
LIBS += $$LIBS_FWCOMPILER
|
||||
|
||||
|
||||
+5
-2
@@ -8,7 +8,7 @@ TEMPLATE = subdirs
|
||||
CONFIG += ordered
|
||||
|
||||
TARGET = src
|
||||
SUBDIRS = res fwbedit fwtransfer
|
||||
SUBDIRS = res
|
||||
# NOTE: 2.1 does not install scripts from src/tools ( fwb_install , fwb_compile_all)
|
||||
|
||||
contains( HAVE_ANTLR_RUNTIME, 1 ) {
|
||||
@@ -18,7 +18,10 @@ contains( HAVE_ANTLR_RUNTIME, 1 ) {
|
||||
}
|
||||
}
|
||||
|
||||
SUBDIRS += compiler_lib \
|
||||
SUBDIRS += common \
|
||||
compiler_lib \
|
||||
fwbedit \
|
||||
fwtransfer \
|
||||
iptlib \
|
||||
pflib \
|
||||
cisco_lib \
|
||||
|
||||
Reference in New Issue
Block a user